docstr: Takes a class and creates markdown text to document its methods and variables.
          
docstr_tok: ["Takes","a","class","and","creates","markdown","text","to","document","its","methods","and","variables","."]
code: def class2md(self, cls, depth=2):
      """Takes a class and creates markdown text to document its methods and variables."""
  
      section = "#" * depth
      subsection = "#" * (depth + 2)
      clsname = cls.__name__
      modname = cls.__module__
      header = clsname
      path = self.get_src_path(cls)
      doc = self.doc2md(cls)
  
      try:
          init = self.func2md(cls.__init__, clsname=clsname)
      except (ValueError, TypeError):
          # this happens if __init__ is outside the repo
          init = ""
  
      variables = []
      for name, obj in getmembers(
          cls,
          lambda a: not (inspect.isroutine(a) or inspect.ismethod(a)),
      ):
          if not name.startswith("_") and type(obj) == property:
              comments = self.doc2md(obj) or inspect.getcomments(obj)
              comments = "\n %s" % comments if comments else ""
              variables.append(
                  "\n%s %s.%s%s\n"
                  % (subsection, clsname, name, comments)
              )
  
      handlers = []
      for name, obj in getmembers(cls, inspect.ismethoddescriptor):
          if (
              not name.startswith("_")
              and hasattr(obj, "__module__")
              and obj.__module__ == modname
          ):
              handlers.append(
                  "\n%s %s.%s\n *Handler*" % (subsection, clsname, name)
              )
  
      methods = []
      for name, obj in getmembers(
          cls, lambda a: inspect.ismethod(a) or inspect.isfunction(a)
      ):
          if (
              not name.startswith("_")
              and hasattr(obj, "__module__")
              and obj.__module__ == modname
              and name not in handlers
          ):
              methods.append(
                  self.func2md(obj, clsname=clsname, depth=depth + 1)
              )
  
      string = CLASS_TEMPLATE.format(
          section=section,
          header=header,
          path=path,
          doc=doc if doc else "",
          init=init,
          variables="".join(variables),
          handlers="".join(handlers),
          methods="".join(methods),
      )
      return string
  
file_path: keras-vis/docs/md_autogen.py
imports: import os
  import re
  import inspect
  from inspect import getdoc, getargspec, getsourcefile, getsourcelines, getmembers
  from collections import defaultdict
  import sys
label_desc: Use image node_id 6 for calling the MarkdownAPIGenerator obj's underlying member method code with example usage: obj.class2md(cls, depth) and returns: string