Skip to content

Conversation

@adewaleo
Copy link
Contributor

@adewaleo adewaleo commented Oct 16, 2018

  • _help.py parses help.yaml files and updates help objects appropriately
  • dummy cdn yaml file added
  • added temporary yaml parser command

closes #7442

Todo:

  • need to add some sort of tests

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.

Copy link
Member

@tjprescott tjprescott left a 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.

@adewaleo
Copy link
Contributor Author

@tjprescott The parser module has been removed!

Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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?

Copy link
Contributor Author

@adewaleo adewaleo Oct 22, 2018

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

Copy link
Contributor Author

@adewaleo adewaleo Oct 22, 2018

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.

Copy link
Contributor Author

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"])
Copy link
Member

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.

Copy link
Member

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
Copy link
Member

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
Copy link
Contributor

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

Copy link
Contributor Author

@adewaleo adewaleo Oct 22, 2018

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.

Copy link
Member

@tjprescott tjprescott left a comment

Choose a reason for hiding this comment

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

Like we discussed:

  1. _help.py should contain all of the help classes
  2. _help_util should be renamed _help_loaders and contain just the different loading logic for V0 and V1.
  3. The core logic needs to load V0 first (if present) and then load V1. It is not one or the other.

Oluwatosin Adewale added 14 commits November 21, 2018 15:48
Parser can output contents as yaml

updated help.yaml test file with some comments.
… 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.
@adewaleo adewaleo changed the base branch from feature/HelpUpdate to dev November 26, 2018 18:21
@adewaleo adewaleo changed the base branch from dev to feature/HelpUpdate November 26, 2018 18:21
@adewaleo
Copy link
Contributor Author

@tjprescott @williexu. Please let me know your thoughts on the current state of the PR. I would still like to add some unittests.

@tjprescott
Copy link
Member

@adewaleo I'm closing this PR for now since we are essentially doing our reviews in person rather than via GitHub anyways.

@tjprescott tjprescott closed this Dec 13, 2018
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.

4 participants