Skip to content

Commit 9ec811a

Browse files
authored
Merge pull request #53 from DrMarkusVoss/52-add-requirements-in-docs-as-code-format-with-traceability-to-architecture-elements
52 add requirements in docs as code format with traceability to architecture elements
2 parents 1a8cfa1 + 38e3d0c commit 9ec811a

39 files changed

+1117
-162
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
python-version: 3.8
1616
- name: install dependencies
1717
run: |
18-
pip install flake8 pytest requests
18+
pip install flake8 pytest requests pyyaml
1919
pip install .
2020
- name: run tests
2121
run:

Examples_Reqs.md

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
# `pumla` WeatherStation examples for requirements in docs-as-code style
2+
These are examples from the `./test/examples/WeatherStation` section. You find the
3+
source code of the .puml and .yaml files that form the example model repository
4+
there. In order to get the example running on your computer, you need
5+
to run first `pumla init`, then `pumla update`" in the examples directory,
6+
because the paths in the model repo file (./test/examples/WeatherStation/reqsrepo_json.puml)
7+
need to be updated to the directory structure on your computer. Currently
8+
the model repo file has the paths from the structure as I have it on my
9+
machine. You can't run the pumla update from the main path of pumla, as
10+
it is setup to update the architecture model repo of the pumla tool itself.
11+
The examples section will be ignored from the top level. So you have to go
12+
down to the examples and call the pumla update from that directory.
13+
14+
If you are changing the contents of the examples to play around, in order for a
15+
change to become alive, you need to call `pumla update` again. cd
16+
17+
## E#0: Creating Re-usable Requirements
18+
Other than with architecture elements, in `pumla` you write the requirements in YAML and not
19+
with PlantUML-conformant PUMLA-macros. Reason for that is, that requirements typically have
20+
more textual relevant information and a plain table structure with potentially quite a lot
21+
attributes that you want to have easy access on. Table-like data structures can be handled by PlantUML
22+
with JSON representations on diagrams. But when it comes to writing the text files, YAML is easier
23+
to use for requirements documentation than JSON. Therefore, `pumla` parses the YAML files and
24+
puts them into the requirements repository in JSON format, so that you can put the requirements
25+
easily onto diagrams.
26+
27+
See here an example for the definition of a re-usable requirement using by describing
28+
it in YAML:
29+
[./test/examples/WeatherStation/req.yaml](test/examples/WeatherStation/req.yaml)
30+
31+
```
32+
#PUMLARR
33+
- type: Requirement
34+
alias: REQ_WS1
35+
status: decided
36+
derived_from:
37+
taggedvalues:
38+
- tag: "Vendor"
39+
values:
40+
- A Inc.
41+
- C Ltd.
42+
- tag: "Variant"
43+
values: [SysA, SysB]
44+
content:
45+
This is a requirement towards my Weather Station. The Weather Station shall
46+
be able to measure the temperature.
47+
48+
- type: Requirement
49+
alias: REQ_WS2
50+
status: new
51+
derived_from:
52+
content:
53+
This is another requirement. The Weather Station housing shall be blue.
54+
55+
...
56+
```
57+
58+
59+
## E#1: Show all Requirements
60+
### E#1.1: All Requirements, full attributes, no trace
61+
See, how all requirements are put onto a diagram using the "`PUMLAPutAllReqs()`" macro for that
62+
purpose.
63+
64+
[./test/examples/WeatherStation/exampleAllReqs.puml](test/examples/WeatherStation/exampleAllReqs.puml)
65+
66+
![](test/examples/WeatherStation/pics/exampleAllReqs.png)
67+
68+
### E#1.2: All requirements, brief subset of attributes, showing the trace
69+
In this example, all requirements are layed out on the diagram with a brief description. Furthermore,
70+
the trace between the requirements is exposed. All with just one `pumla` macro call.
71+
72+
[./test/examples/WeatherStation/exampleAllReqsBrief.puml](test/examples/WeatherStation/exampleAllReqsBrief.puml)
73+
74+
![](test/examples/WeatherStation/pics/exampleAllReqsBrief.png)
75+
### E#1.3: Overview of all requirements (Cheat Sheet)
76+
See here, how with one `pumla` macro `PUMLAPutAllReqsTable()` and overview table is put onto
77+
the diagram, counting the requirements and showing in which files they are implemented.
78+
79+
[./test/examples/WeatherStation/exampleReqCheatSheet.puml](test/examples/WeatherStation/exampleReqCheatSheet.puml)
80+
81+
![](test/examples/WeatherStation/pics/exampleReqCheatSheet.png)
82+
83+
## E#2: Put single requirements onto a diagram
84+
Here is an example where two requirements are put onto a diagram, one with a reduced subset of
85+
attributes.
86+
87+
[./test/examples/WeatherStation/exampleSingleReqs.puml](test/examples/WeatherStation/exampleSingleReqs.puml)
88+
89+
![](test/examples/WeatherStation/pics/exampleSingleReqs.png)
90+
91+
## E#3: Show the requirements trace
92+
This example shows how for a given requirement the requirements trace is created as a diagram with just one
93+
`pumla` macro call. You can
94+
argue that the example might be bad for a requirements breakdown, but it is here to show the principle
95+
and possibilities of pumla, not to show examples of perfect requirements engineering.
96+
97+
[./test/examples/WeatherStation/exampleReqTrace.puml](test/examples/WeatherStation/exampleReqTrace.puml)
98+
99+
![](test/examples/WeatherStation/pics/exampleReqTrace.png)

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ Therefore, in order to enable systematic re-use for architecture models with Pla
2424
`pumla` is intended to be an extension around PlantUML to organize and enable
2525
this systematic re-use.
2626

