def build(<EOL>root, source_module, output_dir,<EOL>json_dump=False, ignore_modules=None, index_filename='<STR_LIT:index>'<EOL>):
if root.endswith('<STR_LIT:/>'):<EOL><INDENT>root = root[:-<NUM_LIT:1>]<EOL><DEDENT>if ignore_modules is None:<EOL><INDENT>ignore_modules = []<EOL><DEDENT>elif isinstance(ignore_modules, str):<EOL><INDENT>ignore_modules = ignore_modules.split('<STR_LIT:U+002C>')<EOL><DEDENT>if output_dir.startswith('<STR_LIT:/>'):<EOL><INDENT>output_dir = output_dir[<NUM_LIT:1>:]<EOL><DEDENT>if not output_dir.endswith('<STR_LIT:/>'):<EOL><INDENT>output_dir = '<STR_LIT>'.format(output_dir)<EOL><DEDENT>output_dir = '<STR_LIT>'.format(root, output_dir)<EOL>if not path.isdir(output_dir):<EOL><INDENT>makedirs(output_dir)<EOL><DEDENT>if source_module == '<STR_LIT:.>':<EOL><INDENT>source_dir = '<STR_LIT>'.format(root)<EOL><DEDENT>else:<EOL><INDENT>source_dir = '<STR_LIT>'.format(root, source_module.replace('<STR_LIT:.>', os.sep))<EOL><DEDENT>chdir(source_dir)<EOL>module_list = _build_module_list(<EOL>source_module,<EOL>index_filename=index_filename,<EOL>ignore_modules=ignore_modules<EOL>)<EOL>chdir(root)<EOL>_parse_module_list(module_list)<EOL>chdir(output_dir)<EOL>_write_docs(module_list, output_dir)<EOL>if json_dump:<EOL><INDENT>print(json.dumps(module_list, indent=<NUM_LIT:4>))<EOL><DEDENT>
Build markdown documentation from a directory and/or python module.

# ignore_modules: takes a list of module names to ignore
# index_filename: __init__.py output (default index.md), use README.md for github indexes