Skip to content

Commit 3a87ec6

Browse files
committed
chore: sync with microG unofficial installer
Signed-off-by: ale5000 <15793015+ale5000-git@users.noreply.github.com>
1 parent 414f742 commit 3a87ec6

1 file changed

Lines changed: 20 additions & 1 deletion

File tree

docs/conf.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77
# For the full list of built-in configuration values, see the documentation: https://www.sphinx-doc.org/en/master/usage/configuration.html
88

99
import os
10+
import re
1011
import subprocess
12+
from docutils import nodes
1113

12-
# Functions
1314
def get_version():
1415
props_path = os.path.join(os.path.dirname(__file__), '..', 'zip-content', 'module.prop')
1516

@@ -36,6 +37,24 @@ def get_revision():
3637
except Exception:
3738
return None
3839

40+
def transform_doc_links(app, docname, source):
41+
"""Phase 1: Convert local .rst links (no anchor) to :doc: roles."""
42+
source[0] = re.sub(r'`([^`<]+)\s*<((?!http|mailto)[^>]+)\.rst>`_', r':doc:`\1 <\2>`', source[0])
43+
44+
def fix_anchors_in_tree(app, doctree, docname):
45+
"""Phase 2: Fix local .rst#anchor links in the resolved tree."""
46+
ext = '.pdf' if app.builder.name == 'latex' else '.html'
47+
for node in doctree.traverse(nodes.reference):
48+
uri = node.get('refuri')
49+
if uri and '.rst#' in uri and not uri.startswith(('http', 'mailto')):
50+
node['refuri'] = uri.replace('.rst#', f'{ext}#')
51+
52+
def setup(app):
53+
# Process text before parsing
54+
app.connect('source-read', transform_doc_links)
55+
# Process nodes after tree is built
56+
app.connect('doctree-resolved', fix_anchors_in_tree)
57+
3958
# Project information
4059
project = 'Google sync add-on'
4160
author = 'ale5000'

0 commit comments

Comments
 (0)