[Python-checkins] [3.11] GH-97950: Allow translation of index directive content (GH-104000) (#104151)
hugovk
webhook-mailer at python.org
Thu May 4 03:26:15 EDT 2023
https://github.com/python/cpython/commit/8f94c9465bda92f4dd913635799a375881e5c93e
commit: 8f94c9465bda92f4dd913635799a375881e5c93e
branch: 3.11
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: hugovk <hugovk at users.noreply.github.com>
date: 2023-05-04T10:26:08+03:00
summary:
[3.11] GH-97950: Allow translation of index directive content (GH-104000) (#104151)
Co-authored-by: Adam Turner <9087854+AA-Turner at users.noreply.github.com>
files:
M Doc/conf.py
M Doc/tools/extensions/pyspecific.py
diff --git a/Doc/conf.py b/Doc/conf.py
index 3bb915b0b02e..3bd828f8ce9e 100644
--- a/Doc/conf.py
+++ b/Doc/conf.py
@@ -86,6 +86,11 @@
# Avoid a warning with Sphinx >= 2.0
master_doc = 'contents'
+# Allow translation of index directives
+gettext_additional_targets = [
+ 'index',
+]
+
# Options for HTML output
# -----------------------
diff --git a/Doc/tools/extensions/pyspecific.py b/Doc/tools/extensions/pyspecific.py
index b4fea983818d..3ff2a91b1fef 100644
--- a/Doc/tools/extensions/pyspecific.py
+++ b/Doc/tools/extensions/pyspecific.py
@@ -679,6 +679,34 @@ def process_audit_events(app, doctree, fromdocname):
node.replace_self(table)
+def patch_pairindextypes(app) -> None:
+ if app.builder.name != 'gettext':
+ return
+
+ # allow translating deprecated index entries
+ try:
+ from sphinx.domains.python import pairindextypes
+ except ImportError:
+ pass
+ else:
+ # Sphinx checks if a 'pair' type entry on an index directive is one of
+ # the Sphinx-translated pairindextypes values. As we intend to move
+ # away from this, we need Sphinx to believe that these values don't
+ # exist, by deleting them when using the gettext builder.
+
+ # pairindextypes.pop('module', None)
+ # pairindextypes.pop('keyword', None)
+ # pairindextypes.pop('operator', None)
+ # pairindextypes.pop('object', None)
+ # pairindextypes.pop('exception', None)
+ # pairindextypes.pop('statement', None)
+ # pairindextypes.pop('builtin', None)
+
+ # there needs to be at least one statement in this block, will be
+ # removed when the first of the below is uncommented.
+ pass
+
+
def setup(app):
app.add_role('issue', issue_role)
app.add_role('gh', gh_issue_role)
@@ -701,6 +729,7 @@ def setup(app):
app.add_directive_to_domain('py', 'awaitablemethod', PyAwaitableMethod)
app.add_directive_to_domain('py', 'abstractmethod', PyAbstractMethod)
app.add_directive('miscnews', MiscNews)
+ app.connect('builder-inited', patch_pairindextypes)
app.connect('doctree-resolved', process_audit_events)
app.connect('env-merge-info', audit_events_merge)
app.connect('env-purge-doc', audit_events_purge)
More information about the Python-checkins
mailing list