Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🔧 Move dead link need fields to internals #1119

Merged
merged 1 commit into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions sphinx_needs/api/need.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,8 @@ def run():
"external_css": external_css or "external_link",
"is_modified": False, # needed by needextend
"modifications": 0, # needed by needextend
"has_dead_links": False,
"has_forbidden_dead_links": False,
# these are set later in the analyse_need_locations transform
"sections": [],
"section_name": "",
Expand Down
11 changes: 8 additions & 3 deletions sphinx_needs/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,14 @@ class NeedsInfoType(TypedDict):
# these all have value type `list[str]`
# back links are all set in process_need_nodes (-> create_back_links) transform

# these default to False and are updated in check_links post-process
has_dead_links: bool
"""True if any links reference need ids that are not found in the need list."""
has_forbidden_dead_links: bool
"""True if any links reference need ids that are not found in the need list,
and the link type does not allow dead links.
"""

# constraints information
constraints: list[str]
"""List of constraint names, which are defined for this need."""
Expand Down Expand Up @@ -173,9 +181,6 @@ class NeedsInfoType(TypedDict):
duration: str
completion: str
# constraints: str # this is already set in create_need
# these are updated in process_need_nodes (-> check_links) transform
has_dead_links: str | bool
has_forbidden_dead_links: str | bool
# options from `BaseService.options` get added to every need,
# via `ServiceManager.register`, which adds them to `extra_options``
# GithubService
Expand Down
2 changes: 1 addition & 1 deletion sphinx_needs/layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,7 @@ def meta_all(
:param show_empty: If true, also need data with no value will be printed. Mostly useful for debugging.
:return: docutils nodes
"""
default_excludes = INTERNALS.copy()
default_excludes = list(INTERNALS)

if exclude is None or not isinstance(exclude, list):
if defaults:
Expand Down
2 changes: 0 additions & 2 deletions sphinx_needs/needs.py
Original file line number Diff line number Diff line change
Expand Up @@ -517,8 +517,6 @@ def prepare_env(app: Sphinx, env: BuildEnvironment, _docname: str) -> None:
"hidden",
"duration",
"completion",
"has_dead_links",
"has_forbidden_dead_links",
"constraints",
]:
# Check if not already set by user
Expand Down
6 changes: 4 additions & 2 deletions sphinx_needs/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class NeedFunctionsType(TypedDict):
NEEDS_FUNCTIONS: dict[str, NeedFunctionsType] = {}

# List of internal need option names. They should not be used by or presented to user.
INTERNALS = [
INTERNALS = (
"docname",
"doctype",
"lineno",
Expand Down Expand Up @@ -82,7 +82,9 @@ class NeedFunctionsType(TypedDict):
"constraints_results",
"arch",
"target_id",
]
"has_dead_links",
"has_forbidden_dead_links",
)

MONTH_NAMES = [
"January",
Expand Down
9 changes: 4 additions & 5 deletions tests/__snapshots__/test_basic_doc.ambr
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# serializer version: 1
# name: test_build_needs[test_app0]
dict({
'current_version': '',
Expand Down Expand Up @@ -30,8 +29,8 @@
'external_css': 'external_link',
'external_url': None,
'full_title': 'Test story',
'has_dead_links': '',
'has_forbidden_dead_links': '',
'has_dead_links': False,
'has_forbidden_dead_links': False,
'hidden': '',
'id': 'ST_001',
'id_prefix': '',
Expand Down Expand Up @@ -98,8 +97,8 @@
'external_css': 'external_link',
'external_url': None,
'full_title': 'No ID',
'has_dead_links': '',
'has_forbidden_dead_links': '',
'has_dead_links': False,
'has_forbidden_dead_links': False,
'hidden': '',
'id': 'US_38823',
'id_prefix': '',
Expand Down
33 changes: 16 additions & 17 deletions tests/__snapshots__/test_export_id.ambr
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# serializer version: 1
# name: test_export_id[test_app0]
dict({
'current_version': '1.0',
Expand Down Expand Up @@ -136,8 +135,8 @@
'external_css': 'external_link',
'external_url': None,
'full_title': 'My requirement',
'has_dead_links': '',
'has_forbidden_dead_links': '',
'has_dead_links': False,
'has_forbidden_dead_links': False,
'hidden': '',
'id': 'REQ_001',
'id_prefix': '',
Expand Down Expand Up @@ -212,8 +211,8 @@
'external_css': 'external_link',
'external_url': None,
'full_title': 'My requirement 2',
'has_dead_links': '',
'has_forbidden_dead_links': '',
'has_dead_links': False,
'has_forbidden_dead_links': False,
'hidden': '',
'id': 'REQ_002',
'id_prefix': '',
Expand Down Expand Up @@ -285,8 +284,8 @@
'external_css': 'external_link',
'external_url': None,
'full_title': 'My requirement 3',
'has_dead_links': '',
'has_forbidden_dead_links': '',
'has_dead_links': False,
'has_forbidden_dead_links': False,
'hidden': '',
'id': 'REQ_003',
'id_prefix': '',
Expand Down Expand Up @@ -358,8 +357,8 @@
'external_css': 'external_link',
'external_url': None,
'full_title': 'My requirement 4',
'has_dead_links': '',
'has_forbidden_dead_links': '',
'has_dead_links': False,
'has_forbidden_dead_links': False,
'hidden': '',
'id': 'REQ_004',
'id_prefix': '',
Expand Down Expand Up @@ -436,8 +435,8 @@
'external_css': 'external_link',
'external_url': None,
'full_title': 'Req 5',
'has_dead_links': '',
'has_forbidden_dead_links': '',
'has_dead_links': False,
'has_forbidden_dead_links': False,
'hidden': '',
'id': 'REQ_005',
'id_prefix': '',
Expand Down Expand Up @@ -540,8 +539,8 @@
'external_css': 'external_link',
'external_url': None,
'full_title': 'Test of requirements',
'has_dead_links': '',
'has_forbidden_dead_links': '',
'has_dead_links': False,
'has_forbidden_dead_links': False,
'hidden': '',
'id': 'TEST_001',
'id_prefix': '',
Expand Down Expand Up @@ -615,8 +614,8 @@
'external_css': 'external_link',
'external_url': None,
'full_title': 'Test of requirements2',
'has_dead_links': '',
'has_forbidden_dead_links': '',
'has_dead_links': False,
'has_forbidden_dead_links': False,
'hidden': '',
'id': 'TEST_002',
'id_prefix': '',
Expand Down Expand Up @@ -690,8 +689,8 @@
'external_css': 'external_link',
'external_url': None,
'full_title': 'Test of requirements 5',
'has_dead_links': '',
'has_forbidden_dead_links': '',
'has_dead_links': False,
'has_forbidden_dead_links': False,
'hidden': '',
'id': 'TEST_003',
'id_prefix': '',
Expand Down
21 changes: 10 additions & 11 deletions tests/__snapshots__/test_external.ambr
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# serializer version: 1
# name: test_external_json[test_app0]
dict({
'current_version': '1.0',
Expand Down Expand Up @@ -30,8 +29,8 @@
'external_css': 'external_link',
'external_url': 'http://my_company.com/docs/v1/index.html#TEST_01',
'full_title': 'TEST_01 DESCRIPTION',
'has_dead_links': '',
'has_forbidden_dead_links': '',
'has_dead_links': False,
'has_forbidden_dead_links': False,
'hidden': '',
'id': 'EXT_TEST_01',
'id_prefix': '',
Expand Down Expand Up @@ -98,8 +97,8 @@
'external_css': 'external_link',
'external_url': 'http://my_company.com/docs/v1/index.html#TEST_02',
'full_title': 'TEST_02 DESCRIPTION',
'has_dead_links': '',
'has_forbidden_dead_links': '',
'has_dead_links': False,
'has_forbidden_dead_links': False,
'hidden': '',
'id': 'EXT_TEST_02',
'id_prefix': '',
Expand Down Expand Up @@ -169,8 +168,8 @@
'external_css': 'external_link',
'external_url': None,
'full_title': 'Test requirement 1',
'has_dead_links': '',
'has_forbidden_dead_links': '',
'has_dead_links': False,
'has_forbidden_dead_links': False,
'hidden': '',
'id': 'REQ_1',
'id_prefix': '',
Expand Down Expand Up @@ -237,8 +236,8 @@
'external_css': 'external_link',
'external_url': None,
'full_title': 'Test specification 1',
'has_dead_links': '',
'has_forbidden_dead_links': '',
'has_dead_links': False,
'has_forbidden_dead_links': False,
'hidden': '',
'id': 'SPEC_1',
'id_prefix': '',
Expand Down Expand Up @@ -307,8 +306,8 @@
'external_css': 'external_link',
'external_url': None,
'full_title': 'Sub-Req',
'has_dead_links': '',
'has_forbidden_dead_links': '',
'has_dead_links': False,
'has_forbidden_dead_links': False,
'hidden': '',
'id': 'SUB_002',
'id_prefix': '',
Expand Down
Loading
Loading