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

👌 Exclude external needs from needs_id_regex check #1108

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
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
Loading