From a0d7abd5c92003f5c4fef1a04496913310afb591 Mon Sep 17 00:00:00 2001 From: Chris Sewell Date: Thu, 12 Sep 2024 15:35:56 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20`parent=5Fneed`=20propagat?= =?UTF-8?q?ion=20from=20external/import=20(#1286)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sphinx_needs/api/need.py | 4 ++++ tests/__snapshots__/test_external.ambr | 4 +++- tests/doc_test/external_doc/needs_test_small.json | 6 +++--- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/sphinx_needs/api/need.py b/sphinx_needs/api/need.py index 17f7324dc..22756ee69 100644 --- a/sphinx_needs/api/need.py +++ b/sphinx_needs/api/need.py @@ -387,6 +387,10 @@ def run(): needs_info["links"] += copy_links # Set copied links to main-links + if parent_needs := needs_info.get("parent_needs"): + # ensure parent_need is consistent with parent_needs + needs_info["parent_need"] = parent_needs[0] + if jinja_content: need_content_context = {**needs_info} need_content_context.update(**needs_config.filter_data) diff --git a/tests/__snapshots__/test_external.ambr b/tests/__snapshots__/test_external.ambr index f2f98d490..e6edd1823 100644 --- a/tests/__snapshots__/test_external.ambr +++ b/tests/__snapshots__/test_external.ambr @@ -531,6 +531,7 @@ 'parent_needs': list([ ]), 'parent_needs_back': list([ + 'EXT_TEST_02', ]), 'parts': dict({ }), @@ -598,8 +599,9 @@ 'max_content_lines': '', 'modifications': 0, 'params': '', - 'parent_need': '', + 'parent_need': 'EXT_TEST_01', 'parent_needs': list([ + 'EXT_TEST_01', ]), 'parent_needs_back': list([ ]), diff --git a/tests/doc_test/external_doc/needs_test_small.json b/tests/doc_test/external_doc/needs_test_small.json index 5ac982674..d191ec7e7 100644 --- a/tests/doc_test/external_doc/needs_test_small.json +++ b/tests/doc_test/external_doc/needs_test_small.json @@ -32,7 +32,7 @@ "max_content_lines": "", "parent_need": null, "parent_needs": [], - "parent_needs_back": [], + "parent_needs_back": ["TEST_02"], "parts": {}, "post_template": null, "pre_template": null, @@ -78,8 +78,8 @@ ], "max_amount": "", "max_content_lines": "", - "parent_need": null, - "parent_needs": [], + "parent_need": "TEST_01", + "parent_needs": ["TEST_01"], "parent_needs_back": [], "parts": {}, "post_template": null,