sphinx-needs icon indicating copy to clipboard operation
sphinx-needs copied to clipboard

Jinja support for need content

Open danwos opened this issue 3 years ago • 1 comments

The content of a need should be able to get handled by jinja (incl. all injected Sphinx-Needs data).

The result would be the same as if you are using the Sphinx-Needs template mechanism: https://sphinxcontrib-needs.readthedocs.io/en/latest/directives/need.html#template

But it would be much easier to use, because:

  • No extra template file needs to be created
  • The content is specified only once, so a need-specific template file can be avoided.

Example:

.. req:: My requirement
   :links: REQ_1, REQ_23 
   :jinja_content:  True / False # if set, support gets activated 
 
   This requirement has status: **{{status}}**.
   It links to:
   {% for link in links %}
   *  {{needs[link]["title"]}}    
   {% endfor %}

Jinja support shall not be activated by default, as this can have some strange side-effects if the user uses characters like {{ without knowing that this gets handled by jinja.

The options shall be able to get set via global_option filters as well. Option name must be discussed ;)

danwos avatar Jun 10 '22 09:06 danwos

Thanks for creating the issue.

Maybe as part of this or a separate issue the documentation of Jinja support in sphinx-needs could be extended. A standalone jinja page with references to other jinja related features in sphinx-needs and materials on internet on Jinja. This is a very powerful feature which many sphinx-needs users does not know yet (so it needs some marketing 😄 )

The places I found in Sphinx-Needs until now where Jinja is used are

  • sphinx-needs jinja templates
  • within conf.py as part of needservice - Is this coming from sphinx-needs by the way?
  • needuml

Perhaps there are more.

twodrops avatar Jun 10 '22 10:06 twodrops