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

#947 filter_warning option to replace default "No needs passed the filters" text #1093

Merged
merged 9 commits into from
Jan 24, 2024

Conversation

kreuzberger
Copy link
Contributor

Add option :filter_warning: to directives (e.g. needtable) to show no text or given text instead of the default text.

Copy link

codecov bot commented Jan 19, 2024

Codecov Report

Attention: 2 lines in your changes are missing coverage. Please review.

Comparison is base (c27bc64) 79.27% compared to head (ee8f6d2) 83.19%.

Files Patch % Lines
sphinx_needs/directives/needextract.py 0.00% 1 Missing ⚠️
sphinx_needs/directives/needfilter.py 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1093      +/-   ##
==========================================
+ Coverage   79.27%   83.19%   +3.92%     
==========================================
  Files          56       56              
  Lines        6460     6456       -4     
==========================================
+ Hits         5121     5371     +250     
+ Misses       1339     1085     -254     
Flag Coverage Δ
pytests 83.19% <96.61%> (+3.92%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@danwos danwos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR. 👍
Technical realization looks good.

I think the dictionary operations can be shortened. I left 1-2 comments, but it affects all changes for the different directives.

content.append(no_needs_found_paragraph())
content.append(
no_needs_found_paragraph(
current_needextract["filter_warning"] if "filter_warning" in current_needextract else None
Copy link
Member

@danwos danwos Jan 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this can be shorten to:

current_needextrac.get("filter_warning", None)

@@ -228,7 +228,11 @@ def process_needfilters(
content.append(puml_node)

if len(content) == 0:
nothing_found = "No needs passed the filters"
nothing_found = (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This we could write like

nothing_found = current_needfilter.get('filter_warning', 'No needs passed the filters')


.. needtable::
:filter: ("7" in tags)
:filter_warning:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would add here a positive filter result as well, to be sure the text is not printed if needs got found.

@kreuzberger
Copy link
Contributor Author

Hi! Just your suggestions will be integrated cause they provide for sure a more pythonic solution.
Just 2 additional questions:

  • the lint gives error due to some apply method i do not know nothing about / unchanged code by my pr. How to solve this?
  • Technically some directives (e.g. needtables) seem to give this warning message or the filter_warning text, but some directives (e.g. needlist) seem to remove the whole node / content even if the code for the warning message is active? Is this right? intended?

@danwos
Copy link
Member

danwos commented Jan 22, 2024

Regarding the linter problem, this may happen if mypy or other linter-libs got an update and introduced new checks.

However, you can deactivate the specific test in pyproject.toml (untested!):

[[tool.mypy.overrides]]
module = [
  "sphinx_needs.directives.needextract",
]
disable_error_code = "no-untyped-call"

Regarding needlists, I guess this is a bug or not updated behavior.
For me, writing the "no needs found"-text for all directives should be the common rule.
So if you like, you can fix it in this PR ;)

Thanks for the invested time!! 🙏

@kreuzberger
Copy link
Contributor Author

So, made some fixes:

  • add you hints regarding code style
  • fix the mypy issue regarding your comments
  • fix different handling of filtered data implementations in most directives

Changed behaviour:

  • all directives use the common method directives.utils.no_needs_found_paragraph
    If no needs are found due to filter, the default or filter warning message is shown.
    This includes that if the warning message is shown the "empty" content is not shown!! This affects:
  • Tables: no more empty tables shown
  • Lists: show filter message in the above cases (was not shown before)
  • needgantt: remove empty figure nodes.
  • needsequence: remove figure nodes if 0 == messages and just one participant.

Added more tests, including a good case there needs are found and filtered message should not be shown.
filter_no_needs.pdf

@kreuzberger
Copy link
Contributor Author

The checks failed due to upload error to codecov...

@kreuzberger
Copy link
Contributor Author

Just one more questions:
If i run the tests locally, (e.g. nox -s "tests-3.10(sphinx='7.0')" ) i always get an error in this test:
tests/test_sn_collapse_button.py FF [ 90%]

The error message shown is

Timing measurement results (JSON) stored under /tmp/sn_test_build_data/pgkTg3kpnD/variant_doc/_build/html/debug_measurement.json
Timing measurement report (HTML) stored under /tmp/sn_test_build_data/pgkTg3kpnD/variant_doc/_build/html/debug_measurement.html
No version of Cypress is installed in: ~/.cache/Cypress/13.6.3/Cypress

Please reinstall Cypress by running: cypress install

----------

Cypress executable not found at: ~/.cache/Cypress/13.6.3/Cypress/Cypress

Is there a specific problem with the pyvenv/nox or what could get wrong?

@danwos
Copy link
Member

danwos commented Jan 22, 2024

Cypress is our frontend JavaScript test framework, to test browser based features like the need-collapse button.
It must be installed by hand.

I guess there is a flag for all frontend tests, so it could be deactivate with the right pytest command.

Copy link
Member

@danwos danwos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Thanks for the update and the good tests.

I will work a little bit on the docs and merge it then (hopefully today)

@kreuzberger
Copy link
Contributor Author

Looks good. Thanks for the update and the good tests.

I will work a little bit on the docs and merge it then (hopefully today)

Hi! After some time 2 thinks were upcomming:

  • No tests implemention for needpie, i think were was no "old" implemenation
  • I would like to add a class for the filter warning, so that it could be styled (e.g. bold, extra box etc). This could be done in the central function for adding the paragraph.

@kreuzberger
Copy link
Contributor Author

With the latest commit i think everything is now successfully finished. If you have no more comments/issues with the PR, i think it is ready to get merged 😄

Copy link
Member

@danwos danwos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks a lot for the PR 👍

@danwos danwos merged commit 73b961e into useblocks:master Jan 24, 2024
19 checks passed
@kreuzberger kreuzberger deleted the issue_947 branch January 24, 2024 17:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants