markdown_refdocs/main
class LinkedAstNode
inherits ast.AST
Attributes
- parent (LinkedAstNode)
class ModuleAnalyzer
inherits ast.NodeVisitor
Parse a python module into reference docs using the source code and docstrings
ModuleAnalyzer.__init__()
def __init__(
self,
filename: str,
prefix: str = '',
hide_private: bool = True,
hide_undoc: bool = True,
hide_undoc_args: bool = True,
namespace_headers: bool = False,
):
Args
- filename (
str
) - prefix (
str
) - hide_private (
bool
) - hide_undoc (
bool
) - hide_undoc_args (
bool
) - namespace_headers (
bool
)
ModuleAnalyzer.get_function_def_segment()
Get the source code lines covering the function defintion
def get_function_def_segment(self, node: ast.FunctionDef) -> str:
Args
- node (
ast.FunctionDef
)
Returns
str
ModuleAnalyzer.visit_ClassDef()
convert a class into markdown
def visit_ClassDef(self, node: ast.ClassDef) -> ParsedClass:
Args
- node (
ast.ClassDef
)
Returns
ModuleAnalyzer.visit_FunctionDef()
convert a function into markdown
def visit_FunctionDef(self, node: ast.FunctionDef) -> ParsedFunction:
Args
- node (
ast.FunctionDef
)
Returns
ModuleAnalyzer.visit_Module()
Convert a module into markdown
def visit_Module(self, node: ast.Module) -> ParsedModule:
Args
- node (
ast.Module
)
Returns
parse_module_file()
convert a module into markdown
def parse_module_file(
filename: str,
prefix: str = '',
hide_private: bool = True,
hide_undoc: bool = True,
hide_undoc_args: bool = True,
namespace_headers: bool = False,
) -> ParsedModule:
Args
- filename (
str
): the path to the file to be read - prefix (
str
): the portion of the path that is not part of the package - hide_private (
bool
): hide privated functions, do not document (does not apply to init) - hide_undoc (
bool
): exclude undocumented functions (no docstring) - hide_undoc_args (
bool
): do not list arguments with neither type nor description - namespace_headers (
bool
)
Returns
- ParsedModule: the markdown string for this module