27+
Furthermore, `pumla` now also supports requirements management in a docs-as-code manner. You can
28+
store your requirements in YAML text files in your git repo along with code and architecture, and
29+
also re-use the requirements definitions on diagrams, mixing it with architecture elements to show
30+
which element implements which requirement, but also create PlantUML diagrams showing a traceability
31+
graph.
32+
2733
### Goals, Use Cases & Principles
2834
<details>
2935
<summary>click to expand!</summary>
@@ -40,6 +46,8 @@ this systematic re-use.
4046
sequence diagrams with deployment diagrams.
4147
- Create an arc42 architecture documentation based on common PlantUML description patterns
4248
with almost no effort.
49+
- requirements in docs-as-code style that can be used in diagram explaining how they are implemented
50+
in the architecture
4351

4452
---
4553

@@ -209,6 +217,12 @@ to an overview and description an that example:
209217

210218
[follow this link to the C4 example](./test/examples/C4example/pumlaC4Example.md)
211219

220+
### Examples for managing and using requirements
221+
This is a set of examples showing how to use `pumla` for requirements management.
222+
223+
[follow this link to the requirements-as-code examples](./Examples_Reqs.md)
224+
225+
212226
### Working with the examples
213227
In order to play around with the previously mentioned examples, you need to initialise the examples
214228
repository to work on your system. To do that, take the following steps starting in the pumla

arch/pumla_architecture.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,42 @@ See the following image to get an idea of the big picture:
5656

5757
![](./00_pics/overview_internalstructure.png)
5858

59+
## `pumla` Requirements as Code approach
60+
In systems engineering, architecture typically is highly connected to requirements engineering. The requirements
61+
are the base to tell you what is expected from the system. Tests are written against requirements (or are a means
62+
to describe a requirement). The traceability from architecture elements to requirements is crucial for knowing which
63+
part of the implementation is intended to do what and why at all. When product variants come into play, the
64+
start point of the variance is typically already on the requirements. So, not every product variant needs to have
65+
each requirement fulfilled.
5966

