Skip to content

Commit 5ee8344

Browse files
gh-97607: Fix content parsing in the impl-detail reST directive (GH-97652)
* 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. * 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). * Further simplify impl-detail reST directive code (cherry picked from commit e8165d4) Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
1 parent c6fcbb4 commit 5ee8344

File tree

1 file changed

+7
-16
lines changed

1 file changed

+7
-16
lines changed

Doc/tools/extensions/pyspecific.py

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -101,33 +101,24 @@ def source_role(typ, rawtext, text, lineno, inliner, options={}, content=[]):
101101
class ImplementationDetail(Directive):
102102

103103
has_content = True
104-
required_arguments = 0
105-
optional_arguments = 1
106104
final_argument_whitespace = True
107105

108106
# This text is copied to templates/dummy.html
109107
label_text = 'CPython implementation detail:'
110108

111109
def run(self):
110+
self.assert_has_content()
112111
pnode = nodes.compound(classes=['impl-detail'])
113112
label = translators['sphinx'].gettext(self.label_text)
114113
content = self.content
115114
add_text = nodes.strong(label, label)
116-
if self.arguments:
117-
n, m = self.state.inline_text(self.arguments[0], self.lineno)
118-
pnode.append(nodes.paragraph('', '', *(n + m)))
119115
self.state.nested_parse(content, self.content_offset, pnode)
120-
if pnode.children and isinstance(pnode[0], nodes.paragraph):
121-
content = nodes.inline(pnode[0].rawsource, translatable=True)
122-
content.source = pnode[0].source
123-
content.line = pnode[0].line
124-
content += pnode[0].children
125-
pnode[0].replace_self(nodes.paragraph('', '', content,
126-
translatable=False))
127-
pnode[0].insert(0, add_text)
128-
pnode[0].insert(1, nodes.Text(' '))
129-
else:
130-
pnode.insert(0, nodes.paragraph('', '', add_text))
116+
content = nodes.inline(pnode[0].rawsource, translatable=True)
117+
content.source = pnode[0].source
118+
content.line = pnode[0].line
119+
content += pnode[0].children
120+
pnode[0].replace_self(nodes.paragraph(
121+
'', '', add_text, nodes.Text(' '), content, translatable=False))
131122
return [pnode]
132123

133124

0 commit comments

Comments
 (0)
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