diff --git a/sphinx_needs/data.py b/sphinx_needs/data.py index a01a4af12..78be90cf7 100644 --- a/sphinx_needs/data.py +++ b/sphinx_needs/data.py @@ -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] @@ -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}, @@ -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.", diff --git a/sphinx_needs/defaults.py b/sphinx_needs/defaults.py index b477af838..0f758a2bc 100644 --- a/sphinx_needs/defaults.py +++ b/sphinx_needs/defaults.py @@ -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(",")] diff --git a/sphinx_needs/needs.py b/sphinx_needs/needs.py index 5977fffbd..048842852 100644 --- a/sphinx_needs/needs.py +++ b/sphinx_needs/needs.py @@ -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 @@ -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( @@ -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, ) diff --git a/tests/__snapshots__/test_basic_doc.ambr b/tests/__snapshots__/test_basic_doc.ambr index e9f5f1a89..666a32d72 100644 --- a/tests/__snapshots__/test_basic_doc.ambr +++ b/tests/__snapshots__/test_basic_doc.ambr @@ -17,7 +17,6 @@ }), 'content': '', 'created_at': '', - 'delete': False, 'docname': 'index', 'doctype': '.rst', 'duration': '', @@ -87,7 +86,6 @@ }), 'content': '', 'created_at': '', - 'delete': False, 'docname': 'index', 'doctype': '.rst', 'duration': '', @@ -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).', diff --git a/tests/__snapshots__/test_external.ambr b/tests/__snapshots__/test_external.ambr index 48630882e..35442c2e2 100644 --- a/tests/__snapshots__/test_external.ambr +++ b/tests/__snapshots__/test_external.ambr @@ -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).', @@ -490,7 +484,6 @@ }), 'content': 'EXT_TEST_01', 'created_at': '', - 'delete': False, 'docname': None, 'doctype': '', 'duration': '', @@ -563,7 +556,6 @@ }), 'content': 'EXT_TEST_02', 'created_at': '', - 'delete': False, 'docname': None, 'doctype': '', 'duration': '', @@ -639,7 +631,6 @@ }), 'content': '', 'created_at': '', - 'delete': False, 'docname': 'index', 'doctype': '.rst', 'duration': '', @@ -711,7 +702,6 @@ }), 'content': '', 'created_at': '', - 'delete': False, 'docname': 'index', 'doctype': '.rst', 'duration': '', @@ -784,7 +774,6 @@ }), 'content': '', 'created_at': '', - 'delete': False, 'docname': 'subfolder_a/subfolder_b/subpage', 'doctype': '.rst', 'duration': '', @@ -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).', diff --git a/tests/__snapshots__/test_extra_options.ambr b/tests/__snapshots__/test_extra_options.ambr index e8e659288..d1263000b 100644 --- a/tests/__snapshots__/test_extra_options.ambr +++ b/tests/__snapshots__/test_extra_options.ambr @@ -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).', diff --git a/tests/__snapshots__/test_need_constraints.ambr b/tests/__snapshots__/test_need_constraints.ambr index 26130144b..2822c618d 100644 --- a/tests/__snapshots__/test_need_constraints.ambr +++ b/tests/__snapshots__/test_need_constraints.ambr @@ -17,7 +17,6 @@ }), 'content': 'This is a requirement describing OPSEC processes.', 'created_at': '', - 'delete': False, 'docname': 'index', 'doctype': '.rst', 'duration': '', @@ -93,7 +92,6 @@ }), 'content': 'Example of a successful constraint.', 'created_at': '', - 'delete': False, 'docname': 'index', 'doctype': '.rst', 'duration': '', @@ -170,7 +168,6 @@ }), 'content': 'Example of a failed constraint.', 'created_at': '', - 'delete': False, 'docname': 'index', 'doctype': '.rst', 'duration': '', @@ -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': '', @@ -315,7 +311,6 @@ }), 'content': 'The Tool awesome shall have a command line interface.', 'created_at': '', - 'delete': False, 'docname': 'index', 'doctype': '.rst', 'duration': '', @@ -392,7 +387,6 @@ }), 'content': 'asdf', 'created_at': '', - 'delete': False, 'docname': 'index', 'doctype': '.rst', 'duration': '', @@ -469,7 +463,6 @@ }), 'content': '', 'created_at': '', - 'delete': False, 'docname': 'style_test', 'doctype': '.rst', 'duration': '', @@ -543,7 +536,6 @@ }), 'content': '', 'created_at': '', - 'delete': False, 'docname': 'style_test', 'doctype': '.rst', 'duration': '', @@ -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).', diff --git a/tests/__snapshots__/test_needextend.ambr b/tests/__snapshots__/test_needextend.ambr index 182849287..681328073 100644 --- a/tests/__snapshots__/test_needextend.ambr +++ b/tests/__snapshots__/test_needextend.ambr @@ -17,7 +17,6 @@ }), 'content': '', 'created_at': '', - 'delete': False, 'docname': 'index', 'doctype': '.rst', 'duration': '', @@ -90,7 +89,6 @@ }), 'content': '', 'created_at': '', - 'delete': False, 'docname': 'index', 'doctype': '.rst', 'duration': '', @@ -161,7 +159,6 @@ }), 'content': '', 'created_at': '', - 'delete': False, 'docname': 'index', 'doctype': '.rst', 'duration': '', @@ -232,7 +229,6 @@ }), 'content': '', 'created_at': '', - 'delete': False, 'docname': 'index', 'doctype': '.rst', 'duration': '', @@ -302,7 +298,6 @@ }), 'content': '', 'created_at': '', - 'delete': False, 'docname': 'index', 'doctype': '.rst', 'duration': '', @@ -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).', @@ -819,7 +808,6 @@ Got an outgoing link ``extend_test_004``. ''', 'created_at': '', - 'delete': False, 'docname': 'index', 'doctype': '.rst', 'duration': '', @@ -895,7 +883,6 @@ Got an incoming links ``extend_test_003`` and ``extend_test_006``. ''', 'created_at': '', - 'delete': False, 'docname': 'index', 'doctype': '.rst', 'duration': '', @@ -971,7 +958,6 @@ Both got deleted. ''', 'created_at': '', - 'delete': False, 'docname': 'index', 'doctype': '.rst', 'duration': '', @@ -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': '', @@ -1114,7 +1099,6 @@ }), 'content': '', 'created_at': '', - 'delete': False, 'docname': 'index', 'doctype': '.rst', 'duration': '', @@ -1187,7 +1171,6 @@ }), 'content': '', 'created_at': '', - 'delete': False, 'docname': 'page_1', 'doctype': '.rst', 'duration': '', @@ -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).', diff --git a/tests/__snapshots__/test_needimport.ambr b/tests/__snapshots__/test_needimport.ambr index 3122c2157..32f44b821 100644 --- a/tests/__snapshots__/test_needimport.ambr +++ b/tests/__snapshots__/test_needimport.ambr @@ -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).', diff --git a/tests/__snapshots__/test_needs_builder.ambr b/tests/__snapshots__/test_needs_builder.ambr index a095bbbac..947ff4e2d 100644 --- a/tests/__snapshots__/test_needs_builder.ambr +++ b/tests/__snapshots__/test_needs_builder.ambr @@ -17,7 +17,6 @@ }), 'content': '', 'created_at': '', - 'delete': False, 'docname': 'index', 'doctype': '.rst', 'duration': '', @@ -87,7 +86,6 @@ }), 'content': '', 'created_at': '', - 'delete': False, 'docname': 'index', 'doctype': '.rst', 'duration': '', @@ -157,7 +155,6 @@ }), 'content': '', 'created_at': '', - 'delete': False, 'docname': 'index', 'doctype': '.rst', 'duration': '', @@ -292,12 +289,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).', @@ -953,12 +944,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).', @@ -1498,7 +1483,6 @@ }), 'content': '', 'created_at': '', - 'delete': False, 'docname': 'index', 'doctype': '.rst', 'duration': '', @@ -1568,7 +1552,6 @@ }), 'content': '', 'created_at': '', - 'delete': False, 'docname': 'index', 'doctype': '.rst', 'duration': '', @@ -1638,7 +1621,6 @@ }), 'content': '', 'created_at': '', - 'delete': False, 'docname': 'index', 'doctype': '.rst', 'duration': '', @@ -1773,12 +1755,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).', diff --git a/tests/__snapshots__/test_needs_id_builder.ambr b/tests/__snapshots__/test_needs_id_builder.ambr index 6fc506ea8..da14169c3 100644 --- a/tests/__snapshots__/test_needs_id_builder.ambr +++ b/tests/__snapshots__/test_needs_id_builder.ambr @@ -18,7 +18,6 @@ }), 'content': '', 'created_at': '', - 'delete': False, 'docname': 'index', 'doctype': '.rst', 'duration': '', @@ -98,7 +97,6 @@ }), 'content': '', 'created_at': '', - 'delete': False, 'docname': 'index', 'doctype': '.rst', 'duration': '', @@ -178,7 +176,6 @@ }), 'content': '', 'created_at': '', - 'delete': False, 'docname': 'index', 'doctype': '.rst', 'duration': '', diff --git a/tests/__snapshots__/test_service_github.ambr b/tests/__snapshots__/test_service_github.ambr index 862de1b7b..ba894c59f 100644 --- a/tests/__snapshots__/test_service_github.ambr +++ b/tests/__snapshots__/test_service_github.ambr @@ -20,7 +20,6 @@ Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> ''', 'created_at': '2024-02-15T14:04:06Z', - 'delete': False, 'docname': 'index', 'doctype': '.rst', 'duration': '', @@ -97,7 +96,6 @@ ''', 'created_at': '2024-02-15T12:19:11Z', - 'delete': False, 'docname': 'index', 'doctype': '.rst', 'duration': '', @@ -197,7 +195,6 @@ closes #1103 ''', 'created_at': '2024-02-15T20:45:12Z', - 'delete': False, 'docname': 'index', 'doctype': '.rst', 'duration': '', @@ -281,7 +278,6 @@ default as `dropdown`, so as not to introduce a breaking change) ''', 'created_at': '2024-02-12T08:36:07.000Z', - 'delete': False, 'docname': 'index', 'doctype': '.rst', 'duration': '', @@ -409,12 +405,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).',