67+
Therefore, bringing requirements engineering and architecture together into one docs-as-code/models-as-code approach
68+
has the potential to ease the implementation of traceability and therefore simplify systems engineering in software intense
69+
systems.
70+
71+
### Design Principles & Ideas
72+
- [ ] requirements as YAML text: YAML better editable and readable for req. documentation as text than JSON
73+
- transform internally to JSON to be able to use contents with PlantUML Preprocessing
74+
- [ ] traceability: in docs only one-directional trace from the lower requirement to the higher requirement (where it has been derived from)
75+
- [ ] generate bi-directional traceability in „pumla update“ step. create a reqrepo_json.puml file with all collected req from whole project
76+
- [ ] have for each req „derived to“ and „derived from“ as keys. „derived to“ is created during the update step
77+
- [ ] „derived from“ is documented as key in the YAML files
78+
- [ ] traceability to architecture artifacts. which arch element realizes a certain requirement.
79+
- [ ] realizes is a part of the architecture model, not of the requirement.
80+
- [ ] requirements are independent of their implementation
81+
- [ ] a requirement belongs to a scope; within the scope it gets broken down
82+
- [ ] requirements can be structured in features.
83+
- [ ] req that belong to a feature can have a loose or high coupling
84+
- [ ] loose coupling will be realized with the „child injection“ mechanism
85+
- [ ] high coupling by a feature table that directly names reqs that belong to the feature
86+
- [ ] feature structure is kind of an architectural step with a composite breakdown view
87+
- [ ] automatic scope alignment if the req doc is next a single RUA arch spec? or manual scope connection? do we need the scope at all?
88+
- [ ] PUMLA macros to create diagrams that show all requirements fulfilled by a certain architecture element
89+
- [ ] PUMLA macros to create feature structure & breakdown views
90+
- [ ] PUMLA macros to create traceability views
91+
- [ ] status „aligned“, „new“, „decided“
92+
- [ ] whether it is „realized/implemented“ will be decided with the respective test passing
93+
- [ ] „rejected“ can be a commit message for deleting the req
94+
- [ ] new: indicated a new unreviewed requirement which is there but not yet considered somewhere
95+
- [ ] aligned: requirement is reviewed and aligned to be usable, but not yet decided how to be realized
96+
- [ ] decided: there is a design decision done on to where and how the requirement shall be realized.
97+

pumla_UsersGuide.md

Lines changed: 131 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -88,22 +88,26 @@ you can name these in a `pumla_blacklist.txt` file. You can also have comments i
8888
blacklist file using `#` as first character of the line. But comments must be
8989
standalone lines, you cannot put a comment behind a path or filename.
9090
The .puml files found will be parsed
91-
and if they are pumla files, their relevant content will be extracted and stored in the
91+
and if they are pumla architecture files, their relevant content will be extracted and stored in the
9292
`modelrepo_json.puml` file or the given
93-
filename. Each call will overwrite the existing `modelrepo_json.puml`
93+
filename. For docs-as-code requirements files, the relevant content will be extracted and stored in the
94+
`reqsrepo_json.puml` file.
95+
Each call will overwrite the existing `modelrepo_json.puml` and `reqsrepo_json.puml`
9496
file, therefore they should not be modified by hand,
9597
because changes will get lost. These repository files are the basis for the
9698
PlantUML extension macros. The macros help to get data out of these repositories
9799
and thereby re-use the once defined model elements and diagrams in a structured
98100
way.
99101

100-
The generated `modelrepo_json.puml` should also not be checked-in into a version
102+
The generated `modelrepo_json.puml` as well as the `reqsrepo_json.puml`
103+
should also not be checked-in into a version
101104
control system, as it contains absolute paths that are different on every computer
102105
where the source code is checked out. Therefore, after a fresh checkout/clone of
103106
a source code repository, first thing to do is call `pumla init` to create a link
104107
to the pumla macros to access the model repository JSON database, the second
105108
thing to do is call `pumla update` to scan the source code repository for pumla
106-
files and create the `modelrepo_json.puml` file. After that you can use the
109+
files and create the `modelrepo_json.puml` and `reqsrepo_json.puml` file.
110+
After that you can use the
107111
model repository to create diagrams and are able to use all the macro commands
108112
explained in the following chapters.
109113

