From 00e5bccceff33538c852c69c0e7af9eec4e5f705 Mon Sep 17 00:00:00 2001 From: "C.A.M. Gerlach" Date: Thu, 29 Sep 2022 14:13:25 -0500 Subject: [PATCH 1/3] Don't parse content as arg in the impl-detail directive This does not change the (untranslated) output, but ensures that the doctree node metadata is correct. which fixes gh-97607 with the text not being translated. It also simplifies the code and logic and makes it consistant with the docutils built-in directives. --- Doc/tools/extensions/pyspecific.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/Doc/tools/extensions/pyspecific.py b/Doc/tools/extensions/pyspecific.py index da15abdf637260..54f6d5ec824e57 100644 --- a/Doc/tools/extensions/pyspecific.py +++ b/Doc/tools/extensions/pyspecific.py @@ -100,8 +100,6 @@ def source_role(typ, rawtext, text, lineno, inliner, options={}, content=[]): class ImplementationDetail(Directive): has_content = True - required_arguments = 0 - optional_arguments = 1 final_argument_whitespace = True # This text is copied to templates/dummy.html @@ -112,9 +110,6 @@ def run(self): label = translators['sphinx'].gettext(self.label_text) content = self.content add_text = nodes.strong(label, label) - if self.arguments: - n, m = self.state.inline_text(self.arguments[0], self.lineno) - pnode.append(nodes.paragraph('', '', *(n + m))) self.state.nested_parse(content, self.content_offset, pnode) if pnode.children and isinstance(pnode[0], nodes.paragraph): content = nodes.inline(pnode[0].rawsource, translatable=True) From 9dcab9cc125ce965d8b9645f328648b676726912 Mon Sep 17 00:00:00 2001 From: "C.A.M. Gerlach" Date: Thu, 29 Sep 2022 14:55:52 -0500 Subject: [PATCH 2/3] Remove unused branch from impl-detail directive handling no-content case This is not used anywhere in the docs and lacks a clear use case, and is more likely a mistake which is now flagged at build time. This simplifies the logic from two code paths to one, and makes the behavior consistant with similar built-in directives (e.g. the various admonition types). --- Doc/tools/extensions/pyspecific.py | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/Doc/tools/extensions/pyspecific.py b/Doc/tools/extensions/pyspecific.py index 54f6d5ec824e57..449ad7ea17889e 100644 --- a/Doc/tools/extensions/pyspecific.py +++ b/Doc/tools/extensions/pyspecific.py @@ -106,22 +106,20 @@ class ImplementationDetail(Directive): label_text = 'CPython implementation detail:' def run(self): + self.assert_has_content() pnode = nodes.compound(classes=['impl-detail']) label = translators['sphinx'].gettext(self.label_text) content = self.content add_text = nodes.strong(label, label) self.state.nested_parse(content, self.content_offset, pnode) - if pnode.children and isinstance(pnode[0], nodes.paragraph): - content = nodes.inline(pnode[0].rawsource, translatable=True) - content.source = pnode[0].source - content.line = pnode[0].line - content += pnode[0].children - pnode[0].replace_self(nodes.paragraph('', '', content, - translatable=False)) - pnode[0].insert(0, add_text) - pnode[0].insert(1, nodes.Text(' ')) - else: - pnode.insert(0, nodes.paragraph('', '', add_text)) + content = nodes.inline(pnode[0].rawsource, translatable=True) + content.source = pnode[0].source + content.line = pnode[0].line + content += pnode[0].children + pnode[0].replace_self( + nodes.paragraph('', '', content, translatable=False)) + pnode[0].insert(0, add_text) + pnode[0].insert(1, nodes.Text(' ')) return [pnode] From b8789b83ff78300e65156eb42eb6c551963a2145 Mon Sep 17 00:00:00 2001 From: "C.A.M. Gerlach" Date: Thu, 29 Sep 2022 21:20:25 -0500 Subject: [PATCH 3/3] Further simplify impl-detail reST directive code --- Doc/tools/extensions/pyspecific.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Doc/tools/extensions/pyspecific.py b/Doc/tools/extensions/pyspecific.py index 449ad7ea17889e..8c3aa47ad1c74b 100644 --- a/Doc/tools/extensions/pyspecific.py +++ b/Doc/tools/extensions/pyspecific.py @@ -116,10 +116,8 @@ def run(self): content.source = pnode[0].source content.line = pnode[0].line content += pnode[0].children - pnode[0].replace_self( - nodes.paragraph('', '', content, translatable=False)) - pnode[0].insert(0, add_text) - pnode[0].insert(1, nodes.Text(' ')) + pnode[0].replace_self(nodes.paragraph( + '', '', add_text, nodes.Text(' '), content, translatable=False)) return [pnode] pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

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:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy