Skip to content

Commit

Permalink
🐛 Fix parent_need propagation from external/import (#1286)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisjsewell authored Sep 12, 2024
1 parent b3d65c8 commit a0d7abd
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
4 changes: 4 additions & 0 deletions sphinx_needs/api/need.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 3 additions & 1 deletion tests/__snapshots__/test_external.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,7 @@
'parent_needs': list([
]),
'parent_needs_back': list([
'EXT_TEST_02',
]),
'parts': dict({
}),
Expand Down Expand Up @@ -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([
]),
Expand Down
6 changes: 3 additions & 3 deletions tests/doc_test/external_doc/needs_test_small.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit a0d7abd

Please sign in to comment.