@@ -127,11 +131,19 @@ is put to the command line output.
127131
Called without any other argument, pumla writes out to the console a
128132
list of all `.puml` files that are `pumla` files (marked with either `'PUMLAMR`
129133
(PUMLA-ModelRepo) or `'PUMLADR` (PUMLA-DiagramRepo) in the first line of the file).
134+
Requirements are described in YAML files (`.yaml`) and will therefore not
135+
be shown by this command, as they are not standalone PlantUML-compliant files.
130136

131137
### `pumla elements`
132138
Writes out to the console all `pumla` model elements and diagrams of
133139
the model repository and diagram repository, with all their relevant
134-
attributes.
140+
attributes. This does not include requirements, for that we have the
141+
call described next.
142+
143+
### `pumla reqs` - not yet implemented
144+
Writes out to the console all `pumla` requirements elements and diagrams of
145+
the model repository and diagram repository, with all their relevant
146+
attributes.
135147

136148
### `pumla getjson <subcommand>`
137149
Prints out a JSON data structure containing the request elements (by subcommand).
@@ -183,14 +195,19 @@ This comment marks the file as a re-usable asset of a dynamic behaviour
183195
element description. In a file marked like that, only the dynamic aspect
184196
should be modelled, by e.g. a sequence, state or activity diagram.
185197

198+
### `'PUMLARR`
199+
This comment put into the first line of a `.yaml` file marks the file
200+
as `pumla` requirement element description that shall be part of the re-usable
201+
requirements repository.
202+
186203
---
187204

188205
## Extension Macros
189206
The following macros (that are PlantUML unquoted functions and procedures) can be
190207
used within each PlantUML file by including `pumla_macros.puml`. They are the
191208
user "API" of `pumla`.
192209

193-
## Creating Re-usable Elements
210+
## Creating Re-usable Model Elements
194211

195212
### `PUMLAReUsableAsset($name : string, $alias : string, $type : string, $stereotypes : string (optinal)) {...}`
196213
Creates a re-usable asset (RUA). The asset can be of any PlantUML type, like class, component, node, rectangle, ...
@@ -313,7 +330,7 @@ you manage your architecture relations and artefacts.
313330
Similar to previous, but instead of information about file path and file name you
314331
get the list of tagged values that are attached to each of the connections.
315332

316-
## Putting Re-usable Elements onto Diagrams
333+
## Putting Re-usable Model Elements onto Diagrams
317334

318335
### `PUMLAPutElement( elem_alias )`
319336
This macro puts the model element with the given alias `elem_alias` onto the diagram.
@@ -504,6 +521,11 @@ as the table cannot be shown within the port element (and would not
504521
make sense). This is the only way to show the tagged value table
505522
of a port.
506523

524+
### `PUMLAPutReqsBreakdownTraceFor($alias)`
525+
Puts the requirement with the given alias onto the diagram and follows
526+
its "derived" breakdown and puts further requirements onto the diagram
527+
that the alias requirement is derived to. It connects the requirements
528+
with a "realization" relation.
507529

508530
## Diagram Filters
509531

@@ -572,6 +594,108 @@ global variable `$PUMVarShowBodyInternals` is true. With this macro, the given a
572594
of which not to show the internals. In order to show internals for that element within the scope of the same diagram
573595
again, the "filter list" has to be resetted with the next macro.
574596

