diff options
author | Adam Turner <9087854+AA-Turner@users.noreply.github.com> | 2023-05-04 07:11:09 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-04 07:11:09 (GMT) |
commit | 35d273825abc319d0ecbd69110e847f6040d0cd7 (patch) | |
tree | 3faf83af2ece32cf5fabf5dc85c08628959221b7 /Doc/tools/extensions | |
parent | 9885677b0494e9be3eb8d7d69bebca0e79d8abcc (diff) | |
download | cpython-35d273825abc319d0ecbd69110e847f6040d0cd7.zip cpython-35d273825abc319d0ecbd69110e847f6040d0cd7.tar.gz cpython-35d273825abc319d0ecbd69110e847f6040d0cd7.tar.bz2 |
GH-97950: Allow translation of index directive content (#104000)
Diffstat (limited to 'Doc/tools/extensions')
-rw-r--r-- | Doc/tools/extensions/pyspecific.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/Doc/tools/extensions/pyspecific.py b/Doc/tools/extensions/pyspecific.py index d659a4a..39c7c42 100644 --- a/Doc/tools/extensions/pyspecific.py +++ b/Doc/tools/extensions/pyspecific.py @@ -674,6 +674,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) @@ -695,6 +723,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) |