10.3 KB496 lines
Blame
1> **Warning**
2>
3> ## THIS IS AN AUTOGENERATED FILE. DO NOT EDIT.
4>
5> ## Please edit the corresponding file in [/packages/mermaid/src/docs/syntax/requirementDiagram.md](../../packages/mermaid/src/docs/syntax/requirementDiagram.md).
6
7# Requirement Diagram
8
9> A Requirement diagram provides a visualization for requirements and their connections, to each other and other documented elements. The modeling specs follow those defined by SysML v1.6.
10
11Rendering requirements is straightforward.
12
13```mermaid-example
14 requirementDiagram
15
16 requirement test_req {
17 id: 1
18 text: the test text.
19 risk: high
20 verifymethod: test
21 }
22
23 element test_entity {
24 type: simulation
25 }
26
27 test_entity - satisfies -> test_req
28```
29
30```mermaid
31 requirementDiagram
32
33 requirement test_req {
34 id: 1
35 text: the test text.
36 risk: high
37 verifymethod: test
38 }
39
40 element test_entity {
41 type: simulation
42 }
43
44 test_entity - satisfies -> test_req
45```
46
47## Syntax
48
49There are three types of components to a requirement diagram: requirement, element, and relationship.
50
51The grammar for defining each is defined below. Words denoted in angle brackets, such as `<word>`, are enumerated keywords that have options elaborated in a table. `user_defined_...` is use in any place where user input is expected.
52
53An important note on user text: all input can be surrounded in quotes or not. For example, both `id: "here is an example"` and `id: here is an example` are both valid. However, users must be careful with unquoted input. The parser will fail if another keyword is detected.
54
55### Requirement
56
57A requirement definition contains a requirement type, name, id, text, risk, and verification method. The syntax follows:
58
59```
60<type> user_defined_name {
61 id: user_defined_id
62 text: user_defined text
63 risk: <risk>
64 verifymethod: <method>
65}
66```
67
68Type, risk, and method are enumerations defined in SysML.
69
70| Keyword | Options |
71| ------------------ | ----------------------------------------------------------------------------------------------------------------------- |
72| Type | requirement, functionalRequirement, interfaceRequirement, performanceRequirement, physicalRequirement, designConstraint |
73| Risk | Low, Medium, High |
74| VerificationMethod | Analysis, Inspection, Test, Demonstration |
75
76### Element
77
78An element definition contains an element name, type, and document reference. These three are all user defined. The element feature is intended to be lightweight but allow requirements to be connected to portions of other documents.
79
80```
81element user_defined_name {
82 type: user_defined_type
83 docref: user_defined_ref
84}
85```
86
87### Markdown Formatting
88
89In places where user defined text is possible (like names, requirement text, element docref, etc.), you can:
90
91- Surround the text in quotes: `"example text"`
92- Use markdown formatting inside quotes: `"**bold text** and *italics*"`
93
94Example:
95
96```mermaid-example
97requirementDiagram
98
99requirement "__test_req__" {
100 id: 1
101 text: "*italicized text* **bold text**"
102 risk: high
103 verifymethod: test
104}
105```
106
107```mermaid
108requirementDiagram
109
110requirement "__test_req__" {
111 id: 1
112 text: "*italicized text* **bold text**"
113 risk: high
114 verifymethod: test
115}
116```
117
118### Relationship
119
120Relationships are comprised of a source node, destination node, and relationship type.
121
122Each follows the definition format of
123
124```
125{name of source} - <type> -> {name of destination}
126```
127
128or
129
130```
131{name of destination} <- <type> - {name of source}
132```
133
134"name of source" and "name of destination" should be names of requirement or element nodes defined elsewhere.
135
136A relationship type can be one of contains, copies, derives, satisfies, verifies, refines, or traces.
137
138Each relationship is labeled in the diagram.
139
140## Larger Example
141
142This example uses all features of the diagram.
143
144```mermaid-example
145 requirementDiagram
146
147 requirement test_req {
148 id: 1
149 text: the test text.
150 risk: high
151 verifymethod: test
152 }
153
154 functionalRequirement test_req2 {
155 id: 1.1
156 text: the second test text.
157 risk: low
158 verifymethod: inspection
159 }
160
161 performanceRequirement test_req3 {
162 id: 1.2
163 text: the third test text.
164 risk: medium
165 verifymethod: demonstration
166 }
167
168 interfaceRequirement test_req4 {
169 id: 1.2.1
170 text: the fourth test text.
171 risk: medium
172 verifymethod: analysis
173 }
174
175 physicalRequirement test_req5 {
176 id: 1.2.2
177 text: the fifth test text.
178 risk: medium
179 verifymethod: analysis
180 }
181
182 designConstraint test_req6 {
183 id: 1.2.3
184 text: the sixth test text.
185 risk: medium
186 verifymethod: analysis
187 }
188
189 element test_entity {
190 type: simulation
191 }
192
193 element test_entity2 {
194 type: word doc
195 docRef: reqs/test_entity
196 }
197
198 element test_entity3 {
199 type: "test suite"
200 docRef: github.com/all_the_tests
201 }
202
203
204 test_entity - satisfies -> test_req2
205 test_req - traces -> test_req2
206 test_req - contains -> test_req3
207 test_req3 - contains -> test_req4
208 test_req4 - derives -> test_req5
209 test_req5 - refines -> test_req6
210 test_entity3 - verifies -> test_req5
211 test_req <- copies - test_entity2
212```
213
214```mermaid
215 requirementDiagram
216
217 requirement test_req {
218 id: 1
219 text: the test text.
220 risk: high
221 verifymethod: test
222 }
223
224 functionalRequirement test_req2 {
225 id: 1.1
226 text: the second test text.
227 risk: low
228 verifymethod: inspection
229 }
230
231 performanceRequirement test_req3 {
232 id: 1.2
233 text: the third test text.
234 risk: medium
235 verifymethod: demonstration
236 }
237
238 interfaceRequirement test_req4 {
239 id: 1.2.1
240 text: the fourth test text.
241 risk: medium
242 verifymethod: analysis
243 }
244
245 physicalRequirement test_req5 {
246 id: 1.2.2
247 text: the fifth test text.
248 risk: medium
249 verifymethod: analysis
250 }
251
252 designConstraint test_req6 {
253 id: 1.2.3
254 text: the sixth test text.
255 risk: medium
256 verifymethod: analysis
257 }
258
259 element test_entity {
260 type: simulation
261 }
262
263 element test_entity2 {
264 type: word doc
265 docRef: reqs/test_entity
266 }
267
268 element test_entity3 {
269 type: "test suite"
270 docRef: github.com/all_the_tests
271 }
272
273
274 test_entity - satisfies -> test_req2
275 test_req - traces -> test_req2
276 test_req - contains -> test_req3
277 test_req3 - contains -> test_req4
278 test_req4 - derives -> test_req5
279 test_req5 - refines -> test_req6
280 test_entity3 - verifies -> test_req5
281 test_req <- copies - test_entity2
282```
283
284## Direction
285
286The diagram can be rendered in different directions using the `direction` statement. Valid values are:
287
288- `TB` - Top to Bottom (default)
289- `BT` - Bottom to Top
290- `LR` - Left to Right
291- `RL` - Right to Left
292
293Example:
294
295```mermaid-example
296requirementDiagram
297
298direction LR
299
300requirement test_req {
301 id: 1
302 text: the test text.
303 risk: high
304 verifymethod: test
305}
306
307element test_entity {
308 type: simulation
309}
310
311test_entity - satisfies -> test_req
312```
313
314```mermaid
315requirementDiagram
316
317direction LR
318
319requirement test_req {
320 id: 1
321 text: the test text.
322 risk: high
323 verifymethod: test
324}
325
326element test_entity {
327 type: simulation
328}
329
330test_entity - satisfies -> test_req
331```
332
333## Styling
334
335Requirements and elements can be styled using direct styling or classes. As a rule of thumb, when applying styles or classes, it accepts a list of requirement or element names and a list of class names allowing multiple assignments at a time (The only exception is the shorthand syntax `:::` which can assign multiple classes but only to one requirement or element at a time).
336
337### Direct Styling
338
339Use the `style` keyword to apply CSS styles directly:
340
341```mermaid-example
342requirementDiagram
343
344requirement test_req {
345 id: 1
346 text: styling example
347 risk: low
348 verifymethod: test
349}
350
351element test_entity {
352 type: simulation
353}
354
355style test_req fill:#ffa,stroke:#000, color: green
356style test_entity fill:#f9f,stroke:#333, color: blue
357```
358
359```mermaid
360requirementDiagram
361
362requirement test_req {
363 id: 1
364 text: styling example
365 risk: low
366 verifymethod: test
367}
368
369element test_entity {
370 type: simulation
371}
372
373style test_req fill:#ffa,stroke:#000, color: green
374style test_entity fill:#f9f,stroke:#333, color: blue
375```
376
377### Class Definitions
378
379Define reusable styles using `classDef`:
380
381```mermaid-example
382requirementDiagram
383
384requirement test_req {
385 id: 1
386 text: "class styling example"
387 risk: low
388 verifymethod: test
389}
390
391element test_entity {
392 type: simulation
393}
394
395classDef important fill:#f96,stroke:#333,stroke-width:4px
396classDef test fill:#ffa,stroke:#000
397```
398
399```mermaid
400requirementDiagram
401
402requirement test_req {
403 id: 1
404 text: "class styling example"
405 risk: low
406 verifymethod: test
407}
408
409element test_entity {
410 type: simulation
411}
412
413classDef important fill:#f96,stroke:#333,stroke-width:4px
414classDef test fill:#ffa,stroke:#000
415```
416
417### Default class
418
419If a class is named default it will be applied to all nodes. Specific styles and classes should be defined afterwards to override the applied default styling.
420
421```
422classDef default fill:#f9f,stroke:#333,stroke-width:4px;
423```
424
425### Applying Classes
426
427Classes can be applied in two ways:
428
4291. Using the `class` keyword:
430
431```
432class test_req,test_entity important
433```
434
4352. Using the shorthand syntax with `:::` either during the definition or afterwards:
436
437```
438requirement test_req:::important {
439 id: 1
440 text: class styling example
441 risk: low
442 verifymethod: test
443}
444```
445
446```
447element test_elem {
448}
449
450test_elem:::myClass
451```
452
453### Combined Example
454
455```mermaid-example
456requirementDiagram
457
458requirement test_req:::important {
459 id: 1
460 text: "class styling example"
461 risk: low
462 verifymethod: test
463}
464
465element test_entity {
466 type: simulation
467}
468
469classDef important font-weight:bold
470
471class test_entity important
472style test_entity fill:#f9f,stroke:#333
473```
474
475```mermaid
476requirementDiagram
477
478requirement test_req:::important {
479 id: 1
480 text: "class styling example"
481 risk: low
482 verifymethod: test
483}
484
485element test_entity {
486 type: simulation
487}
488
489classDef important font-weight:bold
490
491class test_entity important
492style test_entity fill:#f9f,stroke:#333
493```
494
495<!--- cspell:ignore reqs --->
496