Skip to content
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
11 changes: 11 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@
Changelog
=========

.. _`release:6.3.0+1`:

6.3.0+1
-------

- 👌 Allow setting ``parent_needs`` manually

Use ``:parent_needs: PARENT_ID`` to assign a parent
without actually nesting the needs in the source file.


.. _`release:6.3.0`:

6.3.0
Expand Down
28 changes: 28 additions & 0 deletions docs/directives/need.rst
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,34 @@ By using :ref:`needs_extra_links <needs_extra_links>`, you can use the configure

Perform some tests

.. _need_parent_needs:

parent_needs
~~~~~~~~~~~~

The ``parent_needs`` option is set automatically when one need is nested within another.
But if desired, you can set it like a normal option.

.. need-example::

.. req:: Example 1 Parent
:id: REQ_P1

.. req:: Example 1 Child
:id: REQ_C1

has the same parent/child relationship as

.. need-example::

.. req:: Example 2 Parent
:id: REQ_P2

.. req:: Example 2 Child
:id: REQ_C2
:parent_needs: REQ_P2


.. _need_delete:

delete
Expand Down
2 changes: 1 addition & 1 deletion sphinx_needs/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Sphinx needs extension for managing needs/requirements and specifications"""

__version__ = "6.3.0"
__version__ = "6.3.0+1"


def setup(app): # type: ignore[no-untyped-def]
Expand Down
2 changes: 1 addition & 1 deletion sphinx_needs/directives/need.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ def analyse_need_locations(app: Sphinx, doctree: nodes.document) -> None:
# append / set values from need
need_info["sections"] = tuple(sections)
need_info["signature"] = str(signature) if signature is not None else None
need_info["parent_needs"] = parent_needs
need_info["parent_needs"] += parent_needs

if need_node.get("hidden"):
hidden_needs.append(need_node)
Expand Down
3 changes: 3 additions & 0 deletions tests/doc_test/filter_doc/nested_needs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ Nested Needs
.. story:: child 2 story
:id: CHILD_2_STORY

.. story:: child 3 story
:id: CHILD_3_STORY
:parent_needs: CHILD_2_STORY
10 changes: 10 additions & 0 deletions tests/test_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,16 @@ def test_filter_build_html(test_app):
'href="#CHILD_1_STORY" title="CHILD_2_STORY">CHILD_1_STORY</a></span></span></div>'
in html_5
)
assert (
'<div class="line">child needs: <span class="parent_needs"><span><a class="reference internal" '
'href="#CHILD_3_STORY" title="CHILD_2_STORY">CHILD_3_STORY</a></span></span></div>'
in html_5
)
assert (
'<div class="line">parent needs: <span class="parent_needs"><span><a class="reference internal" '
'href="#CHILD_2_STORY" title="CHILD_3_STORY">CHILD_2_STORY</a></span></span></div>'
in html_5
)

html_6 = Path(app.outdir, "filter_no_needs.html").read_text()
assert html_6.count("No needs passed the filters") == 6
Expand Down
Loading