class_docstr: Class for automatic detection and parsing of API docs
  to Sphinx-parsable reST format
class_docstr_tok: ["Class","for","automatic","detection","and","parsing","of","API","docs","to","Sphinx-parsable","reST","format"]
docstr: Make autodoc documentation template string for a module
  
  Parameters
  ----------
  uri : string
      python location of module - e.g 'sphinx.builder'
  
  Returns
  -------
  S : string
      Contents of API doc
docstr_tok: ["Make","autodoc","documentation","template","string","for","a","module","Parameters","--","--","--","--","--","uri",":","string","python","location","of","module","-","e.g","'sphinx.builder'","Returns","--","--","--","-","S",":","string","Contents","of","API","doc"]
code: def generate_api_doc(self, uri):
      """Make autodoc documentation template string for a module
  
      Parameters
      ----------
      uri : string
          python location of module - e.g 'sphinx.builder'
  
      Returns
      -------
      S : string
          Contents of API doc
      """
      # get the names of all classes and functions
      functions, classes = self._parse_module(uri)
      if not len(functions) and not len(classes):
          print("WARNING: Empty - " + uri)  # dbg
          return ""
  
      # Make a shorter version of the uri that omits the package name for
      # titles
      uri_short = re.sub(r"^%s\." % self.package_name, "", uri)
  
      ad = ".. AUTO-GENERATED FILE -- DO NOT EDIT!\n\n"
  
      chap_title = uri_short
      ad += (
          chap_title
          + "\n"
          + self.rst_section_levels[1] * len(chap_title)
          + "\n\n"
      )
  
      # Set the chapter title to read 'module' for all modules except for the
      # main packages
      if "." in uri:
          title = "Module: :mod:`" + uri_short + "`"
      else:
          title = ":mod:`" + uri_short + "`"
      ad += title + "\n" + self.rst_section_levels[2] * len(title)
  
      if len(classes):
          ad += f"\nInheritance diagram for ``{uri}``:\n\n"
          ad += f".. inheritance-diagram:: {uri} \n"
          ad += "   :parts: 3\n"
  
      ad += "\n.. automodule:: " + uri + "\n"
      ad += "\n.. currentmodule:: " + uri + "\n"
      multi_class = len(classes) > 1
      multi_fx = len(functions) > 1
      if multi_class:
          ad += (
              "\n"
              + "Classes"
              + "\n"
              + self.rst_section_levels[2] * 7
              + "\n"
          )
      elif len(classes) and multi_fx:
          ad += (
              "\n"
              + "Class"
              + "\n"
              + self.rst_section_levels[2] * 5
              + "\n"
          )
      for c in classes:
          ad += (
              "\n:class:`"
              + c
              + "`\n"
              + self.rst_section_levels[multi_class + 2] * (len(c) + 9)
              + "\n\n"
          )
          ad += "\n.. autoclass:: " + c + "\n"
          # must NOT exclude from index to keep cross-refs working
          ad += (
              "  :members:\n"
              "  :undoc-members:\n"
              "  :show-inheritance:\n"
              "  :inherited-members:\n"
              "\n"
              "  .. automethod:: __init__\n"
          )
      if multi_fx:
          ad += (
              "\n"
              + "Functions"
              + "\n"
              + self.rst_section_levels[2] * 9
              + "\n\n"
          )
      elif len(functions) and multi_class:
          ad += (
              "\n"
              + "Function"
              + "\n"
              + self.rst_section_levels[2] * 8
              + "\n\n"
          )
      for f in functions:
          # must NOT exclude from index to keep cross-refs working
          ad += "\n.. autofunction:: " + uri + "." + f + "\n\n"
      return ad
  
file_path: nipy/tools/apigen.py
imports: import os
  import re
label_desc: Use image node_id 9 for calling the ApiDocWriter obj's underlying member method code with example usage: obj.generate_api_doc(uri) and returns: ad, str