File: list2need.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 (345 lines) | stat: -rw-r--r-- 8,951 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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
.. _list2need:

list2need
=========
.. versionadded:: 1.2.0


``list2need`` allows to create need objects out ouf a given list, where each list entry is used to create
a single need.

It allows to speed up the need-creation process for simple needs, which in most cases just have a title
and limited meta-data.

The content area of the ``list2need`` directive must contain the list only.
The list-structure syntax is Sphinx-Needs specific, but borrowed from markdown.

Meta-data can be set via inline text. See :ref:`list2need_meta_data` for details.

Need-IDs get generated automatically (hash value), if not given.
IDs can be set by the prefix ``(ID)`` in the line. Example: ``(REQ-1)My first requirement``.
This mechanism is the same as the one used by :ref:`need_part`.

Options for the need-objects can be set by adding them like ``((status="open"))``.
For details please see :ref:`list2need_meta_data`.


.. code-block:: rst

   .. list2need::
      :types: req, spec, test
      :presentation: nested
      :delimiter: .

      * Need example on level 1
      * (NEED-002) Another Need example on level 1 with a given ID
        * Sub-Need on level 2 with status option set
        * Another Sub-Need on level 2. Where this sentence will be used
          as content, the first one as title.
          * Sub-Need on level 3. With some rst-syntax support for
            the **content** by :ref:`list2need`


.. list2need::
   :types: req, spec, test
   :presentation: nested
   :delimiter: .

   * Need example on level 1
   * (NEED-002) Another Need example on level 1 with a given ID
     * Sub-Need on level 2 with status option set ((status='open'))
     * Another Sub-Need on level 2. Where this sentence will be used
       as content, the first one as title.
       * Sub-Need on level 3. With some rst-syntax support for
         the **content** by :ref:`list2need`

.. warning::

   There are currently known limitations in the list parser.
   For instance new content lines starting with `*` or `:` may get handled incorrectly.

List structure
--------------
The used list structure was defined to be as small as possible.

Each line starting with a ``*`` will create a new need object.

To define a child-need, add **2 additional whitespaces** infront of ``*``.
This is called the indentation level and each level must have a need-type defined in the ``types`` option.

A line starting **without** a ``*`` will be added to the prior one.
So it can be used to structure longer titles or content, and has no impact on the later representation.

Options
-------

types
~~~~~

List of need-types, which are used for the different list-levels.
As input name the ``directive`` entry from the configuration variable  :ref:`needs_types` is used.

There is no default value and ``types`` must be set.

.. code-block:: rst

      .. list2need::
         :types: feature, function, test

         * Login user
           * Provide login screen
           * Create password hash
             * Recalculate hash and compare



presentation
~~~~~~~~~~~~
Defines how the single Sphinx-Needs objects shall be presented.

:nested: Needs of level 2 are defined in the content of the parent need (level 1) and so on.
:standalone: Each list element gets its own, independent need object. They are not nested.


Default: **nested**

delimiter
~~~~~~~~~

Character to be used as delimiter, to define which part of the list-element shall be used as title, which one as
content.

The first split part is used as title, the rest as content.

Default: **.**

links-down
~~~~~~~~~~
``links-down`` set automatically links between the different levels of the list.

.. code-block:: rst

   .. list2need::
      :types: req, spec, test
      :presentation: standalone
      :links-down: triggers, tests

      * (NEED-A)Login user
        * (NEED-B)Provide login screen
        * (NEED-C)Create password hash
          * (NEED-D)Recalculate hash and compare

``:links-down: triggers, tests`` will set a link from type ``triggers`` from ``NEED-A`` to ``NEED-B`` and ``NEED-C``.
``NEED-C`` will get a link from type ``tests`` to ``NEED-D``.

So links get set from the upper level down to all need-objects on the direct lower level (top-down approach).

The amount of given link-types must be the amount of used levels minus 1.

**Result from the above example**:

.. list2need::
   :types: req, spec, test
   :presentation: standalone
   :links-down: triggers, tests

   * (NEED-A)Login user
     * (NEED-B)Provide login screen
     * (NEED-C)Create password hash
       * (NEED-D)Recalculate hash and compare


tags
~~~~

``tags`` sets tags globally to all items in the list.

.. code-block:: rst

   .. list2need::
      :types: req, spec
      :tags: A, B

      * (NEED-A)Login user
        * (NEED-B)Provide login screen
        * (NEED-C)Create password hash
          * (NEED-D)Recalculate hash and compare


