useblocks / sphinx-needs

Adds needs/requirements to sphinx
https://sphinx-needs.readthedocs.io/en/latest/index.html
MIT License
216 stars 67 forks source link

needs_model: A more complex model for sphinx-needs config. #332

Open danwos opened 3 years ago

danwos commented 3 years ago

Currently needs_types, needs_extra_links/options, needs_warnings are not related to each other.

But there are a lot of use cases, where e.g. only specific options for a specific need-types shall be possible.

Therefore there shall be a new option needs_model, which takes a dictionary as value, which includes the configs for needs_extra_links and co.

I have to check if the usage ofneeds_model prohibits the usage of some other, already existing options.

Model defintiion needs tbd...

twodrops commented 3 years ago

I vote for this. It would be great to have a type-specific need definition, which is also self-contained.

StephanKuempel commented 2 years ago

Maybe the complete model could be defined by a json schema ? Benefit would be:

Maybe, part of the already existing (very generic) needsfile.json schema could be used.

ubmarco commented 2 years ago

I tried an initial implementation of this using pydantic in https://github.com/useblocks/sphinx-needs/pull/676. The docs are still missing, but I already at this early stage I think the solution checks all the boxes:

Here is a Sphinx project example.

mason3k commented 1 year ago

Would be nice if needs_global_options could be supported on a per-needs-type basis as well, for defaults that only make sense for a certain needs type

arwedus commented 1 year ago

Would be nice if needs_global_options could be supported on a per-needs-type basis as well, for defaults that only make sense for a certain needs type

@danwos: I was about to request exactly that as a new issue, to have a per-directive default value for options 😆 . E.g. a requirement has default status "draft", but a test has a default status "implemented" (just an example, not sure if it makes sense).

This (sub) feature should be easy to implement, as we already have the same functionality via needextend (when you set an option for all needs of a certain type to a default value only if the option value is not '').

arwedus commented 1 year ago

@mason3k: This what we requested is actually already possible, see https://sphinx-needs.readthedocs.io/en/latest/configuration.html#filter-based-global-options

Set a filter based global option, and use type="req" (for example) as filter.