Skip to content

Commit

Permalink
👌 Exclude external needs from needs_id_regex check (#1108)
Browse files Browse the repository at this point in the history
fix for [#1099](#1099)

---------

Co-authored-by: Chris Sewell <[email protected]>
  • Loading branch information
David-Le-Nir and chrisjsewell authored Feb 26, 2024
1 parent cf5598f commit a037336
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
.idea
*.iml
.DS_Store
.venv*
.pvenv
.nox
Expand Down
9 changes: 9 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@ License
.. include:: ../LICENSE


Unreleased
----------

Fixed
.....

* Fix external needs identifier checked by regex (`#1099 <https://github.com/useblocks/sphinx-needs/pull/1099>`_)


2.0.0
-----

Expand Down
6 changes: 5 additions & 1 deletion sphinx_needs/api/need.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,11 @@ def run():
else:
need_id = id

if needs_config.id_regex and not re.match(needs_config.id_regex, need_id):
if (
needs_config.id_regex
and not is_external
and not re.match(needs_config.id_regex, need_id)
):
raise NeedsInvalidException(
f"Given ID '{need_id}' does not match configured regex '{needs_config.id_regex}'"
)
Expand Down
3 changes: 3 additions & 0 deletions tests/doc_test/doc_needs_external_needs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,6 @@
"id_prefix": "ext_rel_path_",
},
]

# we want to ensure only internal needs are checked against this regex, not the external ones
needs_id_regex = "INTERNAL.*"
5 changes: 5 additions & 0 deletions tests/doc_test/doc_needs_external_needs/index.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
TEST DOCUMENT NEEDS EXTERNAL NEEDS
==================================

.. spec:: Internal need
:id: INTERNAL_001

An internal requirement with an id check by the regex. External needs identifiers shall not be checked for regex matching.

.. needlist::
:tags: ext_test

Expand Down

0 comments on commit a037336

Please sign in to comment.