mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Refactor has_child() function (by review)
This commit is contained in:
parent
a557e0dd32
commit
c35886f6d0
@ -1706,11 +1706,7 @@ class BuildEnvironment:
|
|||||||
fignum_counter = {}
|
fignum_counter = {}
|
||||||
|
|
||||||
def has_child(node, cls):
|
def has_child(node, cls):
|
||||||
for child in node:
|
return any(isinstance(child, cls) for child in node)
|
||||||
if isinstance(child, cls):
|
|
||||||
return True
|
|
||||||
|
|
||||||
return False
|
|
||||||
|
|
||||||
def get_section_number(docname, section):
|
def get_section_number(docname, section):
|
||||||
anchorname = '#' + section['ids'][0]
|
anchorname = '#' + section['ids'][0]
|
||||||
|
@ -109,11 +109,7 @@ class AutoNumbering(Transform):
|
|||||||
|
|
||||||
def apply(self):
|
def apply(self):
|
||||||
def has_child(node, cls):
|
def has_child(node, cls):
|
||||||
for child in node:
|
return any(isinstance(child, cls) for child in node)
|
||||||
if isinstance(child, cls):
|
|
||||||
return True
|
|
||||||
|
|
||||||
return False
|
|
||||||
|
|
||||||
for node in self.document.traverse(nodes.Element):
|
for node in self.document.traverse(nodes.Element):
|
||||||
if isinstance(node, nodes.figure):
|
if isinstance(node, nodes.figure):
|
||||||
|
Loading…
Reference in New Issue
Block a user