def core_module_docstrings(<EOL>include_core=True, include_user=False, config=None, format="<STR_LIT>"<EOL>):
paths = {}<EOL>docstrings = {}<EOL>if include_core:<EOL><INDENT>for file in os.listdir(modules_directory()):<EOL><INDENT>if file.endswith("<STR_LIT>"):<EOL><INDENT>name = file[:-<NUM_LIT:3>]<EOL>if name != "<STR_LIT>":<EOL><INDENT>paths[name] = (os.path.join(modules_directory(), file), "<STR_LIT>")<EOL><DEDENT><DEDENT><DEDENT><DEDENT>if include_user:<EOL><INDENT>for include_path in sorted(config["<STR_LIT>"]):<EOL><INDENT>for file in sorted(os.listdir(include_path)):<EOL><INDENT>if not file.endswith("<STR_LIT>"):<EOL><INDENT>continue<EOL><DEDENT>name = file[:-<NUM_LIT:3>]<EOL>paths[name] = (os.path.join(include_path, file), "<STR_LIT:user>")<EOL><DEDENT><DEDENT><DEDENT>for name in paths:<EOL><INDENT>path, module_type = paths[name]<EOL>with open(path) as f:<EOL><INDENT>try:<EOL><INDENT>module = ast.parse(f.read())<EOL><DEDENT>except SyntaxError:<EOL><INDENT>continue<EOL><DEDENT>raw_docstring = ast.get_docstring(module)<EOL>if raw_docstring is None:<EOL><INDENT>continue<EOL><DEDENT>parts = re.split("<STR_LIT>", raw_docstring, flags=re.M)<EOL>docstring = parts[<NUM_LIT:0>]<EOL>if format == "<STR_LIT>":<EOL><INDENT>docstring = [<EOL>d for d in _from_docstring_md(str(docstring).strip().split("<STR_LIT:\n>"))<EOL>]<EOL><DEDENT>elif format == "<STR_LIT>":<EOL><INDENT>docstring = [<EOL>d for d in _from_docstring_rst(str(docstring).strip().split("<STR_LIT:\n>"))<EOL>]<EOL><DEDENT>else:<EOL><INDENT>raise Exception("<STR_LIT>")<EOL><DEDENT>docstrings[name] = docstring + ["<STR_LIT:\n>"]<EOL><DEDENT><DEDENT>return docstrings<EOL>
Get docstrings for all core modules and user ones if requested
returns a dict of {<module_name>: <docstring>}