def doc_module(module_name, module, output_dir, source_location, leaf):
path = pathlib.Path(output_dir).joinpath(*module.__name__.split("<STR_LIT:.>"))<EOL>available_classes = get_available_classes(module)<EOL>deffed_classes = get_classes(module)<EOL>deffed_funcs = get_funcs(module)<EOL>deffed_enums = get_enums(module)<EOL>alias_funcs = available_classes - deffed_classes<EOL>if leaf:<EOL><INDENT>doc_path = path.with_suffix("<STR_LIT>")<EOL><DEDENT>else:<EOL><INDENT>doc_path = path / "<STR_LIT>"<EOL><DEDENT>doc_path.parent.mkdir(parents=True, exist_ok=True)<EOL>module_path = "<STR_LIT:/>".join(module.__name__.split("<STR_LIT:.>"))<EOL>doc = [f"<STR_LIT>" + "<STR_LIT:\n>"]<EOL>module_doc = module.__doc__<EOL>if module_doc is not None:<EOL><INDENT>doc += to_doc(module.__name__, module, <NUM_LIT:1>, source_location)<EOL><DEDENT>else:<EOL><INDENT>doc.append(f"<STR_LIT>")<EOL><DEDENT>doc.append("<STR_LIT>")<EOL>for cls_name, cls in sorted(deffed_enums) + sorted(deffed_classes):<EOL><INDENT>doc += to_doc(cls_name, cls, <NUM_LIT:2>, source_location)<EOL>class_methods = [<EOL>x<EOL>for x in inspect.getmembers(cls, inspect.isfunction)<EOL>if (not x[<NUM_LIT:0>].startswith("<STR_LIT:_>")) and deffed_here(x[<NUM_LIT:1>], cls)<EOL>]<EOL>class_methods += inspect.getmembers(cls, lambda o: isinstance(o, property))<EOL>if len(class_methods) > <NUM_LIT:0>:<EOL><INDENT>doc.append("<STR_LIT>")<EOL>for method_name, method in class_methods:<EOL><INDENT>doc += to_doc(method_name, method, <NUM_LIT:4>, source_location)<EOL><DEDENT><DEDENT><DEDENT>for fname, func in sorted(deffed_funcs):<EOL><INDENT>doc += to_doc(fname, func, <NUM_LIT:2>, source_location)<EOL><DEDENT>return doc_path.absolute(), "<STR_LIT>".join(doc)<EOL>
Document a module

Parameters
----------
module_name : str
module : module
output_dir : str
source_location : str
leaf : bool