Coverage for sphinx_ifelse/utils.py: 100%
14 statements
« prev ^ index » next coverage.py v7.7.1, created at 2025-03-26 16:18 +0000
« prev ^ index » next coverage.py v7.7.1, created at 2025-03-26 16:18 +0000
2from typing import Tuple, List
3from sphinx.util.docutils import SphinxDirective
5from sphinx.util.tags import Tags
7def directive2location(self: SphinxDirective) -> Tuple[str, int]:
8 return (self.state.document.settings.env.docname, self.lineno)
10def remove_all_childs_of_types(node, nodetypes : List[str]):
11 # We have to run the list of children reversed,
12 # as we change the parent during processing.
13 for child in reversed(node.children):
14 if len(child.children) > 0:
15 remove_all_childs_of_types(child, nodetypes)
16 for nodetype in nodetypes:
17 if isinstance(child, nodetype):
18 node.remove(child)
19 break
20 return