genpydoc.extractor package¶
Submodules¶
genpydoc.extractor.extract module¶
genpydoc.extractor.visit module¶
- class genpydoc.extractor.visit.CovNode(name: str, path: str, level: int, lineno: int, covered: bool, node_type: str, is_nested_func: bool, is_nested_cls: bool, parent: Self, file: str, docstring: str | None = None, code: str | None = None)¶
Bases:
objectCoverage of an AST Node.
- Parameters:
name (str) – Name of node (module, class, method or function names).
path (str) – Pseudo-import path to node (i.e.
sample.py: MyClass.my_method).level (int) – Level of recursiveness/indentation.
lineno (int) – Line number of class, method, or function.
covered (bool) – Has a docstring.
node_type (str) – Type of node (e.g “module”, “class”, or “function”).
is_nested_func (bool) – If the node itself is a nested function or method.
is_nested_cls (bool) – If the node itself is a nested class.
docstring (str) – The docstring of the node.
code (str) – The source code of the node.
parent (CovNode) – Parent node of current CovNode, if any.
- code: str | None¶
- covered: bool¶
- docstring: str | None¶
- file: str¶
- is_nested_cls: bool¶
- is_nested_func: bool¶
- level: int¶
- lineno: int¶
- name: str¶
- node_type: str¶
- parent: Self¶
- path: str¶
- class genpydoc.extractor.visit.Visitor(filename: str, config: Config, source: str)¶
Bases:
NodeVisitorVisitor is a NodeVisitor that traverses a Python AST to collect information about docstrings for modules, classes, and functions. During traversal, it builds CovNode records for each visitable node, including metadata such as the node’s name, path, type, location, and associated docstring (when present). It also provides sanitized code with any docstrings removed and applies configuration driven ignore rules (e.g., private/semiprivate, __init__, magic methods, property decorators, overloads).
- filename¶
The name of the file being analyzed.
- Type:
str
- source¶
The full source code corresponding to the AST being visited.
- Type:
str
- source: str¶
- visit_AsyncFunctionDef(node: AsyncFunctionDef | FunctionDef | ClassDef) None¶
Visit async function or method for docstrings.
- Parameters:
node (ast.AsyncFunctionDef) – an async function/method AST node.
- visit_ClassDef(node: AsyncFunctionDef | FunctionDef | ClassDef) None¶
Visit class for docstrings.
- Parameters:
node (ast.ClassDef) – a class AST node.
- visit_FunctionDef(node: AsyncFunctionDef | FunctionDef | ClassDef) None¶
Visit function or method for docstrings.
- Parameters:
node (ast.FunctionDef) – a function/method AST node.
- visit_Module(node: AsyncFunctionDef | FunctionDef | ClassDef | Module) None¶
Visit module for docstrings.
- Parameters:
node (ast.Module) – a module AST node.