Skip to content

{Docs} Quote code in help messages with backticks#13060

Merged
jiasli merged 6 commits intoAzure:devfrom
jiasli:backtick-quote
May 6, 2020
Merged

{Docs} Quote code in help messages with backticks#13060
jiasli merged 6 commits intoAzure:devfrom
jiasli:backtick-quote

Conversation

@jiasli
Copy link
Member

@jiasli jiasli commented Apr 17, 2020

Description
Fix #10698: az ad app permission add description not understandable

Symptom

The doc for az ad app permission add is not rendered correctly, with the value of --api-permissions missing.

https://docs.microsoft.com/en-us/cli/azure/ad/app/permission

image

Root Cause

The reason is that the doc generator parses <resource-access-id> and <type> as a possible HTML entities:

c.argument('api_permissions', nargs='+', help='space seperated list of <resource-access-id>=<type>')

but they don't match up with any entities on the Docs HTML Whitelist, and the content is discarded.

This happens not only to this command but all over the place, including VM, Network and more commands.

Solution

This PR quotes the text with backticks ` like what azure-cli-core does for --resource-group:

help="Name of resource group. You can configure the default group using `az configure --defaults group=<name>`",

In this way, the doc is rendered correctly (even better with highlighting due to backtick (`) being interpreted as code in markdown), such as

https://docs.microsoft.com/en-us/cli/azure/acs

image

⚠ But the disadvantage is the --help message may look verbose.

Remarks

I searched the occurrence of <> with regex <.+?> (? stands for non-greedy match) and added backticks manually.

@jiasli jiasli requested review from mmyyrroonn and qwordy April 17, 2020 03:56
c.argument('network_acls', type=validate_file_or_dict,
help='Network ACLs. It accepts a JSON filename or a JSON string. JSON format: '
'{\\"ip\\":[<ip1>, <ip2>...],\\"vnet\\":[<vnet_name_1>/<subnet_name_1>,<subnet_id2>...]}')
'`{\\"ip\\":[<ip1>, <ip2>...],\\"vnet\\":[<vnet_name_1>/<subnet_name_1>,<subnet_id2>...]}`')
Copy link
Member Author

@jiasli jiasli Apr 17, 2020

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for pointing it out.

with self.argument_context('managedapp definition create') as c:
c.argument('lock_level', arg_type=get_enum_type(ApplicationLockLevel), help='The type of lock restriction.')
c.argument('authorizations', options_list=['--authorizations', '-a'], nargs='+', help="space-separated authorization pairs in a format of <principalId>:<roleDefinitionId>")
c.argument('authorizations', options_list=['--authorizations', '-a'], nargs='+', help="space-separated authorization pairs in a format of `<principalId>:<roleDefinitionId>`")
Copy link
Member Author

@jiasli jiasli Apr 17, 2020

Choose a reason for hiding this comment

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

with self.argument_context('network public-ip prefix') as c:
c.argument('public_ip_prefix_name', name_arg_type, completer=get_resource_name_completion_list('Microsoft.Network/publicIPPrefixes'), id_part='name', help='The name of the public IP prefix.')
c.argument('prefix_length', options_list='--length', help='Length of the prefix (i.e. XX.XX.XX.XX/<Length>)')
c.argument('prefix_length', options_list='--length', help='Length of the prefix (i.e. `XX.XX.XX.XX/<Length>`)')
Copy link
Member Author

@jiasli jiasli Apr 17, 2020

Choose a reason for hiding this comment

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

with self.argument_context('vmss create', min_api='2017-03-30', arg_group='Network') as c:
c.argument('public_ip_per_vm', action='store_true', help="Each VM instance will have a public ip. For security, you can use '--nsg' to apply appropriate rules")
c.argument('vm_domain_name', help="domain name of VM instances, once configured, the FQDN is 'vm<vm-index>.<vm-domain-name>.<..rest..>'")
c.argument('vm_domain_name', help="domain name of VM instances, once configured, the FQDN is `vm<vm-index>.<vm-domain-name>.<..rest..>`")
Copy link
Member Author

@jiasli jiasli Apr 17, 2020

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

How do you send picture?

Copy link
Contributor

Choose a reason for hiding this comment

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

How do you send picture?

Create a screenshot and paste it into input box? I guess.
This is the way I used.

@qwordy
Copy link
Member

qwordy commented Apr 17, 2020

How do you preview the rendered html page to see the result is expected?
How do you open a draft PR?

@jiasli
Copy link
Member Author

jiasli commented Apr 22, 2020

How do you preview the rendered html page to see the result is expected?

I don't know how to "preview the rendered html page". I am deducing it from the global params --resource-group and --location. +@daxianji007 to clarify.

How do you open a draft PR?

See this blog and this help:

@qwordy
Copy link
Member

qwordy commented Apr 22, 2020

I encounter a same issue of a new parameter I add in Azure CLI 2.4.0. Only at release time can I see the HTML page. This is the problem!

@yonzhan yonzhan added this to the S169 - For Build milestone Apr 22, 2020
@yonzhan
Copy link
Collaborator

yonzhan commented Apr 22, 2020

add to S169

@jiasli jiasli marked this pull request as ready for review April 24, 2020 10:15
Copy link
Contributor

@zhoxing-ms zhoxing-ms left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@fengzhou-msft fengzhou-msft left a comment

Choose a reason for hiding this comment

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

Can we put a guidance in authoring_help.md?

- Don't use "etc". Sometimes it makes sense to spell out a list completely. Sometimes it works to say "like ..." instead of "..., etc".
- Use active voice. For example, say "Update web app configurations" instead of "Updates web app congfigurations" or "Updating web app configurations".
- Don't use highly formal language. If you imagine that another dev sat down with you and you were telling him what he needs to know to use the command, that's exactly what you need to write, in those words.
- If the help message contains **angle brackets**, like `<name>`, it will be parsed as an HTML tag during document rendering. To bypass that, quote the content with backticks `` `<name>` `` to tell the document renderer to parse it as **code**.
Copy link
Member Author

Choose a reason for hiding this comment

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

Can we put a guidance in authoring_help.md?

Good point, added.

@jiasli jiasli requested a review from fengzhou-msft April 30, 2020 06:10


### Example YAML help file, _help.py ###
### Example YAML help file, _help.py
Copy link
Member Author

Choose a reason for hiding this comment

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

_ breaks GitHub's highlighting.

image

Suggested change
### Example YAML help file, _help.py
### Example YAML help file, \_help.py

@jiasli jiasli merged commit 2325d7c into Azure:dev May 6, 2020
@jiasli jiasli mentioned this pull request Jul 9, 2020
2 tasks
@jiasli jiasli deleted the backtick-quote branch July 9, 2020 02:13
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.

"az ad app permission add" description not understandable

9 participants