code: def generate_api_docs(
      package, api_dir, clean=False, printlog=True, ignore_packages=None
  ):
      """Generate a module level API documentation of a python package.
  
      Description
      -----------
      Generates markdown API files for each module in a Python package whereas
      the structure is as follows:
      `package/package.subpackage/package.subpackage.module.md`
  
      Parameters
      -----------
      package : Python package object
      api_dir : str
          Output directory path for the top-level package directory
      clean : bool (default: False)
          Removes previously existing API directory if True.
      printlog : bool (default: True)
          Prints a progress log to the standard output screen if True.
      ignore_packages : iterable or None (default: None)
          Iterable (list, set, tuple) that contains the names of packages
          and subpackages to ignore or skip. For instance, if the
          images subpackage in mlxtend is supposed to be split, provide the
          argument `{mlxtend.image}`.
  
      """
      if printlog:
          print("\n\nGenerating Module Files\n%s\n" % (50 * "="))
  
      prefix = package.__name__ + "."
  
      # clear the previous version
      if clean:
          if os.path.isdir(api_dir):
              shutil.rmtree(api_dir)
  
      # get subpackages
      api_docs = {}
      for importer, pkg_name, is_pkg in pkgutil.iter_modules(
          package.__path__, prefix
      ):
          if (
              ignore_packages is not None
              and pkg_name in ignore_packages
          ):
              if printlog:
                  print("ignored %s" % pkg_name)
              continue
          if is_pkg:
              subpackage = __import__(pkg_name, fromlist="dummy")
              prefix = subpackage.__name__ + "."
  
              # get functions and classes
              classes, functions = get_functions_and_classes(subpackage)
  
              target_dir = os.path.join(api_dir, subpackage.__name__)
  
              # create the subdirs
              if not os.path.isdir(target_dir):
                  os.makedirs(target_dir)
                  if printlog:
                      print("created %s" % target_dir)
  
              # create markdown documents in memory
              for obj in classes + functions:
                  md_path = os.path.join(target_dir, obj[0]) + ".md"
                  if md_path not in api_docs:
                      api_docs[md_path] = object_to_markdownpage(
                          obj_name=obj[0], obj=obj[1], s=""
                      )
                  else:
                      api_docs[md_path] += object_to_markdownpage(
                          obj_name=(obj[0]), obj=obj[1], s=""
                      )
  
      # write to files
      for d in sorted(api_docs):
          prev = ""
          if os.path.isfile(d):
              with open(d, "r") as f:
                  prev = f.read()
              if prev == api_docs[d]:
                  msg = "skipped"
              else:
                  msg = "updated"
          else:
              msg = "created"
  
          if msg != "skipped":
              with open(d, "w") as f:
                  f.write(api_docs[d])
  
          if printlog:
              print("%s %s" % (msg, d))
  
file_path: mlxtend/docs/make_api.py
imports: import inspect
  import os
  import pkgutil
  import shutil
  import sys
label_desc: Use image node_id 9 for calling a global function with example usage: generate_api_docs(package, api_dir, clean, printlog, ignore_packages) without return types