Skip to content

Commit 8896e2f

Browse files
authored
Merge branch 'main' into nicu1989_fix_esbonio
2 parents 56946d3 + c24f4d8 commit 8896e2f

2 files changed

Lines changed: 22 additions & 4 deletions

File tree

src/extensions/score_metamodel/checks/id_contains_feature.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
# SPDX-License-Identifier: Apache-2.0
1212
# *******************************************************************************
1313
import os
14+
import re
1415

1516
from sphinx.application import Sphinx
1617
from sphinx_needs.data import NeedsInfoType
@@ -37,6 +38,7 @@ def id_contains_feature(app: Sphinx, need: NeedsInfoType, log: CheckLogger):
3738

3839
# Get the part of the string after the first two underscores: the path
3940
feature = parts[1]
41+
featureparts = re.split(r"[_-]", feature)
4042

4143
dir_docname = os.path.dirname(str(need.get("docname", "")))
4244

@@ -45,7 +47,22 @@ def id_contains_feature(app: Sphinx, need: NeedsInfoType, log: CheckLogger):
4547
# NOTE: This does not match the process requirements
4648
docname = dir_docname if dir_docname else need.get("docname", "")
4749

48-
if feature not in docname:
50+
# allow if any feature part is contained in UID
51+
foundfeatpart = any(
52+
featurepart.lower() in docname.lower()
53+
for featurepart in featureparts
54+
if featureparts
55+
)
56+
57+
# allow abbreviation of the feature
58+
initials = "".join(
59+
featurepart[0].lower() for featurepart in featureparts if len(featureparts) > 1
60+
)
61+
foundinitials = initials in docname.lower()
62+
63+
if not (foundfeatpart or foundinitials):
4964
log.warning_for_option(
50-
need, "id", f"Feature '{feature}' not in path '{docname}'."
65+
need,
66+
"id",
67+
f"Featurepart '{featureparts}' not in path '{docname}' or abbreviation not ok, expected: '{initials}'.",
5168
)

src/extensions/score_metamodel/tests/rst/id_contains_feature/test_id_contains_feature.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@
1313
# *******************************************************************************
1414
#CHECK: id_contains_feature
1515

16-
.. Feature is not in the path of the RST file
17-
#EXPECT: std_wp__test__abcd.id (std_wp__test__abcd): Feature 'test' not in path
16+
.. Feature is deeper in the path of the RST file
17+
.. This is now explicitly allowed
18+
#EXPECT-NOT: std_wp__test__abcd.id (std_wp__test__abcd): Feature 'test' not in path
1819

1920
.. std_wp:: This is a test
2021
:id: std_wp__test__abcd

0 commit comments

Comments
 (0)