diff --git a/scripts/refdoc/azhelpgen/azhelpgen.py b/scripts/refdoc/azhelpgen/azhelpgen.py index 693a13b013d..9daadc7d1e5 100644 --- a/scripts/refdoc/azhelpgen/azhelpgen.py +++ b/scripts/refdoc/azhelpgen/azhelpgen.py @@ -124,14 +124,15 @@ def make_rst(self): pass yield '{}:default: {}'.format(DOUBLEINDENT, arg.default) if arg.value_sources: - yield '{}:source: {}'.format(DOUBLEINDENT, ', '.join(arg.value_sources)) + yield '{}:source: {}'.format(DOUBLEINDENT, ', '.join(_get_populator_commands(arg))) yield '' yield '' if len(help_file.examples) > 0: for e in help_file.examples: - yield '{}.. cliexample:: {}'.format(INDENT, e.name) + fields = _get_example_fields(e) + yield '{}.. cliexample:: {}'.format(INDENT, fields['summary']) yield '' - yield DOUBLEINDENT + e.text.replace("\\", "\\\\") + yield DOUBLEINDENT + fields['command'].replace("\\", "\\\\") yield '' def run(self): @@ -164,3 +165,26 @@ def _is_group(parser): def _get_parser_name(s): return (s._prog_prefix if hasattr(s, '_prog_prefix') else s.prog)[3:] + + +def _get_populator_commands(param): + commands = [] + for value_source in param.value_sources: + try: + commands.append(value_source["link"]["command"]) + except TypeError: # old value_sources are strings + commands.append(value_source) + except KeyError: # new value_sources are dicts + continue + return commands + +def _get_example_fields(ex): + res = {} + try: + res['summary'] = ex.short_summary + res['command'] = ex.command + except AttributeError: + res['summary'] = ex.name + res['command'] = ex.text + + return res \ No newline at end of file