-
Notifications
You must be signed in to change notification settings - Fork 3.3k
_help.py now parses yaml files and updates Helpfile objects #7581
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
Conversation
tjprescott
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First thing: removal the azure-cli-parser module. You can tuck your test command into azure-cli-configure or something, or just rely on az cdn profile create -h.
|
@tjprescott The parser module has been removed! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we're returning on the first iteration, why do we need the loop?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is because name_source is an array of the option names the parameter can take. E.g. --name and -n.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't follow. Right now, you are only looking at the first index of the array.
Is this what you mean to do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Edited:
Also this code affects how parameters are read from help.py as well. One, can now use just foo or f in help.py, just as in help.yaml, instead of --foo -f
However, I can change the logic to accept only the longer option name, as this might be clearer than accepting either option names.
cc @tjprescott
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for clarifying @williexu, I did not intend to look at just the first element of the array.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@williexu. I made and pushed the change after we spoke
| text = "" | ||
| for link in links: | ||
| if "name" in link and "url" in link: | ||
| text += "- {}: {}.\n".format(link["name"], link["url"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Name should likely be renamed title since that's the attribute in the HTML tag that corresponds to the tooltip (which is presumably what docs team would use it for). Also, it makes clear that this would be a longer thing than a simple name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My opinion is that rather than pull this out into a semi-bulleted list, we do:
For more information, visit: <url> and the title wouldn't be used.
| value_source.append(link_text.strip()) | ||
| params["populator-commands"] = value_source | ||
|
|
||
| return params |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right now, it looks like this is just copying the new fields into the old fields and relying on the logic that parses the old fields. How much more difficult would it be to actually have this conditional logic in the places that parse the YAML dictionary into the Help objects? This seems like it would be limiting in the long run.
| for name in param.name_source: | ||
| if data.get("name") == name.lstrip("-"): | ||
| return True | ||
| return False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a breaking change from the previous behavior- if data.get('name') was "-f --force", this would return false
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, I just tested this scenario and it works. If the data was obtained from _help.py, then HelpFile.load() is called which in turn calls CommandHelpFile._load_from_data() which ensures the previous behavior. These methods are defined in knack.help.py
The change to the previous behaviour is that _help.py will now also allow f or force as names.
tjprescott
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like we discussed:
- _help.py should contain all of the help classes
- _help_util should be renamed _help_loaders and contain just the different loading logic for V0 and V1.
- The core logic needs to load V0 first (if present) and then load V1. It is not one or the other.
Parser can output contents as yaml updated help.yaml test file with some comments.
More helpfile updates.
… Command and Group information formatted differently. Addressed a few other PR comments.
…here some command group names / parameter names are not updated from code.
…ies. Fields within commands/groups need to have some non-alphabetic ordering
…ly appealing. '>' and '|' (part of yaml syntax) are preserved in values.
…puts arguments before examples
7469520 to
a1732d1
Compare
|
@tjprescott @williexu. Please let me know your thoughts on the current state of the PR. I would still like to add some unittests. |
|
@adewaleo I'm closing this PR for now since we are essentially doing our reviews in person rather than via GitHub anyways. |
closes #7442
Todo:
This checklist is used to make sure that common guidelines for a pull request are followed.
The PR has modified HISTORY.rst describing any customer-facing, functional changes. Note that this does not include changes only to help content. (see Modifying change log).
I adhere to the Command Guidelines.