class_docstr: Automatic detection and parsing of API docs to Sphinx-parsable reST
  format.
docstr: Return module sequence discovered from ``self.package_name``.
  
  Parameters
  ----------
  None
  
  Returns
  -------
  mods : sequence
      Sequence of module names within ``self.package_name``
  
  Examples
  --------
  >>> dw = ApiDocWriter('sphinx')
  >>> mods = dw.discover_modules()
  >>> 'sphinx.util' in mods
  True
  >>> dw.package_skip_patterns.append('\.util$')
  >>> 'sphinx.util' in dw.discover_modules()
  False
  >>>
docstr_tok: ["Return","module","sequence","discovered","from","``","self.package_name","``",".","Parameters","--","--","--","--","--","None","Returns","--","--","--","-","mods",":","sequence","Sequence","of","module","names","within","``","self.package_name","``","Examples","--","--","--","--",">",">",">","dw","=","ApiDocWriter","(","'sphinx","'",")",">",">",">","mods","=","dw.discover_modules","(",")",">",">",">","'sphinx.util","'","in","mods","True",">",">",">","dw.package_skip_patterns.append","(","'\\.util","$","'",")",">",">",">","'sphinx.util","'","in","dw.discover_modules","(",")","False",">",">",">"]
code: def discover_modules(self):
      r"""Return module sequence discovered from ``self.package_name``.
  
      Parameters
      ----------
      None
  
      Returns
      -------
      mods : sequence
          Sequence of module names within ``self.package_name``
  
      Examples
      --------
      >>> dw = ApiDocWriter('sphinx')
      >>> mods = dw.discover_modules()
      >>> 'sphinx.util' in mods
      True
      >>> dw.package_skip_patterns.append('\.util$')
      >>> 'sphinx.util' in dw.discover_modules()
      False
      >>>
      """
      modules = [self.package_name]
      # raw directory parsing
      for dirpath, dirnames, filenames in os.walk(self.root_path):
          # Check directory names for packages
          root_uri = self._path2uri(
              os.path.join(self.root_path, dirpath)
          )
  
          # Normally, we'd only iterate over dirnames, but since
          # dipy does not import a whole bunch of modules we'll
          # include those here as well (the *.py filenames).
          filenames = [
              os.path.splitext(f)[0]
              for f in filenames
              if (f.endswith(".py") and not f.startswith("__init__"))
              or f.endswith(".pyx")
          ]
  
          for subpkg_name in dirnames + filenames:
              package_uri = ".".join((root_uri, subpkg_name))
              package_path = self._uri2path(package_uri)
              if package_path and self._survives_exclude(
                  package_uri, "package"
              ):
                  modules.append(package_uri)
  
      return sorted(modules)
  
imports: import ast
  import os
  import re
  from importlib import import_module
  from types import BuiltinFunctionType, FunctionType
  from inspect import ismethod, getmodule
label_desc: Use image node_id 13 for calling the ApiDocWriter obj's underlying member method code with example usage: obj.discover_modules() and returns: sorted