From bc6571a67b9a95af23f2689d375c4517782891ae Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+AA-Turner@users.noreply.github.com> Date: Tue, 31 May 2022 17:06:51 +0100 Subject: [PATCH 1/4] Add a meta node to fix iteration --- sphinx/ext/ifconfig.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sphinx/ext/ifconfig.py b/sphinx/ext/ifconfig.py index bffaa49ff7c..202bee533eb 100644 --- a/sphinx/ext/ifconfig.py +++ b/sphinx/ext/ifconfig.py @@ -20,6 +20,7 @@ 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 @@ -64,7 +65,7 @@ def process_ifconfig_nodes(app: Sphinx, doctree: nodes.document, docname: str) - node.replace_self(newnode) else: if not res: - node.replace_self([]) + node.replace_self(addnodes.meta()) else: node.replace_self(node.children) From d066d23067480f7ce1f02ed9c802906289413b0d Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+AA-Turner@users.noreply.github.com> Date: Tue, 31 May 2022 17:12:17 +0100 Subject: [PATCH 2/4] Add a test --- tests/roots/test-ext-ifconfig/conf.py | 1 + tests/roots/test-ext-ifconfig/index.rst | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/tests/roots/test-ext-ifconfig/conf.py b/tests/roots/test-ext-ifconfig/conf.py index 565f6bcb30a..e82ec79f23f 100644 --- a/tests/roots/test-ext-ifconfig/conf.py +++ b/tests/roots/test-ext-ifconfig/conf.py @@ -7,3 +7,4 @@ def setup(app): app.add_config_value('confval1', False, None) app.add_config_value('confval2', False, None) + app.add_config_value('false_config', False, None) diff --git a/tests/roots/test-ext-ifconfig/index.rst b/tests/roots/test-ext-ifconfig/index.rst index ab08aabef96..594d885428d 100644 --- a/tests/roots/test-ext-ifconfig/index.rst +++ b/tests/roots/test-ext-ifconfig/index.rst @@ -9,3 +9,13 @@ ifconfig egg +Issue 10496 regression test +=========================== + +.. ifconfig:: false_config + + `Link 1 `__ + +.. ifconfig:: false_config + + `Link 2 `__ From 9fad9d98c2883e6781972060c28c17281274370c Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+AA-Turner@users.noreply.github.com> Date: Tue, 31 May 2022 17:15:19 +0100 Subject: [PATCH 3/4] Fix fake link in test --- tests/roots/test-ext-ifconfig/index.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/roots/test-ext-ifconfig/index.rst b/tests/roots/test-ext-ifconfig/index.rst index 594d885428d..f7fabcc78f8 100644 --- a/tests/roots/test-ext-ifconfig/index.rst +++ b/tests/roots/test-ext-ifconfig/index.rst @@ -18,4 +18,4 @@ Issue 10496 regression test .. ifconfig:: false_config - `Link 2 `__ + `Link 2 `__ From c4458e3adbcffced2248fb3d05a283e1754d3b7c Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Fri, 3 Jun 2022 02:01:01 +0900 Subject: [PATCH 4/4] ifconfig: Do not use a meta node for noop --- sphinx/ext/ifconfig.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/sphinx/ext/ifconfig.py b/sphinx/ext/ifconfig.py index 202bee533eb..f0d11507776 100644 --- a/sphinx/ext/ifconfig.py +++ b/sphinx/ext/ifconfig.py @@ -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 @@ -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: @@ -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)