Skip to content

Hidden needs are incorrectly assigned a parent_need link #1433

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

Open
PierreEtienneJ opened this issue Apr 3, 2025 · 0 comments
Open

Hidden needs are incorrectly assigned a parent_need link #1433

PierreEtienneJ opened this issue Apr 3, 2025 · 0 comments

Comments

@PierreEtienneJ
Copy link

Description

When two needs directive follow each other and the second have option :hide:, a parent_need link is incorrectly assigned to the previous directive when a :hide: option is used.

Steps to Reproduce

In rst file

.. req:: req-1

    requirement 1

.. req:: req-2

    requirement 2

text between 2 and 3

.. req:: req-3

    requirement 3

.. req:: req-a
    :hide:

    requirement A

.. req:: req-b
    :hide:

    requirement B

.. spec:: spec-c
    :hide:

    spec C

text between C and D

.. req:: req-d
    :hide:

    requirement D


.. needtable::
   :columns: id;title;parent_needs

Explanation

  • req-1 and req-2 follow directly.
  • req-2 and req-3 have a text between nodes
  • req-3 and req-a follow directly and req-a have option hide
  • req-a and req-b follow directly both have option hide
  • req-b and spec-c follow directly both have option hide
  • spec-c and req-d have a text between nodes and both have option hide

In needtable it's expected:

id title parent_needs
R_A7BB1 req-1
R_F1A88 req-2
R_C2CE3 req-3
R_8CA9D req-a
R_3C018 req-b
S_13219 spec-c
R_490A1 req-d

But we have

id title parent_needs
R_A7BB1 req-1
R_F1A88 req-2
R_C2CE3 req-3
R_8CA9D req-a R_C2CE3
R_3C018 req-b R_8CA9D
S_13219 spec-c R_3C018
R_490A1 req-d

With needservice

from sphinx_needs.services.base import BaseService

extensions = [
    "sphinx_needs",
]

class MyService(BaseService):
    options = []
    def __init__(self, app, name, config, **kwargs):
        self.app = app
        self.name = name

        self.config = config
        super(BaseService, self).__init__()

    def request(self, options):
        nodes = [
            {
                "title": "req-1",
                "hide": False,
                "type": "req",
            },
            {
                "title": "req-2",
                "hide": False,
                "type": "req",
            },
            {
                "title": "req-3",
                "hide": True,
                "type": "req",
            },
            {
                "title": "spec-4",
                "hide": True,
                "type": "spec",
            }
        ]
        return nodes


needs_services = {
    'my-service': {
        'class': MyService,
        'class_init': {
        },
    },
}

in the rst

.. needservice:: my-service

.. needtable::
   :columns: id;title;parent_needs

Explanation:

  • req-1 and req-2 are not hide.
  • req-3 and spec-4 are hide

Expected:

id title parent_needs
R_A7BB1 req-1
R_F1A88 req-2
R_C2CE3 req-3
S_3811D spec-4

But I have:

id title parent_needs
R_A7BB1 req-1
R_F1A88 req-2
R_C2CE3 req-3 R_F1A88
S_3811D spec-4 R_C2CE3

Environment

  • Sphinx-needs version: 5.1.0
  • Sphinx version: 8.2.3
  • python version: 3.12
  • Operating System: Ubuntu 24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant