sphinx-needs icon indicating copy to clipboard operation
sphinx-needs copied to clipboard

Unable to reference need IDs containing dots using :need: directive

Open PierreEtienneJ opened this issue 11 months ago • 1 comments

Description

When a need ID contains a dot (e.g., REQ_1.a), it's not possible to reference this need, for example using the :need: directive like :need:`REQ_1.a` .

This issue occurs because the function sphinx_needs.utils.split_need_id splits the provided ID at dots, which prevents proper referencing of IDs containing dots.

Steps to reproduce

  1. set needs_id_regex in conf.py
needs_id_regex = r"REQ_\d\.[a-z]"
  1. create a need with id containing a dot: REQ_1.a
  2. Try to reference it using :need:`REQ_1.a` .

in rst

.. req:: req-1
    :id: REQ_1.a

    requirement 1

:need:`REQ_1.a`
  1. The reference fails or does not work as expected
 WARNING: linked need REQ_1.a not found [needs.link_ref]

Possible solution

  1. add documentation about main id and part id with examples.
  2. add configuration to allow the split or to change the split character.
  3. update function sphinx_needs.roles.need_ref.process_need_ref to test the need_id_full if the need_id_main is not found.

According to your answers, I can fix that with a pull request.

PierreEtienneJ avatar Apr 06 '25 13:04 PierreEtienneJ

A dot is somehow a reserved character in Sphinx-Needs and is used to address need_parts.

This character is currently hard-coded.

I guess we should add some docs to need-id description to explain this in all related docs.

danwos avatar Apr 15 '25 18:04 danwos