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,