From f4873ee197145f97640836a2690206a5b3cebde5 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Sat, 29 Apr 2023 23:47:17 +0100 Subject: [PATCH 1/6] Allow translating index directives --- Doc/conf.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Doc/conf.py b/Doc/conf.py index 42c23bf77c7034..2b733b4b699518 100644 --- a/Doc/conf.py +++ b/Doc/conf.py @@ -91,6 +91,11 @@ # Avoid a warning with Sphinx >= 2.0 master_doc = 'contents' +# Allow translation of index directives +gettext_additional_targets = [ + 'index', +] + # Options for HTML output # ----------------------- From 474108c2abfb736b74331a54b7d9651c9d938f8f Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Sun, 30 Apr 2023 00:13:33 +0100 Subject: [PATCH 2/6] Clear pairindextypes entries --- Doc/tools/extensions/pyspecific.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/Doc/tools/extensions/pyspecific.py b/Doc/tools/extensions/pyspecific.py index d659a4a54b9d11..d1f3a32a0e26cc 100644 --- a/Doc/tools/extensions/pyspecific.py +++ b/Doc/tools/extensions/pyspecific.py @@ -674,6 +674,27 @@ 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: + 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) + + del pairindextypes + + def setup(app): app.add_role('issue', issue_role) app.add_role('gh', gh_issue_role) @@ -695,6 +716,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) From 8d79707b57cdd9aa981bd805fee0537510fcbc65 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Sun, 30 Apr 2023 00:25:06 +0100 Subject: [PATCH 3/6] comment out removals --- Doc/tools/extensions/pyspecific.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Doc/tools/extensions/pyspecific.py b/Doc/tools/extensions/pyspecific.py index d1f3a32a0e26cc..8082c150981939 100644 --- a/Doc/tools/extensions/pyspecific.py +++ b/Doc/tools/extensions/pyspecific.py @@ -684,13 +684,13 @@ def patch_pairindextypes(app) -> None: except ImportError: pass else: - 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) + # 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) del pairindextypes From b90c593762945005d8f10a0ed2fcad8604296073 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+AA-Turner@users.noreply.github.com> Date: Mon, 1 May 2023 07:35:42 +0100 Subject: [PATCH 4/6] Delete deletion --- Doc/tools/extensions/pyspecific.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/Doc/tools/extensions/pyspecific.py b/Doc/tools/extensions/pyspecific.py index 8082c150981939..abfa90f256db3e 100644 --- a/Doc/tools/extensions/pyspecific.py +++ b/Doc/tools/extensions/pyspecific.py @@ -692,8 +692,6 @@ def patch_pairindextypes(app) -> None: # pairindextypes.pop('statement', None) # pairindextypes.pop('builtin', None) - del pairindextypes - def setup(app): app.add_role('issue', issue_role) From 3a7ac941689a42d89148930e0d0b1e903a6dc316 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Tue, 2 May 2023 17:04:20 +0100 Subject: [PATCH 5/6] syntax --- Doc/tools/extensions/pyspecific.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Doc/tools/extensions/pyspecific.py b/Doc/tools/extensions/pyspecific.py index abfa90f256db3e..14354c24ec40b4 100644 --- a/Doc/tools/extensions/pyspecific.py +++ b/Doc/tools/extensions/pyspecific.py @@ -692,6 +692,10 @@ def patch_pairindextypes(app) -> 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) From d575f695f8c6420905c4603b697cbb0517db4f5e Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Wed, 3 May 2023 13:22:16 +0100 Subject: [PATCH 6/6] Add explanatory note --- Doc/tools/extensions/pyspecific.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Doc/tools/extensions/pyspecific.py b/Doc/tools/extensions/pyspecific.py index 14354c24ec40b4..39c7c42e66f9a0 100644 --- a/Doc/tools/extensions/pyspecific.py +++ b/Doc/tools/extensions/pyspecific.py @@ -684,6 +684,11 @@ def patch_pairindextypes(app) -> None: 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)
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: