File: needarch.rst

package info (click to toggle)
sphinx-needs 5.1.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 11,924 kB
  • sloc: python: 21,132; javascript: 187; makefile: 89; sh: 29; xml: 10
file content (145 lines) | stat: -rw-r--r-- 3,161 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145


.. _needarch:

needarch
========

``needarch`` behaves exactly like :ref:`needuml`, but only works inside a need. It provides also additional exclusive
jinja functions :ref:`needarch_jinja_need` and :ref:`needarch_jinja_import`.

.. need-example::

   .. req:: Requirement arch
      :id: req_arch_001
         
      .. needarch::
         :scale: 50
         :align: center

         Alice -> Bob: Hi Bob
         Bob --> Alice: hi Alice

Jinja context
-------------

The following Jinja functions are **only available** for :ref:`needarch`. 


.. _needarch_jinja_need:

need()
~~~~~~

.. versionadded:: 1.0.3

The `need()` function provides you the need information the :ref:`needarch` is embedded in.

.. need-example::

   .. req:: Req Arch four
      :id: req_arch_004
      :status: draft
      :blocks: req_arch_001

      content.

      .. needarch::
         :scale: 50
         :align: center

         class "{{need().title}}" {
         {{need().status}}
         {% for e in need().blocks %}{{e}}
         {% endfor %}
         }


.. _needarch_jinja_import:

import(need_links_option_name)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This function takes undefined amounts of current need links option names as arguments.

Then it executes :ref:`needuml_jinja_uml` automatically for all links/need_ids defined from the given arguments.

.. need-example::

   .. req:: Req Arch second
      :id: req_arch_002

      content.

   .. req:: Req Arch third
      :id: req_arch_003

      some.

   .. test:: Test Arch
      :id: test_arch_001
      :checks: req_arch_001
      :tests: req_arch_002, req_arch_003

      Test need arch jinja import function.

      .. needarch::
         :scale: 50
         :align: center

         {{import("checks", "tests")}}

.. _needarch_ex_loop:

NeedArch Loop Example
---------------------

.. versionadded:: 1.0.3

NeedArch can detect include loops `(uml('1') -> uml('2') -> uml('3') -> uml('1')`
and can avoid to include an element twice. Maybe this is not always the use case
you have, if so please create an issue and mention this chapter. The algorithm
does detect different parameter sets and does import `uml()` calls with different
:ref:`parameter <needuml_jinja_uml_args>` to the same need.

.. need-example::

   .. comp:: COMP_T_001
      :id: COMP_T_001

      .. needarch::

         {{flow(need().id)}}
         {% if variant == "A" %}
         {{uml('COMP_T_003', variant="A")}}
         usecase {{need().id}}_usecase
         {% else %}
         {{uml('COMP_T_003')}}
         {{uml('COMP_T_003', variant="A")}}
         {% endif %}

   .. comp:: COMP_T_002
      :id: COMP_T_002

      .. needarch::

         {{flow(need().id)}}
         {% if variant == "A" %}
         {{uml('COMP_T_001', variant="A")}}
         usecase {{need().id}}_usecase
         {% else %}
         {{uml('COMP_T_001')}}
         {% endif %}

   .. comp:: COMP_T_003
      :id: COMP_T_003

      .. needarch::

         {{flow(need().id)}}
         {% if variant == "A" %}
         {{uml('COMP_T_002', variant="A")}}
         usecase {{need().id}}_usecase
         {% else %}
         {{uml('COMP_T_002')}}
         {% endif %}