Merge pull request #9953 from tk0miya/9947_source_info_less_topic_node

Fix #9947: i18n: topic directive having a bullet list can't be translatable
This commit is contained in:
Takeshi KOMIYA 2021-12-11 11:00:21 +09:00 committed by GitHub
commit 68703e87f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 1 deletions

View File

@ -39,6 +39,7 @@ Bugs fixed
* #9883: autodoc: doccomment for the alias to mocked object was ignored
* #9908: autodoc: debug message is shown on building document using NewTypes
with Python 3.10
* #9947: i18n: topic directive having a bullet list can't be translatable
* #9878: mathjax: MathJax configuration is placed after loading MathJax itself
* #9857: Generated RFC links use outdated base url
* #9909: HTML, prevent line-wrapping in literal text.

View File

@ -208,7 +208,7 @@ class ApplySourceWorkaround(SphinxTransform):
def apply(self, **kwargs: Any) -> None:
for node in self.document.traverse(): # type: Node
if isinstance(node, (nodes.TextElement, nodes.image)):
if isinstance(node, (nodes.TextElement, nodes.image, nodes.topic)):
apply_source_workaround(node)

View File

@ -150,6 +150,11 @@ def apply_source_workaround(node: Element) -> None:
for classifier in reversed(list(node.parent.traverse(nodes.classifier))):
node.rawsource = re.sub(r'\s*:\s*%s' % re.escape(classifier.astext()),
'', node.rawsource)
if isinstance(node, nodes.topic) and node.source is None:
# docutils-0.18 does not fill the source attribute of topic
logger.debug('[i18n] PATCH: %r to have source, line: %s',
get_full_module_name(node), repr_domxml(node))
node.source, node.line = node.parent.source, node.parent.line
# workaround: literal_block under bullet list (#4913)
if isinstance(node, nodes.literal_block) and node.source is None: