Skip to content

Commit

Permalink
♻️ Remove target_id core need field (#1315)
Browse files Browse the repository at this point in the history
This is a duplicate of `id_parent` (since it is not modified when creating a part from a need)
  • Loading branch information
chrisjsewell authored Oct 4, 2024
1 parent 02b2494 commit 250c58f
Show file tree
Hide file tree
Showing 16 changed files with 3 additions and 190 deletions.
1 change: 0 additions & 1 deletion sphinx_needs/api/need.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,6 @@ def run():
"lineno": lineno,
"lineno_content": lineno_content,
"doctype": doctype,
"target_id": need_id,
"content": "\n".join(content) if isinstance(content, StringList) else content,
"type": need_type,
"type_name": type_name,
Expand Down
4 changes: 0 additions & 4 deletions sphinx_needs/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ class CoreFieldParameters(TypedDict):


NeedsCoreFields: Final[Mapping[str, CoreFieldParameters]] = {
"target_id": {"description": "ID of the data.", "schema": {"type": "string"}},
"id": {"description": "ID of the data.", "schema": {"type": "string"}},
"docname": {
"description": "Name of the document where the need is defined (None if external).",
Expand Down Expand Up @@ -293,9 +292,6 @@ class CoreFieldParameters(TypedDict):
class NeedsInfoType(TypedDict, total=False):
"""Data for a single need."""

# TODO remove duplication target_id/id
target_id: Required[str]
"""ID of the data."""
id: Required[str]
"""ID of the data."""

Expand Down
2 changes: 1 addition & 1 deletion sphinx_needs/diagrams_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ def calculate_link(
+ "/"
+ builder.get_target_uri(_docname)
+ "#"
+ need_info["target_id"]
+ need_info["id_parent"]
)
if need_info["is_part"]:
link = f"{link}.{need_info['id']}"
Expand Down
2 changes: 1 addition & 1 deletion sphinx_needs/directives/needlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def process_needlist(
ref.append(title)
para += ref
elif _docname := need_info["docname"]:
target_id = need_info["target_id"]
target_id = need_info["id_parent"]
ref = nodes.reference("", "")
ref["refdocname"] = _docname
ref["refuri"] = builder.get_relative_uri(fromdocname, _docname)
Expand Down
2 changes: 1 addition & 1 deletion sphinx_needs/roles/need_incoming.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def process_need_incoming(
builder,
fromdocname,
_docname,
target_need["target_id"],
target_need["id_parent"],
node_need_backref[0].deepcopy(),
node_need_backref["reftarget"],
)
Expand Down
3 changes: 0 additions & 3 deletions tests/__snapshots__/test_add_sections_sigs.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
'test',
'test2',
]),
'target_id': 'R_12345',
'title': 'Command line interface',
'type': 'req',
'type_name': 'Requirement',
Expand All @@ -42,7 +41,6 @@
'test',
'test2',
]),
'target_id': 'R_12346',
'title': 'Another Requirement',
'type': 'req',
'type_name': 'Requirement',
Expand All @@ -60,7 +58,6 @@
'1 TEST DOCUMENT',
]),
'signature': 'test_method',
'target_id': 'T_001',
'title': 'test method',
'type': 'test',
'type_name': 'Test Case',
Expand Down
7 changes: 0 additions & 7 deletions tests/__snapshots__/test_basic_doc.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@
'style': None,
'tags': list([
]),
'target_id': 'ST_001',
'template': None,
'title': 'Test story',
'type': 'story',
Expand Down Expand Up @@ -134,7 +133,6 @@
'style': None,
'tags': list([
]),
'target_id': 'US_38823',
'template': None,
'title': 'No ID',
'type': 'story',
Expand Down Expand Up @@ -515,11 +513,6 @@
}),
'type': 'array',
}),
'target_id': dict({
'description': 'ID of the data.',
'field_type': 'core',
'type': 'string',
}),
'template': dict({
'default': None,
'description': 'Template of the need.',
Expand Down
17 changes: 0 additions & 17 deletions tests/__snapshots__/test_external.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
'sections': list([
'Title',
]),
'target_id': 'EXT_REQ_01',
'title': 'REQ_01',
'type': 'req',
'type_name': 'Requirement',
Expand All @@ -30,7 +29,6 @@
'sections': list([
'Title',
]),
'target_id': 'IMP_REQ_01',
'title': 'REQ_01',
'type': 'req',
'type_name': 'Requirement',
Expand Down Expand Up @@ -407,11 +405,6 @@
}),
'type': 'array',
}),
'target_id': dict({
'description': 'ID of the data.',
'field_type': 'core',
'type': 'string',
}),
'template': dict({
'default': None,
'description': 'Template of the need.',
Expand Down Expand Up @@ -538,7 +531,6 @@
'style': None,
'tags': list([
]),
'target_id': 'EXT_TEST_01',
'template': None,
'title': 'TEST_01 DESCRIPTION',
'type': 'impl',
Expand Down Expand Up @@ -614,7 +606,6 @@
'test_02',
'test',
]),
'target_id': 'EXT_TEST_02',
'template': None,
'title': 'TEST_02 DESCRIPTION',
'type': 'req',
Expand Down Expand Up @@ -686,7 +677,6 @@
'style': None,
'tags': list([
]),
'target_id': 'REQ_1',
'template': None,
'title': 'Test requirement 1',
'type': 'req',
Expand Down Expand Up @@ -759,7 +749,6 @@
'style': None,
'tags': list([
]),
'target_id': 'SPEC_1',
'template': None,
'title': 'Test specification 1',
'type': 'spec',
Expand Down Expand Up @@ -829,7 +818,6 @@
'style': None,
'tags': list([
]),
'target_id': 'SUB_002',
'template': None,
'title': 'Sub-Req',
'type': 'req',
Expand Down Expand Up @@ -1210,11 +1198,6 @@
}),
'type': 'array',
}),
'target_id': dict({
'description': 'ID of the data.',
'field_type': 'core',
'type': 'string',
}),
'template': dict({
'default': None,
'description': 'Template of the need.',
Expand Down
13 changes: 0 additions & 13 deletions tests/__snapshots__/test_need_constraints.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@
'style': None,
'tags': list([
]),
'target_id': 'SECURITY_REQ',
'template': None,
'title': 'test1',
'type': 'spec',
Expand Down Expand Up @@ -142,7 +141,6 @@
'tags': list([
'critical',
]),
'target_id': 'SP_109F4',
'template': None,
'title': 'test2',
'type': 'spec',
Expand Down Expand Up @@ -218,7 +216,6 @@
'style': 'red_bar',
'tags': list([
]),
'target_id': 'SP_3EBFA',
'template': None,
'title': 'test3',
'type': 'spec',
Expand Down Expand Up @@ -292,7 +289,6 @@
'style': 'yellow_bar,',
'tags': list([
]),
'target_id': 'SP_CA3FB',
'template': None,
'title': 'FAIL_01',
'type': 'spec',
Expand Down Expand Up @@ -364,7 +360,6 @@
'test',
'test2',
]),
'target_id': 'SP_TOO_001',
'template': None,
'title': 'Command line interface',
'type': 'spec',
Expand Down Expand Up @@ -441,7 +436,6 @@
'hello',
'there',
]),
'target_id': 'SP_TOO_002',
'template': None,
'title': 'CLI',
'type': 'spec',
Expand Down Expand Up @@ -516,7 +510,6 @@
'style': 'red_bar',
'tags': list([
]),
'target_id': 'TEST_STYLE',
'template': None,
'title': 'CLI',
'type': 'spec',
Expand Down Expand Up @@ -590,7 +583,6 @@
'style': 'blue_border, yellow_bar',
'tags': list([
]),
'target_id': 'TEST_STYLE2',
'template': None,
'title': 'CLI2',
'type': 'spec',
Expand Down Expand Up @@ -971,11 +963,6 @@
}),
'type': 'array',
}),
'target_id': dict({
'description': 'ID of the data.',
'field_type': 'core',
'type': 'string',
}),
'template': dict({
'default': None,
'description': 'Template of the need.',
Expand Down
2 changes: 0 additions & 2 deletions tests/__snapshots__/test_need_parts.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@
'test',
'test2',
]),
'target_id': 'SP_TOO_001',
'title': 'Command line interface',
'type': 'spec',
'type_name': 'Specification',
Expand Down Expand Up @@ -119,7 +118,6 @@
'sections': list([
'NEED PARTS',
]),
'target_id': 'TEST_2',
'title': 'TEST_2',
'type': 'spec',
'type_name': 'Specification',
Expand Down
21 changes: 0 additions & 21 deletions tests/__snapshots__/test_needextend.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@
'style': None,
'tags': list([
]),
'target_id': 'REQ_1',
'template': None,
'title': 'Requirement 1',
'type': 'req',
Expand Down Expand Up @@ -138,7 +137,6 @@
'style': None,
'tags': list([
]),
'target_id': 'REQ_A_1',
'template': None,
'title': 'Requirement A 1',
'type': 'req',
Expand Down Expand Up @@ -209,7 +207,6 @@
'style': None,
'tags': list([
]),
'target_id': 'REQ_B_1',
'template': None,
'title': 'Requirement B 1',
'type': 'req',
Expand Down Expand Up @@ -279,7 +276,6 @@
'style': None,
'tags': list([
]),
'target_id': 'REQ_C_1',
'template': None,
'title': 'Requirement C 1',
'type': 'req',
Expand Down Expand Up @@ -350,7 +346,6 @@
'style': None,
'tags': list([
]),
'target_id': 'REQ_D_1',
'template': None,
'title': 'Requirement D 1',
'type': 'req',
Expand Down Expand Up @@ -731,11 +726,6 @@
}),
'type': 'array',
}),
'target_id': dict({
'description': 'ID of the data.',
'field_type': 'core',
'type': 'string',
}),
'template': dict({
'default': None,
'description': 'Template of the need.',
Expand Down Expand Up @@ -865,7 +855,6 @@
'style': None,
'tags': list([
]),
'target_id': 'extend_test_003',
'template': None,
'title': 'needextend Example 3',
'type': 'story',
Expand Down Expand Up @@ -941,7 +930,6 @@
'style': None,
'tags': list([
]),
'target_id': 'extend_test_004',
'template': None,
'title': 'needextend Example 4',
'type': 'story',
Expand Down Expand Up @@ -1015,7 +1003,6 @@
'style': None,
'tags': list([
]),
'target_id': 'extend_test_005',
'template': None,
'title': 'needextend Example 5',
'type': 'story',
Expand Down Expand Up @@ -1087,7 +1074,6 @@
'style': None,
'tags': list([
]),
'target_id': 'extend_test_006',
'template': None,
'title': 'needextend Example 6',
'type': 'story',
Expand Down Expand Up @@ -1160,7 +1146,6 @@
'style': None,
'tags': list([
]),
'target_id': 'extend_test_007',
'template': None,
'title': 'needextend Example 7',
'type': 'story',
Expand Down Expand Up @@ -1233,7 +1218,6 @@
'new_tag',
'another_tag',
]),
'target_id': 'extend_test_page',
'template': None,
'title': 'needextend different pages test',
'type': 'story',
Expand Down Expand Up @@ -1614,11 +1598,6 @@
}),
'type': 'array',
}),
'target_id': dict({
'description': 'ID of the data.',
'field_type': 'core',
'type': 'string',
}),
'template': dict({
'default': None,
'description': 'Template of the need.',
Expand Down
Loading

0 comments on commit 250c58f

Please sign in to comment.