From db66f57dabf51ed943d2396feb3afc56675c8b07 Mon Sep 17 00:00:00 2001 From: Chris Sewell Date: Fri, 13 Sep 2024 11:31:10 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20removal=20of=20`Needextend?= =?UTF-8?q?`=20nodes=20(#1298)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We need to exhaust the entire `findall` iterator, before performing mutations on the doctree, otherwise this can lead to unexpected results --- sphinx_needs/directives/need.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sphinx_needs/directives/need.py b/sphinx_needs/directives/need.py index 1126e6288..a92be651e 100644 --- a/sphinx_needs/directives/need.py +++ b/sphinx_needs/directives/need.py @@ -406,7 +406,7 @@ def process_need_nodes(app: Sphinx, doctree: nodes.document, fromdocname: str) - post_process_needs_data(app) - for extend_node in doctree.findall(Needextend): + for extend_node in list(doctree.findall(Needextend)): remove_node_from_tree(extend_node) format_need_nodes(app, doctree, fromdocname, list(doctree.findall(Need)))