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

🔧 Remove delete from needs.json #1347

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
10 changes: 9 additions & 1 deletion sphinx_needs/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ class CoreFieldParameters(TypedDict):
"""JSON schema for the field."""
show_in_layout: NotRequired[bool]
"""Whether to show the field in the rendered layout of the need by default (False if not present)."""
exclude_extend: NotRequired[bool]
"""Whether field should be excluded from needextend options (False if not present)."""
exclude_external: NotRequired[bool]
"""Whether field should be excluded when loading external needs (False if not present)."""
exclude_import: NotRequired[bool]
Expand All @@ -72,7 +74,11 @@ class CoreFieldParameters(TypedDict):


NeedsCoreFields: Final[Mapping[str, CoreFieldParameters]] = {
"id": {"description": "ID of the data.", "schema": {"type": "string"}},
"id": {
"description": "ID of the data.",
"schema": {"type": "string"},
"exclude_extend": True,
},
"docname": {
"description": "Name of the document where the need is defined (None if external).",
"schema": {"type": ["string", "null"], "default": None},
Expand Down Expand Up @@ -127,6 +133,8 @@ class CoreFieldParameters(TypedDict):
"schema": {"type": "boolean", "default": False},
"exclude_external": True,
"exclude_import": True,
"exclude_json": True,
"exclude_extend": True,
},
"layout": {
"description": "Key of the layout, which is used to render the need.",
Expand Down
2 changes: 0 additions & 2 deletions sphinx_needs/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,4 @@ def string_to_boolean(argument: str | None) -> bool | None:
"constraints_results": directives.unchanged_required,
}

NEEDEXTEND_NOT_ALLOWED_OPTIONS = ["id"]

NEEDS_PROFILING = [x.upper() for x in os.environ.get("NEEDS_PROFILING", "").split(",")]
9 changes: 5 additions & 4 deletions sphinx_needs/needs.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
GRAPHVIZ_STYLE_DEFAULTS,
LAYOUTS,
NEED_DEFAULT_OPTIONS,
NEEDEXTEND_NOT_ALLOWED_OPTIONS,
NEEDFLOW_CONFIG_DEFAULTS,
)
from sphinx_needs.directives.list2need import List2Need, List2NeedDirective
Expand Down Expand Up @@ -478,9 +477,11 @@ def load_config(app: Sphinx, *_args: Any) -> None:
NeedserviceDirective.option_spec.update(extra_links)

# Update NeedextendDirective with option modifiers.
exclude_extend = {
k for k, v in NeedsCoreFields.items() if v.get("exclude_extend", False)
}
for key, value in NEED_DEFAULT_OPTIONS.items():
# Ignore options like "id"
if key in NEEDEXTEND_NOT_ALLOWED_OPTIONS:
if key in exclude_extend:
continue