The tags ``A`` and ``B`` are attached to all ``NEED-A``, ``NEED-B``, ``NEED-C`` and ``NEED-D``.


List examples
-------------

List with need-ids
~~~~~~~~~~~~~~~~~~
.. code-block:: rst

   .. list2need::
      :types: feature

      * (LIST2NEED-001) Feature 1
      * (LIST2NEED-002) Feature 2
      * (FEATURE.3) Feature 3

.. list2need::
   :types: feature, req, spec

   * (LIST2NEED-001) Feature 1
   * (LIST2NEED-002) Feature 2
   * (FEATURE.3) Feature 3

Nested lists
~~~~~~~~~~~~
.. code-block:: rst

   .. list2need::
      :types: feature, req, spec, test

      * Level 1
        * Level 2
          * Level 3
            * Level 4

.. list2need::
   :types: feature, req, spec, test

   * Level 1
     * Level 2
       * Level 3
         * Level 4


List with newlines
~~~~~~~~~~~~~~~~~~
.. code-block:: rst

   .. list2need::
      :types: req, spec

      * Level 1 need with newlines.
        With text in a newline to keep it readable

        Empty lines are okay as well.

.. list2need::
   :types: req, spec

   * Level 1 need with newlines.
     With text in a newline to keep it readable

     Empty lines are okay as well.

Simple rst in lists
~~~~~~~~~~~~~~~~~~~

.. code-block:: rst

   .. list2need::
      :types: req, spec

      * Level 1 need with rst. With **some** rst-content for :ref:`list2need`

.. list2need::
   :types: req, spec

   * Level 1 need with rst. With **some** rst-content for :ref:`list2need`

rst-directives in lists
~~~~~~~~~~~~~~~~~~~~~~~

.. code-block:: rst

   .. list2need::
      :types: req, spec

      * Level 1 need and more
        * And a complex sub-need on level 2 with an image-directive.

        .. image:: /_images/logos/sphinx-needs-logo.png
           :align: center
           :width: 20%


.. list2need::
   :types: req, spec

   * Level 1 need and more
     * And a complex sub-need on level 2 with an image-directive.

     .. image:: /_images/logos/sphinx-needs-logo-old.png
        :align: center
        :width: 20%

Lists with need-part support
~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. code-block:: rst

   .. list2need::
      :types: req, spec

      * (LIST2NEED-REQ-1)Requirement which shall get also need-parts.
        Some need-parts:

        First: :np:`(1)The first need-part`

        Second: :np:`(ANOTHER)ANOTHER need-part`

        * And a spec need.
          Lets reference a need-part frm above: :need:`LIST2NEED-REQ-1.1`

.. list2need::
   :types: req, spec

   * (LIST2NEED-REQ-1)Requirement which shall get also need-parts.
     Some need-parts:

     First: :np:`(1)The first need-part`

     Second: :np:`(ANOTHER)ANOTHER need-part`

     * And a spec need.
       Lets reference a need-part frm above: :need:`LIST2NEED-REQ-1.1`

.. _list2need_meta_data:

Set meta-data
~~~~~~~~~~~~~
Meta-data can be set directly in the related line via: ``((status="open"))``.
Or if the amount of option/values is getting too complex, in a second step
by using :ref:`needextend`.

The position of the option-string inside the line is not important.
Multiple options need to be separated by ``,``.
And instead of ``"`` also ``'`` can be used.

.. code-block:: rst

   .. list2need::
      :types: feature, req

      * (EXT-FEATURE-A)Feature A
        * (EXT-REQ-1)Requirement 1. It shall be fast. ((tags="A, fast", style="green_border"))
        * (EXT-REQ-2)Requirement 2. It shall be big. ((tags="A, big", style="red_border"))
      * (EXT-FEATURE-B)Feature B.
        Options are given in next line for readability
        ((status="done", tags="B", links="EXT-FEATURE-A"))

   .. needextend:: EXT-FEATURE-B
      :style: yellow


.. list2need::
   :types: feature, req

   * (EXT-FEATURE-A)Feature A
     * (EXT-REQ-1)Requirement 1. It shall be fast. ((tags="A, fast", style="green_border"))
     * (EXT-REQ-2)Requirement 2. It shall be big. ((tags="A, big", style="red_border"))
   * (EXT-FEATURE-B)Feature B.
     Options are given in next line for readability
     ((status="done", tags="B", links="EXT-FEATURE-A"))

.. needextend:: EXT-FEATURE-B
   :style: yellow