Skip to content

Commit

Permalink
ifconfig: Do not use a meta node for noop
Browse files Browse the repository at this point in the history
  • Loading branch information
tk0miya committed Jun 2, 2022
1 parent 9fad9d9 commit c4458e3
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions sphinx/ext/ifconfig.py
Expand Up @@ -20,7 +20,6 @@
from docutils.nodes import Node

import sphinx
from sphinx import addnodes
from sphinx.application import Sphinx
from sphinx.util.docutils import SphinxDirective
from sphinx.util.nodes import nested_parse_with_titles
Expand Down Expand Up @@ -52,7 +51,7 @@ def process_ifconfig_nodes(app: Sphinx, doctree: nodes.document, docname: str) -
ns = {confval.name: confval.value for confval in app.config}
ns.update(app.config.__dict__.copy())
ns['builder'] = app.builder.name
for node in doctree.findall(ifconfig):
for node in list(doctree.findall(ifconfig)):
try:
res = eval(node['expr'], ns)
except Exception as err:
Expand All @@ -65,7 +64,7 @@ def process_ifconfig_nodes(app: Sphinx, doctree: nodes.document, docname: str) -
node.replace_self(newnode)
else:
if not res:
node.replace_self(addnodes.meta())
node.replace_self([])
else:
node.replace_self(node.children)

Expand Down

0 comments on commit c4458e3

Please sign in to comment.