pkg

funcpkg.clean

Remove decorator and hash pipe lines from source code

1
2
3
4
def clean(
    src: str  # source code to clean
) -> str:
    """Remove decorator and hash pipe lines from source code"""
funcpkg.write

Write parts to file, filtering None values and joining with blank lines.

1
2
3
4
def write(
    p: str  # path to write to
):
    """Write parts to file, filtering None values and joining with blank lines."""
funcpkg.write_mod

Write module file with imports, constants, and exports.

1
2
3
4
5
6
def write_mod(
    path,  # output file path
    nodes: list,  # list of Node objects to write
    mod_names: list  # list of module names for import rewriting
):
    """Write module file with imports, constants, and exports."""
funcpkg.rewrite_imports

Rewrite cross-notebook imports to relative package imports

1
2
3
4
5
def rewrite_imports(
    src: str,  # source code to rewrite
    mod_names: list  # list of module names
) -> str:
    """Rewrite cross-notebook imports to relative package imports"""
funcpkg.write_init

Generate and write __init__.py file with metadata and exports.

1
2
3
4
5
6
def write_init(
    path: str | Path,  # path to write __init__.py file
    meta: dict,  # metadata dict with desc, version, author
    mods: list  # list of (name nodes) tuples
):
    """Generate and write __init__.py file with metadata and exports."""