class_docstr: Example Builder for sphinx documentation
docstr: Create an RST file for a directory
  
  This will also call generate_example_rst() for every python
  file in the directory
  
  Parameters
  ----------
  path : str
      path to the directory *relative to self.source_dir*
code: def generate_dir_rst(self, path):
      """Create an RST file for a directory
  
      This will also call generate_example_rst() for every python
      file in the directory
  
      Parameters
      ----------
      path : str
          path to the directory *relative to self.source_dir*
      """
      # Get information from the README or other specified file
      try:
          info = open(
              os.path.join(self.source_dir, path, self.dir_info_file)
          ).read()
      except:
          info = os.path.split(path.rstrip("/"))[-1]
          info += "\n" + (len(info) * "-") + "\n"
  
      # Get the footer information
      try:
          footer = open(
              os.path.join(self.source_dir, path, self.dir_footer_file)
          ).read()
      except:
          footer = ""
  
      # Find the index file
      index_file = os.path.join(
          self.target_dir, self.rst_index_filename(path)
      )
      if not os.path.exists(os.path.split(index_file)[0]):
          os.makedirs(os.path.split(index_file)[0])
  
      # Get sub-directories and scripts
      subdirs, scripts = self.parse_directory(path)
  
      # Run the scripts
      for script in scripts:
          self.generate_example_rst(os.path.join(path, script))
  
      outfile = open(index_file, "w")
      outfile.write(
          self.template_index
          % dict(
              sphinx_tag=self.sphinx_tag(path),
              subdir_contents=self.subdir_contents(path, subdirs),
              info=info,
              footer=footer,
              figure_contents=self.figure_contents(path, scripts),
          )
      )
  
      # Recursively probe the sub-directories
      for subdir in subdirs:
          self.generate_dir_rst(os.path.join(path, subdir))
  
imports: import sys
  import os
  import traceback
  import token
  import tokenize
  import gc
  import shutil
  import glob
  import warnings
  import matplotlib
  from matplotlib import image
  from matplotlib import pyplot
label_desc: Use image node_id 16 for calling the ExampleBuilder obj's underlying member method code with example usage: obj.generate_dir_rst(path) without return types