sphinx-needs
sphinx-needs copied to clipboard
check filter strings for correctness
If strings don't evaluate to a boolean value this leads to unexpected behavior.
Example rst code (notice the erroneous filter strings below):
Doc
===
.. comp:: Component
:id: C_1
.. req:: requirement 1
:id: R_1
Requirement 1
.. req:: requirement 2
:id: R_2
Requirement 2
need-extract
------------
.. needextract::
:filter: "R_1"
need-table
----------
.. needtable::
:filter: id == "R_1" or "R_2"
With this the rendered output shows an arbitrary number of needs in need-extract and need-table sections.
In a big project this may also lead to error message that don't lead to the root cause and are hard to track down if you have a lot of changes in your git branch.
Error messages look like the following:
src/documentation/<rst_prolog>:5:unknown document:
A better behavior would be to show a clear error message during build and/or the rendered HTML page pointing at the erroneous filter string.
Maybe we need to check the return value of the used eval()
function for the statement.
It must be boolean, otherwise throw an error.
Thought this is already happening, but we need to recheck.