Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5ee8344

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 directiveThis does not change the (untranslated) output,but ensures that the doctree node metadata is correct.whichfixesgh-97607 with the text not being translated.It also simplifies the code and logicand makes it consistant with the docutils built-in directives.* Remove unused branch from impl-detail directive handling no-content caseThis 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 commite8165d4)Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
1 parentc6fcbb4 commit5ee8344

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
classImplementationDetail(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
defrun(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-
ifself.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-
ifpnode.childrenandisinstance(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)

[8]ページ先頭

©2009-2025 Movatter.jp