-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Help Authoring Updates. #8325
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
Help Authoring Updates. #8325
Changes from all commits
72111ad
2793464
3ceaa20
115a5b8
1a79404
20a43ff
61bd48f
b8eb42a
e90f54a
5e2d17b
515c25d
31f77fe
abf9f87
bae82fa
1758373
bcc7c55
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,11 +12,20 @@ To override help for a given command: | |
| 1. Search code base for "account clear". | ||
| 2. Search result: src/command_modules/azure-cli-**profile**/azure/cli/command_modules/**profile**/commands.py. | ||
| 3. Result shows "account clear" is in the "profile" module. | ||
| 2. Using the module name, find the YAML help file which follows the path pattern: | ||
| 1. src/command_modules/azure-cli-**[module name]**/azure/cli/command_modules/**[module name]**/_help.py. | ||
| 2. Using the module name, find the YAML help file which follows the path pattern.: | ||
| 1. src/command_modules/azure-cli-**[module name]**/azure/cli/command_modules/**[module name]**/_help.py<br> | ||
| **or** <br> | ||
| src/command_modules/azure-cli-**[module name]**/azure/cli/command_modules/**[module name]**/help.yaml | ||
| 2. If the file doesn't exist, it can be created. | ||
| 3. Find or create a help entry with the name of the command/group you want to document. See example below. | ||
|
|
||
|
|
||
| > ###Notes: <br> | ||
| > 1. If using **_help.py** files for help authoring, the command module's **\_\_init\_\_.py** file must import the **_help.py** file. i.e: <br> | ||
| > `import azure.cli.command_modules.examplemod._help` <br> | ||
| > 2. The Help Authoring System now supports **help.yaml** files. Eventually, **_help.py** files will be replaced by **help.yaml**. | ||
|
|
||
|
|
||
| ### Example YAML help file, _help.py ### | ||
|
|
||
| <pre> | ||
|
|
@@ -25,7 +34,7 @@ To override help for a given command: | |
| # Licensed under the MIT License. See License.txt in the project root for license information. | ||
| #--------------------------------------------------------------------------------------------- | ||
|
|
||
| from azure.cli.help_files import helps | ||
| from knack.help_files import helps | ||
|
|
||
| #pylint: disable=line-too-long | ||
|
|
||
|
|
@@ -65,6 +74,72 @@ helps['account'] = """ | |
| """ | ||
| </pre> | ||
|
|
||
|
|
||
| ### Example YAML help file, help.yaml (Version 1) ### | ||
| <pre> | ||
| #--------------------------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. See License.txt in the project root for license information. | ||
| #--------------------------------------------------------------------------------------------- | ||
|
|
||
| version: 1 | ||
|
|
||
| content: | ||
|
|
||
| - command: | ||
| name: account clear | ||
| summary: Clear account | ||
| description: Longer summary of how the dummy account clear command works | ||
| links: | ||
| - title: Azure Accounts Webpage | ||
| url: https://azure.microsoft.com/en-us/account/ | ||
| - url: https://aka.ms/just-a-url | ||
| arguments: | ||
| - name: --account-name | ||
| summary: Account name | ||
| description: | | ||
| Longer summary with newlines preserved. | ||
| Preserving newlines is helpful for paragraph breaks. | ||
| value-sources: | ||
| - link: | ||
| title: List accounts | ||
| command: az account list | ||
| - link: | ||
| title: Show an accounts details | ||
| command: az account show | ||
| - link: | ||
| title: Azure Accounts Webpage | ||
| url: https://azure.microsoft.com/en-us/account/ | ||
| - link: | ||
| title: Azure Billing Documentation | ||
| url: https://docs.microsoft.com/en-us/azure/billing/ | ||
| - string: | ||
| "Account name should be lower case with no numbers or special symbol." | ||
| examples: | ||
| - summary: Clear an account | ||
| description: > | ||
| This is a longer description of the example. | ||
| The > character collapses multiple lines into a single line, | ||
| which is good for on-screen wrapping. | ||
| command: | | ||
| az account clear --acount-name myaccount | ||
|
|
||
| </pre> | ||
|
|
||
| You can also document groups using a similar format. | ||
|
|
||
| <pre> | ||
|
|
||
| - group: | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are groups meant to have examples in help.py? It seems like they can in knack. But I don't think help.yaml supports this
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think so, though Jason would want this. |
||
| name: account | ||
| summary: Manage Azure accounts | ||
| description: Longer summary of the account command group | ||
| links: | ||
| - title: Azure Accounts Webpage | ||
| url: https://azure.microsoft.com/en-us/account/ | ||
| - url: https://aka.ms/just-a-url | ||
| </pre> | ||
|
|
||
| # Tips to write effective help for your command | ||
|
|
||
| - Make sure the doc contains all the details that someone unfamiliar with the API needs to use the command. | ||
|
|
@@ -91,12 +166,13 @@ Command help starts with its raw SDK docstring text, if available. Non-SDK comm | |
|
|
||
| Here are the layers of Project Az help, with each layer overriding the layer below it: | ||
|
|
||
| | Help Display | | ||
| |----------------| | ||
| | YAML Authoring | | ||
| | Code Specified | | ||
| | Docstring | | ||
| | SDK Text | | ||
| | Help Display | | ||
| |-------------------------------| | ||
| | YAML Authoring via *help.yaml*| | ||
| | YAML Authoring via *_help.py* | | ||
| | Code Specified | | ||
| | Docstring | | ||
| | SDK Text | | ||
|
|
||
| ## Page titles for command groups ## | ||
|
|
||
|
|
@@ -123,6 +199,8 @@ For command examples, you optionally specify the profile the example is for with | |
| Here's a samply for `storage account create`: | ||
| The first example is only supported on the profile `latest` and above whilst the second example if only supported on `2017-03-09-profile` and below. | ||
|
|
||
| ### _help.py | ||
|
|
||
| ``` | ||
| examples: | ||
| - name: Create a storage account MyStorageAccount in resource group MyResourceGroup in the West US region with locally redundant storage. | ||
|
|
@@ -133,6 +211,18 @@ The first example is only supported on the profile `latest` and above whilst the | |
| max_profile: 2017-03-09-profile | ||
| ``` | ||
|
|
||
| ### help.yaml | ||
|
|
||
| ``` | ||
| examples: | ||
| - summary: Create a storage account MyStorageAccount in resource group MyResourceGroup in the West US region with locally redundant storage. | ||
| command: az storage account create -n MyStorageAccount -g MyResourceGroup -l westus --sku Standard_LRS | ||
| min_profile: latest | ||
| - summary: Create a storage account MyStorageAccount in resource group MyResourceGroup in the West US region with locally redundant storage. | ||
| command: az storage account create -n MyStorageAccount -g MyResourceGroup -l westus --account-type Standard_LRS | ||
| max_profile: 2017-03-09-profile | ||
| ``` | ||
|
|
||
| Here is how this looks in CLI `--help`: | ||
|
|
||
| On profile `latest`. | ||
|
|
||
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.
@tjprescott, note, the title for links is not currently displayed in the CLI.