use case
As author, I have a common documentation source for multiple software projects (also called variants).
But my Need objects are project-specific so I also need a project-specific Sphinx build, which contains the relevant needs only.
problem
I have tried using the delete option of a need object. However, its attribute can't be set programmatically (global_option, dynamic functions), so its value must be hard coded, which is just a boolean and therefore can't be project-specific.
proposal
Provide a new need option build-tags, which takes a comma-separated list of strings.
Each element represents a build-tag.
If the Sphinx build is called with the tag-parameter sphinx-build -t my_tag and my_tag is part of build-tags, the related need object is internally created.
If build-tags does not match any given sphinx tag, the need object is deleted/removed from the build and does not show up in the HTML representation or in needtables and co. It just doesn't exist in the internal need-dictionary.
If build-tags is not set (internally none) or contains all, the need object is built under all circumstances, no matter what sphinx-build -t ... is telling.
So the change will be backward-compatible, as this is the case for all current docs.
Mapping
In bigger projects, the amount of build-tags, which are often used as feature flags, can be huge. To reduce the usage of -t my_tag in a sphinx-build call, a mapping shall be allowed.
Provide needs_build_mapping for conf.py
Example:
needs_build_mapping = {
"my_tag": ["feature_A", "feature_D"],
"another_tag": ["delete", "do_not_show"],
...
}
needs_build_mapping is a dictionary, where the key represents the sphinx tag from sphinx-build -t ....
The value is a list of strings, where each element can be used inside build-tags of a need object.
If sphinx-build -t my_tag is in the keys of needs_build_mapping, all elements are set internally as tag as well.
So in our example, the list of currently active build tags would be my_tag, feature_A, feature_D.
If one of these is used by build-tags, the related need gets not removed.
fast tagging
In some cases, a single need object shall get "activated" or "removed".
To support a fast, single need object related build tagging, the Need-ID can be also provided as build-tag. Example sphinx-build -t my_tag -t REQ_001.
This allows the steering of specific needs without setting build-tags to a just need-specific value.
drawbacks/open points
- There is no logic in
build-tags. One positive match is enough to take the need into account.
No and or negation support.
- This still does not support
global_options or dynamic functions.
use case source
The SCORE project does a similar, internal implementation of this:
eclipse-score/score#217
They are (miss)using hide to get the same result and do some nasty monkey-patching ;)
We should support them by providing this kind of feature.
Full example
index.rst
.. req:: My Requirement for Login
:id: REQ_LOGIN
:build-tags: login
Some content
.. req:: My Requirement for Printing
:id: REQ_PRINT
:build-tags: export
Some content
.. req:: My Requirement for Design
:id: REQ_DESIGN
Some content
.. needtable::
conf.py
needs_build_mapping = {
"security": ["login", "roles", "encryption", "monitoring"]
}
Call: sphinx-build -b html . _build/html
Result: REQ_DESIGN is part of the docs
Call: sphinx-build -b html -t security . _build/html
Result: REQ_DESIGN, REQ_LOGIN are part of the docs
Call: sphinx-build -b html -t security -t REQ_PRINT . _build/html
Result: REQ_DESIGN, REQ_LOGIN, REQ_PRINT are part of the docs
use case
As author, I have a common documentation source for multiple software projects (also called variants).
But my Need objects are project-specific so I also need a project-specific Sphinx build, which contains the relevant needs only.
problem
I have tried using the delete option of a need object. However, its attribute can't be set programmatically (global_option, dynamic functions), so its value must be hard coded, which is just a boolean and therefore can't be project-specific.
proposal
Provide a new need option
build-tags, which takes a comma-separated list of strings.Each element represents a build-tag.
If the Sphinx build is called with the tag-parameter
sphinx-build -t my_tagandmy_tagis part ofbuild-tags, the related need object is internally created.If
build-tagsdoes not match any given sphinx tag, the need object is deleted/removed from the build and does not show up in the HTML representation or in needtables and co. It just doesn't exist in the internal need-dictionary.If
build-tagsis not set (internallynone) or containsall, the need object is built under all circumstances, no matter whatsphinx-build -t ...is telling.So the change will be backward-compatible, as this is the case for all current docs.
Mapping
In bigger projects, the amount of build-tags, which are often used as feature flags, can be huge. To reduce the usage of
-t my_tagin asphinx-buildcall, a mapping shall be allowed.Provide
needs_build_mappingforconf.pyExample:
needs_build_mappingis a dictionary, where thekeyrepresents the sphinx tag fromsphinx-build -t ....The
valueis a list of strings, where each element can be used insidebuild-tagsof a need object.If
sphinx-build -t my_tagis in the keys ofneeds_build_mapping, all elements are set internally as tag as well.So in our example, the list of currently active build tags would be
my_tag, feature_A, feature_D.If one of these is used by
build-tags, the related need gets not removed.fast tagging
In some cases, a single need object shall get "activated" or "removed".
To support a fast, single need object related build tagging, the Need-ID can be also provided as build-tag. Example
sphinx-build -t my_tag -t REQ_001.This allows the steering of specific needs without setting
build-tagsto a just need-specific value.drawbacks/open points
build-tags. One positive match is enough to take the need into account.No
andor negation support.global_optionsordynamic functions.use case source
The SCORE project does a similar, internal implementation of this:
eclipse-score/score#217
They are (miss)using
hideto get the same result and do some nasty monkey-patching ;)We should support them by providing this kind of feature.
Full example
index.rst
conf.py
Call:
sphinx-build -b html . _build/htmlResult:
REQ_DESIGNis part of the docsCall:
sphinx-build -b html -t security . _build/htmlResult:
REQ_DESIGN, REQ_LOGINare part of the docsCall:
sphinx-build -b html -t security -t REQ_PRINT . _build/htmlResult:
REQ_DESIGN, REQ_LOGIN, REQ_PRINTare part of the docs