Skip to content

Commit 4dc3830

Browse files
Add content check
1 parent 5647766 commit 4dc3830

4 files changed

Lines changed: 120 additions & 121 deletions

File tree

src/extensions/score_metamodel/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,8 @@ def load_metamodel_data():
173173
# Store mandatory_options and optional_options directly as a dict
174174
mandatory_options = directive_data.get("mandatory_options", {})
175175
one_type["mandatory_options"] = mandatory_options
176+
tags = directive_data.get("tags", [])
177+
one_type["tags"] = tags
176178

177179
optional_options = directive_data.get("optional_options", {})
178180
optional_options.update(global_base_options_optional_opts)

src/extensions/score_metamodel/checks/check_options.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
# *******************************************************************************
1313
import re
1414
from collections.abc import Generator
15+
from typing import cast
16+
from pprint import pprint
1517

1618
from score_metamodel import (
1719
CheckLogger,
@@ -26,7 +28,7 @@
2628
CheckingDictType = dict[str, list[FieldCheck]]
2729

2830

29-
def get_need_type(needs_types: list[NeedType], directive: str):
31+
def get_need_type(needs_types: list[NeedType], directive: str)-> NeedType:
3032
for need_type in needs_types:
3133
assert isinstance(need_type, dict), need_type
3234
if need_type["directive"] == directive:
@@ -95,6 +97,21 @@ def remove_prefix(word: str, prefixes: list[str]) -> str:
9597
)
9698

9799

100+
# req-Id: tool_req__docs_common_attr_description
101+
@local_check
102+
def check_content(
103+
app: Sphinx,
104+
need: NeedsInfoType,
105+
log: CheckLogger,
106+
):
107+
108+
need_options = get_need_type(app.config.needs_types, need["type"])
109+
if any(tag in need_options.get("tags", []) for tag in ["architecture_elements", "requirement"]):
110+
# HINT: Seems that falsey evaluation of content fails without bool conversion.
111+
if not bool(need["content"]):
112+
msg = f"Need has no content. Content is mandatory for needs of type {need['type']}"
113+
log.warning_for_need(need, msg)
114+
98115
# req-#id: gd_req__req__attr_type
99116
# req-#id: gd_req__requirements_attr_security
100117
# req-#id: gd_req__req__attr_safety

src/extensions/score_metamodel/metamodel.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ needs_types:
7373
status: ^(valid)$
7474
optional_links:
7575
links: ^.*$
76+
tags:
77+
- requirement
7678

7779
std_wp:
7880
title: Standard Work Product
@@ -111,6 +113,8 @@ needs_types:
111113
complies: ^std_req__(iso26262|isosae21434|isopas8926|aspice_40)__.*$
112114
# req-Id: tool_req__docs_req_link_satisfies_allowed
113115
satisfies: ^wf__.*$
116+
tags:
117+
- requirement
114118

115119
gd_temp:
116120
title: Process Template
@@ -229,6 +233,8 @@ needs_types:
229233
# req-Id: tool_req__docs_req_attr_testcov
230234
testcovered: ^(YES|NO)$
231235
hash: ^.*$
236+
tags:
237+
- requirement
232238

233239
# req-Id: tool_req__docs_req_types
234240
feat_req:
@@ -253,6 +259,8 @@ needs_types:
253259
# req-Id: tool_req__docs_req_attr_testcov
254260
testcovered: ^(YES|NO)$
255261
hash: ^.*$
262+
tags:
263+
- requirement
256264

257265
# req-Id: tool_req__docs_req_types
258266
comp_req:
@@ -276,6 +284,8 @@ needs_types:
276284
# req-Id: tool_req__docs_req_attr_testcov
277285
testcovered: ^(YES|NO)$
278286
hash: ^.*$
287+
tags:
288+
- requirement
279289

280290
# req-Id: tool_req__docs_req_types
281291
tool_req:
@@ -303,6 +313,8 @@ needs_types:
303313
implemented: ^(YES|PARTIAL|NO)$
304314
parent_covered: ^.*$
305315
parent_has_problem: ^.*$
316+
tags:
317+
- requirement
306318

307319
# req-Id: tool_req__docs_req_types
308320
aou_req:
@@ -325,6 +337,8 @@ needs_types:
325337
hash: ^.*$
326338
optional_links:
327339
mitigates: ^.*$
340+
tags:
341+
- requirement
328342

329343

330344
# Architecture
@@ -342,6 +356,8 @@ needs_types:
342356
includes: ^logic_arc_int(_op)*__.+$
343357
optional_links:
344358
fulfils: ^feat_req__.+$
359+
tags:
360+
- architecture_element
345361

346362
feat_arc_dyn:
347363
title: Feature Architecture Dynamic View
@@ -369,6 +385,8 @@ needs_types:
369385
optional_links:
370386
includes: ^logic_arc_int_op__.+$
371387
fulfils: ^comp_req__.+$
388+
tags:
389+
- architecture_element
372390

373391
logic_arc_int_op:
374392
title: Logical Architecture Interface Operation
@@ -416,6 +434,8 @@ needs_types:
416434
includes: ^comp_arc_sta__.+$
417435
uses: ^real_arc_int(_op)*__.+$
418436
fulfils: ^comp_req__.+$
437+
tags:
438+
- architecture_element
419439

420440
comp_arc_dyn:
421441
title: Component Architecture Dynamic View
@@ -429,6 +449,8 @@ needs_types:
429449
status: ^(valid|invalid)$
430450
optional_links:
431451
fulfils: ^comp_req__.+$
452+
tags:
453+
- architecture_element
432454

433455
real_arc_int:
434456
title: Component Architecture Interfaces
@@ -443,6 +465,8 @@ needs_types:
443465
language: ^(cpp|rust)$
444466
optional_links:
445467
fulfils: ^comp_req__.+$
468+
tags:
469+
- architecture_element
446470

447471
real_arc_int_op:
448472
title: Component Architecture Interface Operation
@@ -458,6 +482,8 @@ needs_types:
458482
included_by: ^real_arc_int__.+$
459483
optional_links:
460484
implements: ^logic_arc_int_op__.+$
485+
tags:
486+
- architecture_element
461487

462488
review_header:
463489
prefix: review__header

0 commit comments

Comments
 (0)