Returns a string describing a positional argument. Args: arg: The name of the positional argument. docstring_info: A docstrings.DocstringInfo namedtuple with information about the containing function's docstring. spec: An instance of fire.inspectutils.FullArgSpec, containing typ
(arg, docstring_info, spec)
| 417 | |
| 418 | |
| 419 | def _CreateArgItem(arg, docstring_info, spec): |
| 420 | """Returns a string describing a positional argument. |
| 421 | |
| 422 | Args: |
| 423 | arg: The name of the positional argument. |
| 424 | docstring_info: A docstrings.DocstringInfo namedtuple with information about |
| 425 | the containing function's docstring. |
| 426 | spec: An instance of fire.inspectutils.FullArgSpec, containing type and |
| 427 | default information about the arguments to a callable. |
| 428 | |
| 429 | Returns: |
| 430 | A string to be used in constructing the help screen for the function. |
| 431 | """ |
| 432 | |
| 433 | # The help string is indented, so calculate the maximum permitted length |
| 434 | # before indentation to avoid exceeding the maximum line length. |
| 435 | max_str_length = LINE_LENGTH - SECTION_INDENTATION - SUBSECTION_INDENTATION |
| 436 | |
| 437 | description = _GetArgDescription(arg, docstring_info) |
| 438 | |
| 439 | arg_string = formatting.BoldUnderline(arg.upper()) |
| 440 | |
| 441 | arg_type = _GetArgType(arg, spec) |
| 442 | arg_type = f'Type: {arg_type}' if arg_type else '' |
| 443 | available_space = max_str_length - len(arg_type) |
| 444 | arg_type = ( |
| 445 | formatting.EllipsisTruncate(arg_type, available_space, max_str_length)) |
| 446 | |
| 447 | description = '\n'.join(part for part in (arg_type, description) if part) |
| 448 | |
| 449 | return _CreateItem(arg_string, description, indent=SUBSECTION_INDENTATION) |
| 450 | |
| 451 | |
| 452 | def _CreateFlagItem(flag, docstring_info, spec, required=False, |
no test coverage detected