-
Notifications
You must be signed in to change notification settings - Fork 110
add override capabilities to repeated capabilities documentation #2183
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
Merged
Merged
Changes from 5 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
bc59057
add overwrite to repeated capabilities
elebel-emerson db0726d
Test for rep caps template
elebel-emerson dcb3894
codegen
elebel-emerson 92b5d19
Revert changes to file modes
elebel-emerson a5b270d
remove auto_prefix_addition_supported
elebel-emerson 9cd7344
expanding metadata instead of creating
elebel-emerson 33883f0
change repeated capabilities to pass
elebel-emerson eae401f
remove functional change
elebel-emerson 53574b6
testing chained rep caps
elebel-emerson 4b2ab0d
fixing whitespace/code sections
elebel-emerson 8e16ee1
change to use valid_indices instead of valid_identifiers
elebel-emerson 6d34dba
fixing bolding of first line of rep_caps
elebel-emerson 3108727
change nifake from keys to indices
elebel-emerson 2fed2e4
make whitespace more consistent
elebel-emerson 92ec484
Merge branch 'master' of https://github.com/ni/nimi-python into updat…
elebel-emerson 6a5105a
fix whitespace and pull from main
elebel-emerson b24a22f
use textwrap
elebel-emerson 99e7fb4
fix comment
elebel-emerson 8bfd388
going to be overwritten metadata
elebel-emerson 0bec19d
different test than default
elebel-emerson d4a1106
fixes from PR Comments
elebel-emerson 26b3c1b
Stop testing indentations
elebel-emerson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| from pathlib import Path | ||
| from types import SimpleNamespace | ||
|
|
||
| from mako.template import Template | ||
|
|
||
|
|
||
| def _render_rep_caps(config): | ||
| repo_root = Path(__file__).resolve().parents[2] | ||
| template_path = repo_root / 'build' / 'templates' / 'rep_caps.rst.mako' | ||
| template = Template(filename=str(template_path)) | ||
| metadata = SimpleNamespace(config=config) | ||
| return template.render(template_parameters={'metadata': metadata}) | ||
|
|
||
|
|
||
| def test_rep_caps_template_uses_custom_documentation_overrides(): | ||
| config = { | ||
| 'module_name': 'nifake', | ||
| 'c_function_prefix': 'niFake_', | ||
| 'repeated_capabilities': [ | ||
| { | ||
| 'prefix': 'res', | ||
| 'python_name': 'resources', | ||
| 'documentation': { | ||
| 'description': 'Resource repeated capabilities use fully-qualified identifiers.', | ||
| 'valid_identifiers': ['dev0/res0', 'dev0/res1'], | ||
| 'examples': [ | ||
| "session.resources['dev0/res0'].channel_enabled = True", | ||
| "session.resources['dev0/res1'].channel_enabled = True", | ||
| ], | ||
| }, | ||
| } | ||
| ], | ||
| } | ||
|
|
||
| rendered = _render_rep_caps(config) | ||
|
|
||
| assert 'Resource repeated capabilities use fully-qualified identifiers.' in rendered | ||
| assert "Valid identifiers: :python:`'dev0/res0, dev0/res1'`." in rendered | ||
| assert "session.resources['dev0/res0'].channel_enabled = True" in rendered | ||
| assert "session.resources['dev0/res1'].channel_enabled = True" in rendered | ||
|
|
||
| # Generic auto-prefix guidance should be suppressed when override disables it. | ||
|
elebel-emerson marked this conversation as resolved.
Outdated
|
||
| assert 'If no prefix is added to the items in the parameter' not in rendered | ||
| assert "session.resources['0-2'].channel_enabled = True" not in rendered | ||
| assert "'res0, res1, res2'" not in rendered | ||
|
|
||
|
|
||
| def test_rep_caps_template_preserves_default_prefixed_behavior(): | ||
| config = { | ||
| 'module_name': 'nifake', | ||
| 'c_function_prefix': 'niFake_', | ||
| 'repeated_capabilities': [ | ||
| { | ||
| 'prefix': 'channel', | ||
| 'python_name': 'channels', | ||
| } | ||
| ], | ||
| } | ||
|
|
||
| rendered = _render_rep_caps(config) | ||
|
|
||
| assert 'If no prefix is added to the items in the parameter' in rendered | ||
| assert "session.channels['0-2'].channel_enabled = True" in rendered | ||
| assert "'channel0, channel1, channel2'" in rendered | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,5 +34,3 @@ channels | |
|
|
||
| passes a string of :python:`'0, 1, 2'` to the set attribute function. | ||
|
|
||
|
|
||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.