You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/internals/extensions/metamodel.md
+27-10Lines changed: 27 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
(metamodel)=
2
2
# score_metamodel
3
3
4
-
The `score_metamodel` extension is a core extension/component of the Docs-As-Code.
4
+
The `score_metamodel` extension is a core extension/component of the Docs-As-Code.
5
5
It provides metamodel definitions, validation checks, and project layout management for Sphinx documentation.
6
6
7
7
## Overview
@@ -33,7 +33,7 @@ The extension implements a multi-tier checking system:
33
33
- Require access to the complete needs graph
34
34
- Examples: Link validation, dependency checking, cross-reference verification
35
35
36
-
This extension comes with Docs-As-Code.
36
+
This extension comes with Docs-As-Code.
37
37
Add `score_metamodel` to your extensions in `conf.py`:
38
38
39
39
```python
@@ -44,6 +44,23 @@ extensions = [
44
44
]
45
45
```
46
46
47
+
## need types
48
+
49
+
Each type of needs is defined in the `needs_types` section of the `metamodel.yaml` file. Each need type has attributes, links, tags, and other properties that define its structure and behavior within the documentation system.
50
+
51
+
Each need type is introduced via `<type-name>:` followed by its properties indented under it.
52
+
53
+
Properties:
54
+
-**title**: The title of the need type.
55
+
-**prefix**: A unique prefix used to identify the need type. Default is the type name followed by `__`.
56
+
-**mandatory_options**: A list of mandatory options that must be provided for the need type.
57
+
`id` is worth mentioning as it is automatically included and must be unique. Default is the prefix followed by `[a-z0-9_]`.
58
+
-**optional_options**: A list of optional options that can be provided for the need type.
59
+
-**mandatory_links**: A list of mandatory links to other need types that must be included.
60
+
-**optional_links**: A list of optional links to other need types that can be included.
61
+
-**tags**: A list of tags associated with the need type.
62
+
-**parts**: The number of parts (separated by `__`) within the need ID.
63
+
47
64
## Creating New Validation Checks
48
65
49
66
The extension automatically discovers checks from the `checks/` directory and the metamodel.yaml config. There are several types of checks you can implement:
@@ -73,23 +90,23 @@ needs_types:
73
90
```
74
91
75
92
### 2. Generic Graph Checks (Configuration-Based)
76
-
Generic graph checks are defined in the metamodel.yaml under `graph_checks`.
93
+
Generic graph checks are defined in the metamodel.yaml under `graph_checks`.
77
94
These checks all follow the same structure:
78
95
79
96
```yaml
80
97
<name of the check>:
81
98
needs:
82
-
include: <need1>, <need2> #list of your needs
99
+
include: <need1>, <need2> #list of your needs
83
100
condition: <your condition(s) that need to be fulfilled>
84
101
check:
85
102
<link attribute to check>: <condition to be checked in each need inside the link attribute>
86
-
explanation: <A short sentence that explains what is required to be adhered to. This will be
103
+
explanation: <A short sentence that explains what is required to be adhered to. This will be
87
104
< part of the error message if the check fails>
88
105
```
89
106
90
107
> *Note:* You can also use multiple conditions or negate conditions in either the needs or check part.
91
108
92
-
A complete example might look like so:
109
+
A complete example might look like so:
93
110
94
111
```yaml
95
112
graph_checks:
@@ -101,14 +118,14 @@ graph_checks:
101
118
- safety != QM
102
119
- status == valid
103
120
check:
104
-
implements:
121
+
implements:
105
122
and:
106
123
- safety != QM
107
124
- status == valid
108
125
explanation: An safety architecture element can only link other safety architecture elements.
109
126
```
110
127
111
-
What does this check do?
128
+
What does this check do?
112
129
This check will go through each of the needs mentioned in 'include' that match the condition, and then for every single one of them check the needs that are linked inside the 'implements' attribute. Go inside those needs and check if they also fulfill the condition described.
113
130
If one of them does not fulfill the condition the check fails and will let you know with a warning that it did so.
0 commit comments