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

Class ParamShorthandDocGen

awscli/argprocess.py:443–582  ·  view source on GitHub ↗

Documentation generator for param shorthand syntax.

Source from the content-addressed store, hash-verified

441
442
443class ParamShorthandDocGen(ParamShorthand):
444 """Documentation generator for param shorthand syntax."""
445
446 _DONT_DOC = object()
447 _MAX_STACK = 3
448
449 def supports_shorthand(self, argument_model):
450 """Checks if a CLI argument supports shorthand syntax."""
451 if argument_model is not None:
452 return _supports_shorthand_syntax(argument_model)
453 return False
454
455 def generate_shorthand_example(
456 self, cli_argument, command_name, operation_name
457 ):
458 """Generate documentation for a CLI argument.
459
460 :type cli_argument: awscli.arguments.BaseCLIArgument
461 :param cli_argument: The CLI argument which to generate
462 documentation for.
463
464 :return: Returns either a string or ``None``. If a string
465 is returned, it is the generated shorthand example.
466 If a value of ``None`` is returned then this indicates
467 that no shorthand syntax is available for the provided
468 ``argument_model``.
469
470 """
471 docstring = self._handle_special_cases(
472 cli_argument, command_name, operation_name
473 )
474 if docstring is self._DONT_DOC:
475 return None
476 elif docstring:
477 return docstring
478
479 # Otherwise we fall back to the normal docgen for shorthand
480 # syntax.
481 stack = []
482 try:
483 if cli_argument.argument_model.type_name == 'list':
484 argument_model = cli_argument.argument_model.member
485 return self._shorthand_docs(argument_model, stack) + ' ...'
486 else:
487 return self._shorthand_docs(cli_argument.argument_model, stack)
488 except TooComplexError:
489 return ''
490
491 def _handle_special_cases(
492 self, cli_argument, command_name, operation_name
493 ):
494 model = cli_argument.argument_model
495 if (
496 model.type_name == 'list'
497 and model.member.type_name == 'structure'
498 and len(model.member.members) == 1
499 and self._uses_old_list_case(
500 command_name, operation_name, cli_argument.name

Callers 2

setUpMethod · 0.90
doc_option_exampleMethod · 0.90

Calls

no outgoing calls

Tested by 1

setUpMethod · 0.72