Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
pyspecific: Fix i18n for availability directive
If the directive has content, the previous code would nest paragraph
nodes from that content inside a general paragraph node, which confuses
Sphinx and leads it to drop the content when translating. Instead, use a
container node for the body.

Also use set_source_info so that any warnings have location info.
  • Loading branch information
jeanas committed Feb 12, 2023
commit 6afb193ee0b47e27ae1f3567261f8df74269bd49
20 changes: 11 additions & 9 deletions Doc/tools/extensions/pyspecific.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
from sphinx.environment import NoUri
from sphinx.locale import _ as sphinx_gettext
from sphinx.util import status_iterator, logging
from sphinx.util.docutils import SphinxDirective
from sphinx.util.nodes import split_explicit_title
from sphinx.writers.text import TextWriter, TextTranslator

Expand Down Expand Up @@ -119,7 +120,7 @@ def run(self):

# Support for documenting platform availability

class Availability(Directive):
class Availability(SphinxDirective):

has_content = True
required_arguments = 1
Expand All @@ -139,18 +140,19 @@ class Availability(Directive):

def run(self):
availability_ref = ':ref:`Availability <availability>`: '
avail_nodes, avail_msgs = self.state.inline_text(
availability_ref + self.arguments[0],
self.lineno)
pnode = nodes.paragraph(availability_ref + self.arguments[0],
classes=["availability"],)
n, m = self.state.inline_text(availability_ref, self.lineno)
pnode.extend(n + m)
n, m = self.state.inline_text(self.arguments[0], self.lineno)
pnode.extend(n + m)
'', *avail_nodes, *avail_msgs)
self.set_source_info(pnode)
cnode = nodes.container("", pnode, classes=["availability"])
self.set_source_info(cnode)
if self.content:
self.state.nested_parse(self.content, self.content_offset, pnode)

self.state.nested_parse(self.content, self.content_offset, cnode)
self.parse_platforms()

return [pnode]
return [cnode]

def parse_platforms(self):
"""Parse platform information from arguments
Expand Down