Skip to content

Commit

Permalink
exclude external needs from the identifier regex check (#1099)
Browse files Browse the repository at this point in the history
  • Loading branch information
David-Le-Nir committed Feb 15, 2024
1 parent f6b090a commit 0a1c6c8
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 2 deletions.
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


2.1.0
-----

Fixed
.....

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


2.0.0
-----

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "sphinx-needs"

# !! Don't miss updates in sphinx_needs.__version__, changelog.rst, and .github/workflows/docker !!!
version = "2.0.0"
version = "2.1.0"

description = "Sphinx needs extension for managing needs/requirements and specifications"
authors = ["team useblocks <[email protected]>"]
Expand Down
2 changes: 1 addition & 1 deletion sphinx_needs/api/need.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ 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}'")

# Handle status
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 @@ -16,3 +16,6 @@
{"base_url": "http://my_company.com/docs/v1/", "json_path": "needs_test_small.json", "id_prefix": "ext_"},
{"base_url": "../../_build/html", "json_path": "needs_test_small.json", "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 0a1c6c8

Please sign in to comment.