Skip to content

Commit

Permalink
add document source for each group (Azure#712)
Browse files Browse the repository at this point in the history
* add document source for each group

* add doc source using dedicated doc source map
  • Loading branch information
erich-wang authored and BurtBiel committed Aug 18, 2016
1 parent 511a72a commit e7e8ce7
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ $RECYCLE.BIN/
src/build
*.iml
/doc/_build
/doc/sphinx/_build
/.vs/config/applicationhost.config
.vscode/settings.json

Expand Down
24 changes: 22 additions & 2 deletions doc/sphinx/azhelpgen/azhelpgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ def make_rst(self):
DOUBLEINDENT = INDENT * 2
parser_dict = {}
_store_parsers(app.parser, parser_dict)
parser_dict.pop('')

help_files = []
for cmd, parser in parser_dict.items():
Expand All @@ -35,10 +34,13 @@ def make_rst(self):

for help_file in help_files:
is_command = isinstance(help_file, _help.CommandHelpFile)
yield '.. cli{}:: {}'.format('command' if is_command else 'group', help_file.command)
yield '.. cli{}:: {}'.format('command' if is_command else 'group', help_file.command if help_file.command else 'az') #it is top level group az if command is empty
yield ''
yield '{}:summary: {}'.format(INDENT, help_file.short_summary)
yield '{}:description: {}'.format(INDENT, help_file.long_summary)
if not is_command:
top_group_name = help_file.command.split()[0] if help_file.command else ''
yield '{}:docsource: {}'.format(INDENT, _doc_source_map[top_group_name] if top_group_name in _doc_source_map else '')
yield ''

if is_command and help_file.parameters:
Expand Down Expand Up @@ -96,3 +98,21 @@ def _is_group(parser):

def _get_parser_name(s):
return (s._prog_prefix if hasattr(s, '_prog_prefix') else s.prog)[3:]

_doc_source_map = {
'': 'src/command_modules/azure-cli-profile/azure/cli/command_modules/profile/_help.py',
'account': 'src/command_modules/azure-cli-profile/azure/cli/command_modules/profile/_help.py',
'component': 'src/command_modules/azure-cli-component/azure/cli/command_modules/component/_help.py',
'keyvault': 'src/command_modules/azure-cli-keyvault/azure/cli/command_modules/keyvault/_help.py',
'network': 'src/command_modules/azure-cli-network/azure/cli/command_modules/network/_help.py',
'redis': 'src/command_modules/azure-cli-redis/azure/cli/command_modules/redis/_help.py',
'resource': 'src/command_modules/azure-cli-resource/azure/cli/command_modules/resource/_help.py',
'tag': 'src/command_modules/azure-cli-resource/azure/cli/command_modules/resource/_help.py',
'role': 'src/command_modules/azure-cli-role/azure/cli/command_modules/role/_help.py',
'ad': 'src/command_modules/azure-cli-role/azure/cli/command_modules/role/_help.py',
'storage': 'src/command_modules/azure-cli-storage/azure/cli/command_modules/storage/_help.py',
'taskhelp': 'src/command_modules/azure-cli-taskhelp/azure/cli/command_modules/taskhelp/_help.py',
'vm': 'src/command_modules/azure-cli-vm/azure/cli/command_modules/vm/_help.py',
'vmss': 'src/command_modules/azure-cli-vm/azure/cli/command_modules/vm/_help.py',
'webapp': 'src/command_modules/azure-cli-webapp/azure/cli/command_modules/webapp/_help.py'
}
6 changes: 5 additions & 1 deletion doc/sphinx/cligroup/cligroup.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ def get_index_text(self, modname, name):
return name

class CliGroupDirective(CliBaseDirective):
doc_field_types = cli_field_types
doc_field_types = copy.copy(cli_field_types)
doc_field_types.append(
Field('docsource', label='Doc Source', has_arg=False,
names=('docsource', 'documentsource'))
)

class CliCommandDirective(CliBaseDirective):
doc_field_types = cli_field_types
Expand Down

0 comments on commit e7e8ce7

Please sign in to comment.