MCPcopy Index your code
hub / github.com/aws/aws-cli / doc_option_example

Method doc_option_example

awscli/clidocs.py:628–684  ·  view source on GitHub ↗
(self, arg_name, help_command, event_name, **kwargs)

Source from the content-addressed store, hash-verified

626 doc.write('}')
627
628 def doc_option_example(self, arg_name, help_command, event_name, **kwargs):
629 service_id, operation_name = find_service_and_method_in_event_name(
630 event_name
631 )
632 doc = help_command.doc
633 cli_argument = help_command.arg_table[arg_name]
634 if cli_argument.group_name in self._arg_groups:
635 if cli_argument.group_name in self._documented_arg_groups:
636 # Args with group_names (boolean args) don't
637 # need to generate example syntax.
638 return
639 argument_model = cli_argument.argument_model
640 docgen = ParamShorthandDocGen()
641 if docgen.supports_shorthand(cli_argument.argument_model):
642 example_shorthand_syntax = docgen.generate_shorthand_example(
643 cli_argument, service_id, operation_name
644 )
645 if example_shorthand_syntax is None:
646 # If the shorthand syntax returns a value of None,
647 # this indicates to us that there is no example
648 # needed for this param so we can immediately
649 # return.
650 return
651 if example_shorthand_syntax:
652 doc.style.new_paragraph()
653 doc.write('Shorthand Syntax')
654 doc.style.start_codeblock()
655 for example_line in example_shorthand_syntax.splitlines():
656 doc.writeln(example_line)
657 doc.style.end_codeblock()
658 if (
659 argument_model is not None
660 and argument_model.type_name == 'list'
661 and argument_model.member.type_name in SCALAR_TYPES
662 ):
663 # A list of scalars is special. While you *can* use
664 # JSON ( ["foo", "bar", "baz"] ), you can also just
665 # use the argparse behavior of space separated lists.
666 # "foo" "bar" "baz". In fact we don't even want to
667 # document the JSON syntax in this case.
668 member = argument_model.member
669 doc.style.new_paragraph()
670 doc.write('Syntax')
671 doc.style.start_codeblock()
672 example_type = self._json_example_value_name(
673 member, include_enum_values=False
674 )
675 doc.write(f'{example_type} {example_type} ...')
676 doc.style.end_codeblock()
677 doc.style.new_paragraph()
678 elif cli_argument.cli_type_name not in SCALAR_TYPES:
679 doc.style.new_paragraph()
680 doc.write('JSON Syntax')
681 doc.style.start_codeblock()
682 self._json_example(doc, argument_model, stack=[])
683 doc.style.end_codeblock()
684 doc.style.new_paragraph()
685

Callers

nothing calls this directly

Calls 11

supports_shorthandMethod · 0.95
_json_exampleMethod · 0.95
new_paragraphMethod · 0.45
writeMethod · 0.45
start_codeblockMethod · 0.45
writelnMethod · 0.45
end_codeblockMethod · 0.45

Tested by

no test coverage detected