docstr: Given a diff structure, generate a string of paths separated
  by new lines and grouped together by their state.
  
  A group's header is colored to enhance readability, for example:
  
      Added:
          another_file.txt
          backup.tar
          dir/
          dir/1
  
  An example of a diff formatted when entries contain hash:
  
      Added:
          d3b07384 foo
  
      Modified:
          c157a790..f98bf6f1 bar
  
  If a group has no entries, it won't be included in the result.
  
  At the bottom, include a summary with the number of files per state.
docstr_tok: ["Given","a","diff","structure",",","generate","a","string","of","paths","separated","by","new","lines","and","grouped","together","by","their","state",".","A","group","'s","header","is","colored","to","enhance","readability",",","for","example",":","Added",":","another_file.txt","backup.tar","dir\/","dir\/1","An","example","of","a","diff","formatted","when","entries","contain","hash",":","Added",":","d3b07384","foo","Modified",":","c157a790","..","f98bf6f1","bar","If","a","group","has","no","entries",",","it","wo","n't","be","included","in","the","result",".","At","the","bottom",",","include","a","summary","with","the","number","of","files","per","state","."]
code: def _show_diff(diff, hide_missing=False):
      """
      Given a diff structure, generate a string of paths separated
      by new lines and grouped together by their state.
  
      A group's header is colored to enhance readability, for example:
  
          Added:
              another_file.txt
              backup.tar
              dir/
              dir/1
  
      An example of a diff formatted when entries contain hash:
  
          Added:
              d3b07384 foo
  
          Modified:
              c157a790..f98bf6f1 bar
  
      If a group has no entries, it won't be included in the result.
  
      At the bottom, include a summary with the number of files per state.
      """
  
      colors = {
          "added": "green",
          "modified": "yellow",
          "deleted": "red",
          "renamed": "green",
          "not in cache": "yellow",
      }
  
      summary = {}
  
      states = ["added", "deleted", "renamed", "modified"]
      if not hide_missing:
          states.append("not in cache")
      for state in states:
          summary[state] = 0
          entries = diff[state]
  
          if not entries:
              continue
  
          header = state.capitalize()
          ui.write(f"[{colors[state]}]{header}[/]:", styled=True)
  
          for entry in entries:
              path = entry["path"]
              if isinstance(path, dict):
                  path = f"{path['old']} -> {path['new']}"
              checksum = entry.get("hash")
              summary[state] += 1 if not path.endswith(os.sep) else 0
              ui.write(
                  "{space}{checksum}{separator}{path}".format(
                      space="    ",
                      checksum=_digest(checksum) if checksum else "",
                      separator="  " if checksum else "",
                      path=path,
                  )
              )
  
          ui.write()
  
      if not sum(summary.values()):
          return
  
      states_summary = ", ".join(
          f"{summary[state]} {state}"
          for state in states
          if summary[state] > 0
      )
      ui.write("files summary:", states_summary)
  
file_path: dvc/dvc/commands/diff.py
imports: import os
  from dvc.cli import completion, formatter
  from dvc.cli.command import CmdBase
  from dvc.cli.utils import append_doc_link
  from dvc.log import logger
  from dvc.ui import ui
label_desc: Use image node_id 1 for calling the CmdDiff obj's underlying member method code with example usage: obj._show_diff(diff, hide_missing) without return types