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

Check if option is modified by needextend

Open Chriner opened this issue 3 years ago • 2 comments

With directive needextend it is possible to do any modifications. For that reason we want to restrict the usage of needextend to specific use cases. This can be done with needs_warnings. But not all use cases are possible to check.

Example use case for needextend restriction: • maximum 1 modification per need (= only one needextend per need) -> already possible • Allowed to modify only specific need types (e. g. req-sys, req-sw) -> already possible • Allowed to modify option abc (e. g. link) -> not possible

Can the check for option be added? E. g. an extra option counter could be added, together with the possibility to iterate through all options.

Chriner avatar Sep 10 '21 15:09 Chriner

I like the idea. Maybe we can automatically create for each option, like status, the related option status_changed with starting value 0. And each modification via needextend raises this number. Filter would look like need['status_changed'] > 1

Another approach would be to have a generic modifications option, which stores a dict of option:number. A filter for a warning may look like need['modifications']['status'] > 1

But I don't like the second solution so much, as it would introduce dicts for options to the user.

Would such a solution be helpful for your use cases?

danwos avatar Sep 13 '21 15:09 danwos

For me both are fine. First solution has drawback, that a new option status_changed cannot be introduced, because name is already automatically used for status. So possibly option 1 restricts to much.

But it solves my use case only partly. I would like to check, if all options are not modified, only one is allowed to be modified e. g. status. Do I see it right I have to do the following checks:

if need['special_status_changed'] > 1 or need['morespecial_status_changed'] > 1 or need['mostspecial_status_changed'] > 1 error Then at a later point of time someone introduces the option normal_status and then this is missing in filter. So I would need a more general solution. Don't have a good idea for this now.

Chriner avatar Sep 13 '21 15:09 Chriner