From 00d5aba1c1e3ce714e28f2a7ba19e3057d613f72 Mon Sep 17 00:00:00 2001 From: David Le Nir Date: Thu, 15 Feb 2024 09:38:59 +0100 Subject: [PATCH 1/3] exclude external needs from the identifier regex check (useblocks#1099) --- .gitignore | 2 ++ docs/changelog.rst | 9 +++++++++ sphinx_needs/api/need.py | 2 +- tests/doc_test/doc_needs_external_needs/conf.py | 3 +++ tests/doc_test/doc_needs_external_needs/index.rst | 5 +++++ 5 files changed, 20 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 4ab112d7d..40b2679d1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ .idea +*.iml +.DS_Store .venv* .pvenv .nox diff --git a/docs/changelog.rst b/docs/changelog.rst index ed001362d..8101602c6 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -9,6 +9,15 @@ License .. include:: ../LICENSE +2.1.0 +----- + +Fixed +..... + +* Fix external needs identifier checked by regex (`#1099 `_) + + 2.0.0 ----- diff --git a/sphinx_needs/api/need.py b/sphinx_needs/api/need.py index 5ae06f619..21ba360cf 100644 --- a/sphinx_needs/api/need.py +++ b/sphinx_needs/api/need.py @@ -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 diff --git a/tests/doc_test/doc_needs_external_needs/conf.py b/tests/doc_test/doc_needs_external_needs/conf.py index 95e5cee80..1feaeef97 100644 --- a/tests/doc_test/doc_needs_external_needs/conf.py +++ b/tests/doc_test/doc_needs_external_needs/conf.py @@ -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.*" diff --git a/tests/doc_test/doc_needs_external_needs/index.rst b/tests/doc_test/doc_needs_external_needs/index.rst index 72c82c2f6..0de2703c1 100644 --- a/tests/doc_test/doc_needs_external_needs/index.rst +++ b/tests/doc_test/doc_needs_external_needs/index.rst @@ -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 From 80f31913d75fb03b8b0dd72eb4cec6bf78ebbe31 Mon Sep 17 00:00:00 2001 From: David-Le-Nir <97294334+David-Le-Nir@users.noreply.github.com> Date: Mon, 26 Feb 2024 09:03:09 +0100 Subject: [PATCH 2/3] improve formatting in sphinx_needs/api/need.py Co-authored-by: Chris Sewell --- sphinx_needs/api/need.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/sphinx_needs/api/need.py b/sphinx_needs/api/need.py index 21ba360cf..94d116dda 100644 --- a/sphinx_needs/api/need.py +++ b/sphinx_needs/api/need.py @@ -190,8 +190,14 @@ def run(): else: need_id = 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}'") + 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 # Check if status is in needs_statuses. If not raise an error. From 48d6b5873c119e55b67f2f4e3eb843f926e23710 Mon Sep 17 00:00:00 2001 From: David-Le-Nir <97294334+David-Le-Nir@users.noreply.github.com> Date: Mon, 26 Feb 2024 09:04:08 +0100 Subject: [PATCH 3/3] set future version as "unreleased" in changelog Co-authored-by: Chris Sewell --- docs/changelog.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index 8101602c6..a85dc0f85 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -9,8 +9,8 @@ License .. include:: ../LICENSE -2.1.0 ------ +Unreleased +---------- Fixed .....