Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/sphinx-doc/sphinx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2021-10-26 19:49:57 +0300
committerTakeshi KOMIYA <i.tkomiya@gmail.com>2021-10-26 19:49:59 +0300
commit13803a79e7179f40a27f46d5a5a05f1eebbcbb63 (patch)
tree2cb19dd2900c96c57f601d46bdfbfc0652127b13 /sphinx/writers
parent2be9d6b092965a2f9354da66b645bf5ea76ce288 (diff)
Support docutils-0.18: Consume iterator of Element.traverse()
Since 0.18, Element.traverse() returns an iterator instead of intermediate object. As a result, the return value is always considered as truthy value. And it becomes fragile when the caller modifies the doctree on the loop.
Diffstat (limited to 'sphinx/writers')
-rw-r--r--sphinx/writers/latex.py2
-rw-r--r--sphinx/writers/manpage.py4
2 files changed, 3 insertions, 3 deletions
diff --git a/sphinx/writers/latex.py b/sphinx/writers/latex.py
index 869759ee5..3f032e616 100644
--- a/sphinx/writers/latex.py
+++ b/sphinx/writers/latex.py
@@ -651,7 +651,7 @@ class LaTeXTranslator(SphinxTranslator):
raise nodes.SkipNode
else:
short = ''
- if node.traverse(nodes.image):
+ if list(node.traverse(nodes.image)):
short = ('[%s]' % self.escape(' '.join(clean_astext(node).split())))
try:
diff --git a/sphinx/writers/manpage.py b/sphinx/writers/manpage.py
index 12fc31281..da5f4c241 100644
--- a/sphinx/writers/manpage.py
+++ b/sphinx/writers/manpage.py
@@ -56,7 +56,7 @@ class NestedInlineTransform:
def apply(self, **kwargs: Any) -> None:
matcher = NodeMatcher(nodes.literal, nodes.emphasis, nodes.strong)
- for node in self.document.traverse(matcher): # type: TextElement
+ for node in list(self.document.traverse(matcher)): # type: TextElement
if any(matcher(subnode) for subnode in node):
pos = node.parent.index(node)
for subnode in reversed(list(node)):
@@ -227,7 +227,7 @@ class ManualPageTranslator(SphinxTranslator, BaseTranslator):
# overwritten -- don't make whole of term bold if it includes strong node
def visit_term(self, node: Element) -> None:
- if node.traverse(nodes.strong):
+ if list(node.traverse(nodes.strong)):
self.body.append('\n')
else:
super().visit_term(node)