def __str__()

in tools/tensorflow_docs/tools/nblint/linter.py [0:0]


  def __str__(self):
    """Print the entire status report of all entries to console.

    Arrange and format entries for reporting to console. If
    `LinterStatus.verbose` is True, display group member entries in addition to
    the cumulative group status. Called as: `print(linter_status)`.

    Returns:
      String containing the entire lint report.
    """
    # Sort group entries to display nested underneath parent.
    groups = {}
    # Can skip if not displaying.
    if self.verbose:
      for entry in self._status_list:
        if entry.is_group_entry:
          if entry.group in groups:
            groups[entry.group].append(entry)
          else:
            groups[entry.group] = [entry]

    # Filter top-level entries.
    root_entries = [obj for obj in self._status_list if not obj.is_group_entry]
    output = ""

    for entry in root_entries:
      # Print top-level entry.
      status = self._format_status(entry)
      name = f"{entry.lint.style}::{entry.name}"
      msg = f" | {entry.lint.message}" if entry.lint.message else ""
      output += f"{status} | {name}{msg}\n"

      # Print child entries, if applicable.
      if self.verbose and entry.group in groups:
        output += "[All results]\n"
        for child in groups[entry.group]:
          output += f"- {self._format_status(child)} | {child.name}\n"

        output += "\n"

    # Print any stderror messages from within lint functions.
    output += self._format_lint_messages()

    return output