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 custom_descriptions.NeedsCustomDescription(component): available_space = LINE_LENGTH - SECTION_INDENTATION description = custom_descriptions.GetDescription(component, available_space, LINE_LENGTH) summary = custom_descriptions.GetSummary(component, available_space, LINE_LENGTH) else: description = _GetDescription(info) summary = _GetSummary(info) # Fall back to summary if description is not available. text = description or summary or None if text: return ('DESCRIPTION', text) else: return None
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 elif custom_descriptions.NeedsCustomDescription(member): summary = custom_descriptions.GetSummary( member, LINE_LENGTH - SECTION_INDENTATION, LINE_LENGTH) else: summary = None item = _CreateItem(name, summary) item_strings.append(item) return (action_group.plural.upper(), _NewChoicesSection(action_group.name.upper(), item_strings))
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)
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, show custom one. if custom_descriptions.NeedsCustomDescription(component): available_space = LINE_LENGTH - SECTION_INDENTATION - len(current_command + ' - ') summary = custom_descriptions.GetSummary(component, available_space, LINE_LENGTH) if summary: text = current_command + ' - ' + summary else: text = current_command return ('NAME', text)
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