Extract inline comment following an identifier on a source line.
1
2
3
4
5
6
def inline_doc(
ls: list[str], # source code lines
ln: int, # line number to search
name: str # identifier name to match before comment
) -> str:
"""Extract inline comment following an identifier on a source line."""
Extract parameters from a function node with inline documentation.
1
2
3
4
5
def parse_params(
fn, # function node to extract parameters from
ls # source lines for inline doc extraction
) -> list[Param]:
"""Extract parameters from a function node with inline documentation."""
Extract hash pipe directives from line immediately after export decorator
1
2
3
4
5
def parse_hash_pipe(
ls: list, # source code lines
export_dec # the export decorator node
) -> list[str]:
"""Extract hash pipe directives from line immediately after export decorator"""
classread.parse_class_params
Extract parameters from __init__ method if present, else class attributes.
1
2
3
4
class parse_class_params:
"""Extract parameters from __init__ method if present, else class attributes."""
n: ast.ClassDef # class node to extract params from
ls: list # source lines for inline doc extraction
classread.parse_class_methods
Extract methods from a class definition.
1
2
3
4
class parse_class_methods:
"""Extract methods from a class definition."""
n: ast.ClassDef
ls: list
Extract return type annotation and inline documentation from function node.
1
2
3
4
5
def parse_ret(
fn, # function node to parse return annotation from
ls # source code lines
) -> tuple[str, str] | None:
"""Extract return type annotation and inline documentation from function node."""
Extract source code including decorators from AST node.
1
2
3
4
5
def src_with_decs(
n, # AST node with potential decorators
ls # source code lines
) -> str:
"""Extract source code including decorators from AST node."""
Check if decorator marks a node for export.
1
2
3
4
5
def is_export(
d, # decorator node to check
cfg: Config # configuration object
) -> bool:
"""Check if decorator marks a node for export."""
Extract import node from AST.
1
2
3
4
5
def parse_import(
n: ast.AST, # AST node to check
ls: list # source lines (unused but kept for consistent interface)
) -> Node | None:
"""Extract import node from AST."""
Extract constant definition (dunder-prefixed, non-dunder-suffixed).
1
2
3
4
5
def parse_const(
n: ast.AST, # AST node to check
ls: list # source lines (unused)
) -> Node | None:
"""Extract constant definition (dunder-prefixed, non-dunder-suffixed)."""
Extract exported function or class decorated with export decorators from config.
1
2
3
4
5
class parse_export:
"""Extract exported function or class decorated with export decorators from config."""
n: ast.AST # AST node to check
ls: list # source lines for inline doc and decorators
cfg: Config # configuration object
Extract importable nodes from an AST node.
1
2
3
4
5
6
def parse_node(
n: ast.AST, # AST node to parse
src: str, # full source code text
cfg: Config # configuration object
):
"""Extract importable nodes from an AST node."""
Parse a Python file and extract all nodes.
1
2
3
4
5
6
def parse_file(
p: str | Path, # path to Python file to parse
module: str='', # module name to assign to nodes
root: str='.' # root directory containing pyproject.toml
) -> list[Node]:
"""Parse a Python file and extract all nodes."""
Read project metadata from pyproject.toml.
1
2
3
4
def read_meta(
root='.' # project root directory containing pyproject.toml
) -> dict:
"""Read project metadata from pyproject.toml."""
Extract notebook name from file path, skipping hidden, test, and configured prefix files.
1
2
3
4
5
def nb_name(
f: Path, # file path to extract notebook name from
root: str='.' # root directory containing pyproject.toml
) -> str | None:
"""Extract notebook name from file path, skipping hidden, test, and configured prefix files."""
Scan notebooks directory and extract metadata and module definitions.
1
2
3
4
def scan(
root='.' # root directory containing pyproject.toml
):
"""Scan notebooks directory and extract metadata and module definitions."""