NeedextendDirective.option_spec.update(
Expand Down Expand Up @@ -551,7 +552,7 @@ def load_config(app: Sphinx, *_args: Any) -> None:
if needs_config.report_dead_links is not True:
log_warning(
LOGGER,
'Config option "needs_constraints_failed_color" is deprecated. Please use `suppress_warnings = ["needs.link_outgoing"]` instead.',
'Config option "needs_report_dead_links" is deprecated. Please use `suppress_warnings = ["needs.link_outgoing"]` instead.',
"config",
None,
)
Expand Down
8 changes: 0 additions & 8 deletions tests/__snapshots__/test_basic_doc.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
}),
'content': '',
'created_at': '',
'delete': False,
'docname': 'index',
'doctype': '.rst',
'duration': '',
Expand Down Expand Up @@ -87,7 +86,6 @@
}),
'content': '',
'created_at': '',
'delete': False,
'docname': 'index',
'doctype': '.rst',
'duration': '',
Expand Down Expand Up @@ -221,12 +219,6 @@
'field_type': 'extra',
'type': 'string',
}),
'delete': dict({
'default': False,
'description': 'If true, the need is deleted entirely.',
'field_type': 'core',
'type': 'boolean',
}),
'docname': dict({
'default': None,
'description': 'Name of the document where the need is defined (None if external).',
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 @@ -111,12 +111,6 @@
'field_type': 'extra',
'type': 'string',
}),
'delete': dict({
'default': False,
'description': 'If true, the need is deleted entirely.',
'field_type': 'core',
'type': 'boolean',
}),
'docname': dict({
'default': None,
'description': 'Name of the document where the need is defined (None if external).',
Expand Down Expand Up @@ -490,7 +484,6 @@
}),
'content': 'EXT_TEST_01',
'created_at': '',
'delete': False,
'docname': None,
'doctype': '',
'duration': '',
Expand Down Expand Up @@ -563,7 +556,6 @@
}),
'content': 'EXT_TEST_02',
'created_at': '',
'delete': False,
'docname': None,
'doctype': '',
'duration': '',
Expand Down Expand Up @@ -639,7 +631,6 @@
}),
'content': '',
'created_at': '',
'delete': False,
'docname': 'index',
'doctype': '.rst',
'duration': '',
Expand Down Expand Up @@ -711,7 +702,6 @@
}),
'content': '',
'created_at': '',
'delete': False,
'docname': 'index',
'doctype': '.rst',
'duration': '',
Expand Down Expand Up @@ -784,7 +774,6 @@
}),
'content': '',
'created_at': '',
'delete': False,
'docname': 'subfolder_a/subfolder_b/subpage',
'doctype': '.rst',
'duration': '',
Expand Down Expand Up @@ -918,12 +907,6 @@
'field_type': 'extra',
'type': 'string',
}),
'delete': dict({
'default': False,
'description': 'If true, the need is deleted entirely.',
'field_type': 'core',
'type': 'boolean',
}),
'docname': dict({
'default': None,
'description': 'Name of the document where the need is defined (None if external).',
Expand Down
6 changes: 0 additions & 6 deletions tests/__snapshots__/test_extra_options.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,6 @@
'field_type': 'extra',
'type': 'string',
}),
'delete': dict({
'default': False,
'description': 'If true, the need is deleted entirely.',
'field_type': 'core',
'type': 'boolean',
}),
'docname': dict({
'default': None,
'description': 'Name of the document where the need is defined (None if external).',
Expand Down
14 changes: 0 additions & 14 deletions tests/__snapshots__/test_need_constraints.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
}),
'content': 'This is a requirement describing OPSEC processes.',
'created_at': '',
'delete': False,
'docname': 'index',
'doctype': '.rst',
'duration': '',
Expand Down Expand Up @@ -93,7 +92,6 @@
}),
'content': 'Example of a successful constraint.',
'created_at': '',
'delete': False,
'docname': 'index',
'doctype': '.rst',
'duration': '',
Expand Down Expand Up @@ -170,7 +168,6 @@
}),
'content': 'Example of a failed constraint.',
'created_at': '',
'delete': False,
'docname': 'index',
'doctype': '.rst',
'duration': '',
Expand Down Expand Up @@ -245,7 +242,6 @@
}),
'content': 'Example of a failed constraint with medium severity. Note the style from :ref:`needs_constraint_failed_options`',
'created_at': '',
'delete': False,
'docname': 'index',
'doctype': '.rst',
'duration': '',
Expand Down Expand Up @@ -315,7 +311,6 @@
}),
'content': 'The Tool awesome shall have a command line interface.',
'created_at': '',
'delete': False,
'docname': 'index',
'doctype': '.rst',
'duration': '',
Expand Down Expand Up @@ -392,7 +387,6 @@
}),
'content': 'asdf',
'created_at': '',
'delete': False,
'docname': 'index',
'doctype': '.rst',
'duration': '',
Expand Down Expand Up @@ -469,7 +463,6 @@
}),
'content': '',
'created_at': '',
'delete': False,
'docname': 'style_test',
'doctype': '.rst',
'duration': '',
Expand Down Expand Up @@ -543,7 +536,6 @@
}),
'content': '',
'created_at': '',
'delete': False,
'docname': 'style_test',
'doctype': '.rst',
'duration': '',
Expand Down Expand Up @@ -677,12 +669,6 @@
'field_type': 'extra',
'type': 'string',
}),
'delete': dict({
'default': False,
'description': 'If true, the need is deleted entirely.',
'field_type': 'core',
'type': 'boolean',
}),
'docname': dict({
'default': None,
'description': 'Name of the document where the need is defined (None if external).',
Expand Down
23 changes: 0 additions & 23 deletions tests/__snapshots__/test_needextend.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
}),
'content': '',
'created_at': '',
'delete': False,
'docname': 'index',
'doctype': '.rst',
'duration': '',
Expand Down Expand Up @@ -90,7 +89,6 @@
}),
'content': '',
'created_at': '',
'delete': False,
'docname': 'index',
'doctype': '.rst',
'duration': '',
Expand Down Expand Up @@ -161,7 +159,6 @@
}),
'content': '',
'created_at': '',
'delete': False,
'docname': 'index',
'doctype': '.rst',
'duration': '',
Expand Down Expand Up @@ -232,7 +229,6 @@
}),
'content': '',
'created_at': '',
'delete': False,
'docname': 'index',
'doctype': '.rst',
'duration': '',
Expand Down Expand Up @@ -302,7 +298,6 @@
}),
'content': '',
'created_at': '',
'delete': False,
'docname': 'index',
'doctype': '.rst',
'duration': '',
Expand Down Expand Up @@ -437,12 +432,6 @@
'field_type': 'extra',
'type': 'string',
}),
'delete': dict({
'default': False,
'description': 'If true, the need is deleted entirely.',
'field_type': 'core',
'type': 'boolean',
}),
'docname': dict({
'default': None,
'description': 'Name of the document where the need is defined (None if external).',
Expand Down Expand Up @@ -819,7 +808,6 @@
Got an outgoing link ``extend_test_004``.
''',
'created_at': '',
'delete': False,
'docname': 'index',
'doctype': '.rst',
'duration': '',
Expand Down Expand Up @@ -895,7 +883,6 @@
Got an incoming links ``extend_test_003`` and ``extend_test_006``.
''',
'created_at': '',
'delete': False,
'docname': 'index',
'doctype': '.rst',
'duration': '',
Expand Down Expand Up @@ -971,7 +958,6 @@
Both got deleted.
''',
'created_at': '',
'delete': False,
'docname': 'index',
'doctype': '.rst',
'duration': '',
Expand Down Expand Up @@ -1042,7 +1028,6 @@
}),
'content': 'Had the link ``extend_test_003``, got another one ``extend_test_004``.',
'created_at': '',
'delete': False,
'docname': 'index',
'doctype': '.rst',
'duration': '',
Expand Down Expand Up @@ -1114,7 +1099,6 @@
}),
'content': '',
'created_at': '',
'delete': False,
'docname': 'index',
'doctype': '.rst',
'duration': '',
Expand Down Expand Up @@ -1187,7 +1171,6 @@
}),
'content': '',
'created_at': '',
'delete': False,
'docname': 'page_1',
'doctype': '.rst',
'duration': '',
Expand Down Expand Up @@ -1324,12 +1307,6 @@
'field_type': 'extra',
'type': 'string',
}),
'delete': dict({
'default': False,
'description': 'If true, the need is deleted entirely.',
'field_type': 'core',
'type': 'boolean',
}),
'docname': dict({
'default': None,
'description': 'Name of the document where the need is defined (None if external).',
Expand Down
6 changes: 0 additions & 6 deletions tests/__snapshots__/test_needimport.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -1713,12 +1713,6 @@
'field_type': 'extra',
'type': 'string',
}),
'delete': dict({
'default': False,
'description': 'If true, the need is deleted entirely.',
'field_type': 'core',
'type': 'boolean',
}),
'docname': dict({
'default': None,
'description': 'Name of the document where the need is defined (None if external).',
Expand Down
Loading
Loading