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 internal needs and needs.json #1347

Merged
merged 3 commits into from
Feb 18, 2025
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
18 changes: 7 additions & 11 deletions sphinx_needs/api/need.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,13 @@

logger = get_logger(__name__)

_deprecated_kwargs = {"constraints_passed", "links_string", "hide_tags", "hide_status"}
_deprecated_kwargs = {
"constraints_passed",
"links_string",
"hide_tags",
"hide_status",
"delete",
}


def generate_need(
Expand All @@ -50,7 +56,6 @@ def generate_need(
arch: dict[str, str] | None = None,
signature: str = "",
sections: list[str] | None = None,
delete: None | bool = False,
jinja_content: None | bool = False,
hide: bool = False,
collapse: None | bool = None,
Expand Down Expand Up @@ -104,7 +109,6 @@ def generate_need(
:param tags: A list of tags, or a comma separated string.
:param constraints: Constraints as single, comma separated, string.
:param constraints_passed: Contains bool describing if all constraints have passed
:param delete: boolean value (Remove the complete need).
:param hide: boolean value.
:param collapse: boolean value.
:param style: String value of class attribute of node.
Expand Down Expand Up @@ -215,7 +219,6 @@ def generate_need(
"pre_template": pre_template,
"post_template": post_template,
"hide": hide,
"delete": delete or False,
"jinja_content": jinja_content or False,
"parts": parts or {},
"is_part": False,
Expand Down Expand Up @@ -333,7 +336,6 @@ def add_need(
arch: dict[str, str] | None = None,
signature: str = "",
sections: list[str] | None = None,
delete: None | bool = False,
jinja_content: None | bool = False,
hide: bool = False,
collapse: None | bool = None,
Expand Down Expand Up @@ -389,7 +391,6 @@ def add_need(
:param tags: A list of tags, or a comma separated string.
:param constraints: Constraints as single, comma separated, string.
:param constraints_passed: Contains bool describing if all constraints have passed
:param delete: boolean value (Remove the complete need).
:param hide: boolean value.
:param collapse: boolean value.
:param style: String value of class attribute of node.
Expand All @@ -407,10 +408,6 @@ def add_need(
)
kwargs = {k: v for k, v in kwargs.items() if k not in _deprecated_kwargs}

if delete:
# Don't generate a need object if the :delete: option is enabled.
return []

if doctype is None and not is_external and docname:
doctype = os.path.splitext(app.env.doc2path(docname))[1]

Expand All @@ -431,7 +428,6 @@ def add_need(
arch=arch,
signature=signature,
sections=sections,
delete=delete,
jinja_content=jinja_content,
hide=hide,
collapse=collapse,
Expand Down
8 changes: 0 additions & 8 deletions sphinx_needs/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,6 @@ class CoreFieldParameters(TypedDict):
"exclude_external": True,
"allow_extend": True,
},
"delete": {
"description": "If true, the need is deleted entirely.",
"schema": {"type": "boolean", "default": False},
"exclude_external": True,
"exclude_import": True,
},
"layout": {
"description": "Key of the layout, which is used to render the need.",
"schema": {"type": ["string", "null"], "default": None},
Expand Down Expand Up @@ -392,8 +386,6 @@ class NeedsInfoType(TypedDict, total=False):
"""Hide the meta-data information of the need."""
hide: Required[bool]
"""If true, the need is not rendered."""
delete: Required[bool]
"""If true, the need is deleted entirely."""
layout: Required[None | str]
"""Key of the layout, which is used to render the need."""
style: Required[None | str]
Expand Down
5 changes: 3 additions & 2 deletions sphinx_needs/directives/need.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,11 @@ class NeedDirective(SphinxDirective):

@measure_time("need")
def run(self) -> Sequence[nodes.Node]:
if self.options.get("delete"):
return []

needs_config = NeedsSphinxConfig(self.env.config)

delete_opt = self.options.get("delete")
collapse = self.options.get("collapse")
jinja_content = self.options.get("jinja_content")
hide = "hide" in self.options
Expand Down Expand Up @@ -104,7 +106,6 @@ def run(self) -> Sequence[nodes.Node]:
collapse=collapse,
style=style,
layout=layout,
delete=delete_opt,
jinja_content=jinja_content,
constraints=constraints,
**need_extra_options,
Expand Down
2 changes: 1 addition & 1 deletion sphinx_needs/needs.py
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,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 @@ -18,7 +18,6 @@
}),
'content': '',
'created_at': '',
'delete': False,
'docname': 'index',
'doctype': '.rst',
'duration': '',
Expand Down Expand Up @@ -88,7 +87,6 @@
}),
'content': '',
'created_at': '',
'delete': False,
'docname': 'index',
'doctype': '.rst',
'duration': '',
Expand Down Expand Up @@ -222,12 +220,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
12 changes: 0 additions & 12 deletions tests/__snapshots__/test_external.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,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 @@ -667,12 +661,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 @@ -131,12 +131,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
16 changes: 0 additions & 16 deletions tests/__snapshots__/test_list2need.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
the **content** by :ref:`test`
''',
'created_at': '',
'delete': False,
'docname': 'index',
'doctype': '.rst',
'duration': '',
Expand Down Expand Up @@ -127,7 +126,6 @@
}),
'content': '',
'created_at': '',
'delete': False,
'docname': 'index',
'doctype': '.rst',
'duration': '',
Expand Down Expand Up @@ -214,7 +212,6 @@
}),
'content': '',
'created_at': '',
'delete': False,
'docname': 'options',
'doctype': '.rst',
'duration': '',
Expand Down Expand Up @@ -301,7 +298,6 @@
}),
'content': '',
'created_at': '',
'delete': False,
'docname': 'options',
'doctype': '.rst',
'duration': '',
Expand Down Expand Up @@ -391,7 +387,6 @@
}),
'content': '',
'created_at': '',
'delete': False,
'docname': 'options',
'doctype': '.rst',
'duration': '',
Expand Down Expand Up @@ -481,7 +476,6 @@
}),
'content': 'With some content in the next line.',
'created_at': '',
'delete': False,
'docname': 'options',
'doctype': '.rst',
'duration': '',
Expand Down Expand Up @@ -569,7 +563,6 @@
}),
'content': '',
'created_at': '',
'delete': False,
'docname': 'links_down',
'doctype': '.rst',
'duration': '',
Expand Down Expand Up @@ -656,7 +649,6 @@
}),
'content': '',
'created_at': '',
'delete': False,
'docname': 'links_down',
'doctype': '.rst',
'duration': '',
Expand Down Expand Up @@ -743,7 +735,6 @@
}),
'content': '',
'created_at': '',
'delete': False,
'docname': 'links_down',
'doctype': '.rst',
'duration': '',
Expand Down Expand Up @@ -830,7 +821,6 @@
}),
'content': '',
'created_at': '',
'delete': False,
'docname': 'global_tags',
'doctype': '.rst',
'duration': '',
Expand Down Expand Up @@ -920,7 +910,6 @@
}),
'content': '',
'created_at': '',
'delete': False,
'docname': 'global_tags',
'doctype': '.rst',
'duration': '',
Expand Down Expand Up @@ -1012,7 +1001,6 @@
}),
'content': '',
'created_at': '',
'delete': False,
'docname': 'global_tags',
'doctype': '.rst',
'duration': '',
Expand Down Expand Up @@ -1104,7 +1092,6 @@
}),
'content': 'With some content in the next line.',
'created_at': '',
'delete': False,
'docname': 'global_tags',
'doctype': '.rst',
'duration': '',
Expand Down Expand Up @@ -1204,7 +1191,6 @@
the **content** by :ref:`test`
''',
'created_at': '',
'delete': False,
'docname': 'index',
'doctype': '.rst',
'duration': '',
Expand Down Expand Up @@ -1295,7 +1281,6 @@
the **content** by :ref:`test`
''',
'created_at': '',
'delete': False,
'docname': 'index',
'doctype': '.rst',
'duration': '',
Expand Down Expand Up @@ -1382,7 +1367,6 @@
}),
'content': '',
'created_at': '',
'delete': False,
'docname': 'index',
'doctype': '.rst',
'duration': '',
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 @@ -18,7 +18,6 @@
}),
'content': 'This is a requirement describing OPSEC processes.',
'created_at': '',
'delete': False,
'docname': 'index',
'doctype': '.rst',
'duration': '',
Expand Down Expand Up @@ -94,7 +93,6 @@
}),
'content': 'Example of a successful constraint.',
'created_at': '',
'delete': False,
'docname': 'index',
'doctype': '.rst',
'duration': '',
Expand Down Expand Up @@ -171,7 +169,6 @@
}),
'content': 'Example of a failed constraint.',
'created_at': '',
'delete': False,
'docname': 'index',
'doctype': '.rst',
'duration': '',
Expand Down Expand Up @@ -246,7 +243,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 @@ -316,7 +312,6 @@
}),
'content': 'The Tool awesome shall have a command line interface.',
'created_at': '',
'delete': False,
'docname': 'index',
'doctype': '.rst',
'duration': '',
Expand Down Expand Up @@ -393,7 +388,6 @@
}),
'content': 'asdf',
'created_at': '',
'delete': False,
'docname': 'index',
'doctype': '.rst',
'duration': '',
Expand Down Expand Up @@ -470,7 +464,6 @@
}),
'content': '',
'created_at': '',
'delete': False,
'docname': 'style_test',
'doctype': '.rst',
'duration': '',
Expand Down Expand Up @@ -544,7 +537,6 @@
}),
'content': '',
'created_at': '',
'delete': False,
'docname': 'style_test',
'doctype': '.rst',
'duration': '',
Expand Down Expand Up @@ -678,12 +670,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