597+
## Creating Re-usable Requirements Elements
598+
599+
### Creating a single re-usable docs-as-code requirement
600+
Requirements are stored in YAML files (`.yaml`) with a file marking `#PUMLARR`in the first line.
601+
Then, within the file, one or more requirements can be described. The requirements are elements
602+
of a YAML list with at least the following attributes:
603+
- alias: the unique short-ID
604+
- type: describing the kind of requirement. Can be set according to needs. Could be "Requirement", "Constraint", ...
605+
- status: also here, the status model is not defined by PUMLA; put status values as you need and like.
606+
- derived_from: the alias of the (parent) requirement where this requirement is derived from.
607+
- content: The text content of the requirement itself.
608+
609+
The following attributes are optional:
610+
- taggedvalues: a list of tag/values pairs, where values is list by itself.
611+
612+
Requirement files can be distributed across the folders in a git repository and therefore be
613+
stored close to the code if wanted. The `pumla update`
614+
command will find each of them, considering the blacklist.
615+
616+
Example:
617+
```
618+
File: req.yaml
619+
620+
#PUMLARR
621+
- type: Requirement
622+
alias: REQ_WS1
623+
status: decided
624+
derived_from:
625+
taggedvalues:
626+
- tag: "Vendor"
627+
values:
628+
- A Inc.
629+
- C Ltd.
630+
- tag: "Variant"
631+
values: [SysA, SysB]
632+
content:
633+
This is a requirement towards my Weather Station. The Weather Station shall
634+
be able to measure the temperature.
635+
636+
- type: Requirement
637+
alias: REQ_WS2
638+
status: new
639+
derived_from:
640+
content:
641+
This is another requirement. The Weather Station housing shall be blue.
642+
```
643+
644+
## Overview on the Requirements Repository of Re-usable Elements
645+
### `PUMLAPutAllReqsTable()`
646+
This macro puts all requirements of the `reqsrepo_json.puml` into a table on the diagram,
647+
with a count of the requirements as well as the files where the requirements are stored in. It
648+
is similar to the `CheatSheets` of the architecture model elements.
649+
650+
### `PUMLAPutReqByCount($count)`
651+
This macro is solely meant for overview purposes, allowing you to quickly step through each
652+
single requirement in the requirements repository by addressing it by its number (`$count`).
653+
654+
Hint: The `$count` shall not be used to address a requirement a certain requirement or put
655+
it onto a real diagram with a real purpose. The numbering in the requirements repository can
656+
change by calling `pumla update`, so that the `$count` may point to another requirement.
657+
In real diagram, requirements shall always be addressed by their unique short-ID, the `alias`.
658+
659+
## Putting Re-usable Requirements Elements onto Diagrams
660+
### `PUMLAPutReq($alias)`
661+
Puts the requirement with the given alias in form of a PlantUML JSON table with all its
662+
attributes onto the diagram.
663+
664+
### `PUMLAPutAllReqs()`
665+
Puts all the requirements of the requirements repository (`reqsrepo_json.puml`) onto the
666+
diagram.
667+
668+
### `PUMLAPutAllReqsWithStatusTable($value)`
669+
Puts all requirements of the requirements repository, where the status has the given `$value`,
670+
onto the diagram.
671+
672+
### `PUMLAPutAllReqsWithTypeTable($value)`
673+
Puts all requirements of the requirements repository, where the type has the given `$value`,
674+
onto the diagram.
675+
676+
### `PUMLAPutReqBrief($alias)`
677+
Puts the requirement with the given alias onto the diagram, focussing on a limited amount of
678+
attributes:
679+
- type
680+
- content
681+
- status
682+
683+
### `PUMLAPutReqAsNote($alias)`
684+
Puts the brief requirement with the given alias wrapped into a PlantUML note onto the diagram.
685+
686+
Hint: This macro can be useful to put the requirement onto diagrams along with classes, components or
687+
dynamic behaviour descriptions.
688+
689+
### `PUMLAPutAllReqsBrief()`
690+
Puts all the requirements of the requirements repository (`reqsrepo_json.puml`) onto the
691+
diagram, but only with the brief set of attributes (see `PUMLAPutReqBrief($alias)`).
692+
693+
## Working with Requirements Traceability
694+
### `PUMLAPutReqsBreakdownTraceFor($alias)`
695+
Puts the trace for a requirement with given alias down on the diagram. Each requirement along the
696+
trace is put with its brief description. The trace is modelled with a "realizes" relation, so pointing
697+
from a derived requirement to a parent requirement where it was derived from.
698+
575699
## Working around some PlantUML limitations
576700

577701
### `PUMLASetAsComponentDiagram()`

pumla_global_cfg.puml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,6 @@
3333
' interaction description).
3434
!$PUMC4UseDynamicExt = %false()
3535

36+
' max character width of requirements
37+
' conent attribute.
38+
!$PUMReqContentWidth = 15

0 commit comments

Comments
 (0)