How to use the fire.custom_descriptions.NeedsCustomDescription function in fire

To help you get started, we’ve selected a few fire examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github google / python-fire / fire / helptext.py View on Github external
def _DescriptionSection(component, info):
  """The "Description" sections of the help string.

  Args:
    component: The component to produce the description section for.
    info: The info dict for the component of interest.

  Returns:
    Returns the description if available. If not, returns the summary.
    If neither are available, returns None.
  """
  # If the docstring is one of the messy builtin docstrings, set it to None.
  # TODO(dbieber): In follow up commits we can add in replacement docstrings.
  if custom_descriptions.NeedsCustomDescription(component):
    return None

  summary = _GetSummary(info)
  description = _GetDescription(info)
  text = description or summary or None

  if text:
    return ('DESCRIPTION', text)
  else:
    return None
github google / python-fire / fire / helptext.py View on Github external
def _MakeUsageDetailsSection(action_group):
  """Creates a usage details section for the provided action group."""
  item_strings = []
  for name, member in action_group.GetItems():
    info = inspectutils.Info(member)
    item = name
    docstring_info = info.get('docstring_info')
    if (docstring_info
        and not custom_descriptions.NeedsCustomDescription(member)):
      summary = docstring_info.summary
    else:
      summary = None
    item = _CreateItem(name, summary)
    item_strings.append(item)
  return (action_group.plural.upper(),
          _NewChoicesSection(action_group.name.upper(), item_strings))
github google / python-fire / fire / helptext.py View on Github external
def _NameSection(component, info, trace=None, verbose=False):
  """The "Name" section of the help string."""

  # Only include separators in the name in verbose mode.
  current_command = _GetCurrentCommand(trace, include_separators=verbose)
  summary = _GetSummary(info)

  # If the docstring is one of the messy builtin docstrings, don't show summary.
  # TODO(dbieber): In follow up commits we can add in replacement summaries.
  if custom_descriptions.NeedsCustomDescription(component):
    summary = None

  if summary:
    text = current_command + ' - ' + summary
  else:
    text = current_command
  return ('NAME', text)