def func2md(self, func, clsname=None, names=None, depth=<NUM_LIT:3>):
section = "<STR_LIT:#>" * depth<EOL>if names is None:<EOL><INDENT>names = [func.__name__]<EOL><DEDENT>funcname = "<STR_LIT:U+002CU+0020>".join(names)<EOL>escfuncname = "<STR_LIT:U+002CU+0020>".join(["<STR_LIT>" % funcname if funcname.startswith("<STR_LIT:_>") else funcname for funcname in names])<EOL>header = "<STR_LIT>" % ("<STR_LIT>" % clsname if clsname else "<STR_LIT>", escfuncname)<EOL>path = self.get_src_path(func)<EOL>doc = self.doc2md(func)<EOL>args, kwargs = [], []<EOL>spec = getargspec(func)<EOL>vargsname, kwargsname = spec.varargs, spec.keywords<EOL>vargs = list(make_iter(spec.args)) if spec.args else []<EOL>defaults = list(make_iter(spec.defaults)) if spec.defaults else []<EOL>while vargs:<EOL><INDENT>if vargs and vargs[<NUM_LIT:0>] == "<STR_LIT>":<EOL><INDENT>args.append(vargs.pop(<NUM_LIT:0>))<EOL><DEDENT>elif len(vargs) > len(defaults):<EOL><INDENT>args.append(vargs.pop(<NUM_LIT:0>))<EOL><DEDENT>else:<EOL><INDENT>default = defaults.pop(<NUM_LIT:0>)<EOL>if isinstance(default, str):<EOL><INDENT>default = "<STR_LIT>" % default<EOL><DEDENT>else:<EOL><INDENT>default = "<STR_LIT:%s>" % str(default)<EOL><DEDENT>kwargs.append((vargs.pop(<NUM_LIT:0>), default))<EOL><DEDENT><DEDENT>if args:<EOL><INDENT>args = "<STR_LIT:U+002CU+0020>".join("<STR_LIT:%s>" % arg for arg in args)<EOL><DEDENT>if kwargs:<EOL><INDENT>kwargs = "<STR_LIT:U+002CU+0020>".join("<STR_LIT>" % kwarg for kwarg in kwargs)<EOL>if args:<EOL><INDENT>kwargs = "<STR_LIT:U+002CU+0020>" + kwargs<EOL><DEDENT><DEDENT>if vargsname:<EOL><INDENT>vargsname = "<STR_LIT>" % vargsname<EOL>if args or kwargs:<EOL><INDENT>vargsname = "<STR_LIT:U+002CU+0020>" + vargsname<EOL><DEDENT><DEDENT>if kwargsname:<EOL><INDENT>kwargsname = "<STR_LIT>" % kwargsname<EOL>if args or kwargs or vargsname:<EOL><INDENT>kwargsname = "<STR_LIT:U+002CU+0020>" + kwargsname<EOL><DEDENT><DEDENT>_FUNCDEF = "<STR_LIT>"<EOL>funcdef = _FUNCDEF.format(funcname=funcname,<EOL>args=args or "<STR_LIT>",<EOL>kwargs=kwargs or "<STR_LIT>",<EOL>vargs=vargsname or "<STR_LIT>",<EOL>vkwargs=kwargsname or "<STR_LIT>")<EOL>lmax = <NUM_LIT><EOL>if len(funcdef) > lmax:<EOL><INDENT>split = funcdef.split("<STR_LIT:(>", <NUM_LIT:1>)<EOL>rest = split[<NUM_LIT:1>]<EOL>args = rest.split("<STR_LIT:U+002CU+0020>")<EOL>funcname = "<STR_LIT:(>".join(split[:<NUM_LIT:1>]) + "<STR_LIT:(>"<EOL>lline = len(funcname)<EOL>parts = []<EOL>for arg in args:<EOL><INDENT>larg = len(arg)<EOL>if larg > lmax - <NUM_LIT:5>:<EOL><INDENT>parts.append(arg)<EOL><DEDENT>elif lline + larg > lmax:<EOL><INDENT>parts.append("<STR_LIT>" + arg)<EOL>lline = <NUM_LIT:0><EOL><DEDENT>else:<EOL><INDENT>parts.append(arg)<EOL><DEDENT>lline += len(parts[-<NUM_LIT:1>])<EOL><DEDENT>funcdef = funcname + "<STR_LIT:U+002CU+0020>".join(parts)<EOL><DEDENT>string = FUNC_TEMPLATE.format(section=section,<EOL>header=header,<EOL>funcdef=funcdef,<EOL>path=path,<EOL>doc=doc if doc else "<STR_LIT>")<EOL>return string<EOL>
Takes a function (or method) and documents it.

        Args:
            clsname (str, optional): class name to prepend to funcname.
            depth (int, optional): number of ### to append to function name