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

✨ Allow configuring description of extra option #1338

Merged
merged 5 commits into from
Oct 28, 2024

Conversation

chrisjsewell
Copy link
Member

@chrisjsewell chrisjsewell commented Oct 27, 2024

This PR allows for using a dict to define a needs_extra_options item, that can have both a name and (optional) description key, e.g.:

needs_extra_options = [
    "introduced",
    {"name": "impacts", "description": "What is the impact of this need?"},
]

Note, I envisage this extended dict format eventually also supporting other settings such as a data type, default, and possibly also limiting the need types it applies to, e.g.

needs_extra_options = [
    {"name": "duration", 
     "description": "What is the impact of this need?",
     "type": "number",
     "default": 1,
     "need_types": ["req", "spec"]
    },
]

These though would require additional code changes

@chrisjsewell chrisjsewell requested a review from ubmarco October 27, 2024 16:08
Copy link

codecov bot commented Oct 27, 2024

Codecov Report

Attention: Patch coverage is 95.23810% with 1 line in your changes missing coverage. Please review.

Project coverage is 88.03%. Comparing base (4e10030) to head (0c9fd3c).
Report is 99 commits behind head on master.

Files with missing lines Patch % Lines
sphinx_needs/needs.py 93.33% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1338      +/-   ##
==========================================
+ Coverage   86.87%   88.03%   +1.15%     
==========================================
  Files          56       60       +4     
  Lines        6532     7086     +554     
==========================================
+ Hits         5675     6238     +563     
+ Misses        857      848       -9     
Flag Coverage Δ
pytests 88.03% <95.23%> (+1.15%) ⬆️

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 danwos October 27, 2024 16:12
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 great, just a hint for the docs

@chrisjsewell chrisjsewell requested a review from danwos October 28, 2024 11:35
@chrisjsewell chrisjsewell merged commit 7a3e9ef into master Oct 28, 2024
18 checks passed
@chrisjsewell chrisjsewell deleted the extra-option-description branch October 28, 2024 13:44
chrisjsewell added a commit that referenced this pull request Jan 26, 2025
Currently, the value of all extra options is expected to be a string; other types are not supported in other aspects of sphinx-needs, such as `needextend` and dynamic functions.

This PR adds the `needs. mistyped_external_values ` and `needs.mistyped_import_values` warnings for non-string values, for `needs_external_needs` and `needimport` sources respectively.
The warning is only emitted once per source, to avoid creating too many warnings.

Note, in the future it is likely that more types will be supported via configuration in `needs_extra_options` (see #1338)
chrisjsewell added a commit that referenced this pull request Jan 27, 2025
Currently, the value of all extra options is expected to be a string;
other types are not supported in various aspects of sphinx-needs (such
as `needextend`, dynamic functions and filtering), and in-fact are
already silently converted to strings during processing,
see:
https://github.com/useblocks/sphinx-needs/blob/92b47b129047df1b7aa9f40332d48deb369dc0c2/sphinx_needs/api/need.py#L791

This PR adds the `needs.mistyped_external_values ` and
`needs.mistyped_import_values` warnings for non-string values, for
`needs_external_needs` and `needimport` sources respectively. The
warning is only emitted once per source, to avoid creating too many
warnings.

Note, in the future it is hoped that more types will be supported via
configuration in `needs_extra_options` (see
#1338)
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