Sphinx-Needs: Import Needs

Import a Need with needimport

Documentation: How-to import needs with needimport.

Example 1: How-to import a Need.

.. needimport:: example_needs.json
   :id_prefix: imp_
   :tags: imported
   :template: extend_template

We do use here a template, to make the reject_reason availalbe to the content of the need. The reject_reason is been set in the needextend in the next chapter.

In the template extend_template we access to the reject reason:

Listing 8 file extend_template.need
1{# Place the original content here #}
2{{content}}
3
4
5**Reject Reason added during needimport:**
6{{reject_reason}}
7
8**Reject Reason copied with dynamic function:**
9:ndf:`copy('reject_reason', '{{id}}')`

You can find the documenation of the option template for needimport in needimport customization.

You can find the documenation of the option template for need in need template.

You can find the documentation of dynamic functions and the copy function especially in dynamic functions.

How-to change a imported need with needextend

Documentation: How-to extend needs with needextend.

Example 2: How-to extend a Need.

.. needextend:: imp_test_item
   :status: implemented
   :reject_reason:
      | Here I add a multi line reject reason.
      | First line
      | Second line

Challanges

The issue with needextend is, how to ensure the final output is correct. Here it is often necassary to protect attributes for changes via needextend via needs_warnings. See Monitoring modifications.