Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

filter on style (or: all options/fields) #169

Closed
AlbertMietus opened this issue Jan 12, 2021 · 3 comments · Fixed by #268
Closed

filter on style (or: all options/fields) #169

AlbertMietus opened this issue Jan 12, 2021 · 3 comments · Fixed by #268

Comments

@AlbertMietus
Copy link

Currently a filter as "red_border" in style is not possible, as only a few "variables" (see https://sphinxcontrib-needs.readthedocs.io/en/latest/filter.html#filter-string) exist.

My request is to add "style" to that list.

Or better to add ALL options as variable -- as I can't see why some are more useful as others.
Suggested syntax: option.$NAME (or: field.$NAME) where $NAME is any option/field that is set in a directive

Thanks

BTW, I know, it is possible to add it myself, but this seams very generic

@danwos
Copy link
Member

danwos commented Jan 12, 2021

Mhh, I think this is already possible by using current_need in the filter string.

Something like this should work (untested)

.. needtable::
   :filter: current_need["style"] == "red_border"

This should give you access to every option.
Also needs is available, which contains all needs and their options.

But yes, it's totally undocumented.
I leave this ticket open until the docs got updated.

@AlbertMietus
Copy link
Author

This sounds oke, BUT: It does not work

I got the following error
sphinxcontrib.needs.filter_common.NeedInvalidFilter: Filter current_need["style"] == "red_border" not valid: Error: name 'current_need' is not defined

As it is undocumented, is kind of hard to see which version I should use. But I have piped this week. __needs.py says 0.5.6 ...

Thanks again

@danwos
Copy link
Member

danwos commented May 7, 2021

Tested it with current version and it is working as expected.

Used this code for tests:

.. needtable::
   :filter: style == "red_border"

.. needtable::
   :filter: "red_border" in style

Both needtables show me only the related needs and not more.

But current_need was really not accessible.
This gets fixed with #268.

You can see all available "vars" for a filter string by using the debug layout of a need, which prints all internal vars.

.. req:: test
   :layout: debug

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants