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

Commit6ef6915

Browse files
authored
gh-101845: pyspecific: Fix i18n for availability directive (GH-101846)
pyspecific: Fix i18n for availability directiveIf the directive has content, the previous code would nest paragraphnodes from that content inside a general paragraph node, which confusesSphinx and leads it to drop the content when translating. Instead, use acontainer node for the body.Also use set_source_info so that any warnings have location info.
1 parentdfc2e06 commit6ef6915

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

‎Doc/tools/extensions/pyspecific.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
fromsphinx.environmentimportNoUri
2929
fromsphinx.localeimport_assphinx_gettext
3030
fromsphinx.utilimportstatus_iterator,logging
31+
fromsphinx.util.docutilsimportSphinxDirective
3132
fromsphinx.util.nodesimportsplit_explicit_title
3233
fromsphinx.writers.textimportTextWriter,TextTranslator
3334

@@ -119,7 +120,7 @@ def run(self):
119120

120121
# Support for documenting platform availability
121122

122-
classAvailability(Directive):
123+
classAvailability(SphinxDirective):
123124

124125
has_content=True
125126
required_arguments=1
@@ -139,18 +140,19 @@ class Availability(Directive):
139140

140141
defrun(self):
141142
availability_ref=':ref:`Availability <availability>`: '
143+
avail_nodes,avail_msgs=self.state.inline_text(
144+
availability_ref+self.arguments[0],
145+
self.lineno)
142146
pnode=nodes.paragraph(availability_ref+self.arguments[0],
143-
classes=["availability"],)
144-
n,m=self.state.inline_text(availability_ref,self.lineno)
145-
pnode.extend(n+m)
146-
n,m=self.state.inline_text(self.arguments[0],self.lineno)
147-
pnode.extend(n+m)
147+
'',*avail_nodes,*avail_msgs)
148+
self.set_source_info(pnode)
149+
cnode=nodes.container("",pnode,classes=["availability"])
150+
self.set_source_info(cnode)
148151
ifself.content:
149-
self.state.nested_parse(self.content,self.content_offset,pnode)
150-
152+
self.state.nested_parse(self.content,self.content_offset,cnode)
151153
self.parse_platforms()
152154

153-
return [pnode]
155+
return [cnode]
154156

155157
defparse_platforms(self):
156158
"""Parse platform information from arguments

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp