Examples for Tickets
Here I collect examples to Sphinx-Needs tickets.
Coloring of needs depending of incoming links
https://github.com/useblocks/sphinx-needs/issues/1457
Question:
I would like to set the style of a need, if an incoming link is available. I’ve tried it by using needs_global_options
needs_global_options = {
"style": {
"predicates": [
("len(links_back)==0", "red_bar"),
("len(links_back)>0", "green_bar"),
]
}
}
With this option all requirements have the red bar, even there is an incoming link.
Another idea was to use dynamic functions, but the incoming links are not available as written in the documentation: https://sphinx-needs.readthedocs.io/en/latest/dynamic_functions.html#incoming-links
I have imported system requirements and I would like to see fast, which requirement is already linked by a color bar. Any ideas or suggestions how to realize this?
Answer:
Here is an implementation of the feature.
It is not covering the needs_global_options, but to do so, is straight forward. So I focused to set it manually in the following needs.
Example 1
.. need:: need red if linked
:id: N_NEED_RED_IF_LINKED
:style: red_bar
:tags: [[check_need_linked()]]
:status: [[check_need_linked('links', 'satisfies')]]
.. need:: link to need
:id: N_LINK_TO_RED_NEED
:links: N_NEED_RED_IF_LINKED
.. need:: need not linked
:id: N_NEED_NOT_LINKED
:tags: [[check_need_linked()]]
:status: [[check_need_linked('links', 'satisfies')]]
needextract shall support include directive
https://github.com/useblocks/sphinx-needs/issues/1624
Example 2
.. need:: need with include
:id: N__NEED_INCLUDE
<Now follows an include.>
.. include:: include.rst.inc
<After the include.>
.. needextract::
:filter: "N__NEED_INCLUDE" == id
<Now follows an include.> <your text here> <After the include.> |
<Now follows an include.> <your text here> <After the include.> |