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

♻️ Make needextend argument declarative #1391

Merged
merged 4 commits into from
Jan 27, 2025

Conversation

chrisjsewell
Copy link
Member

@chrisjsewell chrisjsewell commented Jan 27, 2025

The argument for needextend can refer to either a single need ID or filter function.
Currently, the format cannot be known until all needs have been processed, and it is resolved during post-processing.
This is problematic for (a) user readability, (b) improving processing performance and issue feedback

This PR slightly modifies the argument processing to allow for two "explicit" formats:

  • <ID>, if the argument is enclosed in <> it is always processed as a single ID
  • "filter string", if the argument is enclosed in "" it is always processed as a filter string

If the string is not enclosed, then the logic is relatively similar to the existing:

  • ID, if the argument is a single word (no spaces) then it is processed as a single ID
  • otherwise, it is processed as a filter string

This change should not break most uses of needextend, but there are some corner-cases that would need to be adapted, e.g. a single is_external would now be processed as an ID, unless it was enclosed or expanded:

.. needextend:: "is_external"
.. needextend:: is_external is True

Copy link

codecov bot commented Jan 27, 2025

Codecov Report

Attention: Patch coverage is 94.59459% with 2 lines in your changes missing coverage. Please review.

Project coverage is 88.24%. Comparing base (4e10030) to head (2902559).
Report is 106 commits behind head on master.

Files with missing lines Patch % Lines
sphinx_needs/directives/needextend.py 93.75% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1391      +/-   ##
==========================================
+ Coverage   86.87%   88.24%   +1.36%     
==========================================
  Files          56       60       +4     
  Lines        6532     7145     +613     
==========================================
+ Hits         5675     6305     +630     
+ Misses        857      840      -17     
Flag Coverage Δ
pytests 88.24% <94.59%> (+1.36%) ⬆️

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.

@chrisjsewell chrisjsewell requested a review from ubmarco January 27, 2025 13:25
Copy link
Member

@ubmarco ubmarco left a comment

Choose a reason for hiding this comment

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

Just 2 minor remarks

sphinx_needs/data.py Outdated Show resolved Hide resolved
sphinx_needs/directives/needextend.py Show resolved Hide resolved
@chrisjsewell chrisjsewell requested a review from ubmarco January 27, 2025 14:17
@chrisjsewell chrisjsewell changed the title ♻️ Make needextend argument deterministic ♻️ Make needextend argument declarative Jan 27, 2025
@chrisjsewell chrisjsewell merged commit ba2497a into master Jan 27, 2025
19 checks passed
@chrisjsewell chrisjsewell deleted the needimport-deterministic-arg branch January 27, 2025 14:41
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.

2 participants