Create delightful software with Jupyter Notebooks
npx @tessl/cli install tessl/pypi-nbdev@2.4.0nbdev is a notebook-driven development platform that enables developers to create high-quality software packages directly from Jupyter notebooks. It provides comprehensive tooling for automatic documentation generation, seamless publishing to PyPI and conda repositories, two-way synchronization between notebooks and plain-text source code, parallel test execution, built-in continuous integration, and git-friendly notebook handling.
pip install nbdevimport nbdev
from nbdev import nbdev_export, show_docCommon workflow imports:
from nbdev.config import get_config, nbdev_create_config
from nbdev.export import nb_export
from nbdev.test import nbdev_test
from nbdev.clean import nbdev_cleanimport nbdev
from nbdev.config import get_config, nbdev_create_config
from nbdev.export import nb_export
# Create a new nbdev project
nbdev_create_config()
# Get current configuration
config = get_config()
print(f"Project: {config.lib_name}")
print(f"Version: {config.version}")
# Export notebooks to Python modules
nb_export()nbdev is built around several key architectural components:
settings.ini filesThe processing pipeline uses a processor pattern where notebooks pass through configurable stages (processors) that can transform, validate, or extract information from cells.
Project setup, configuration management, and bootstrapping functionality for new nbdev projects.
def nbdev_create_config(
repo: str = None,
branch: str = None,
user: str = None,
author: str = None,
author_email: str = None,
description: str = None,
path: str = '.',
cfg_name: str = 'settings.ini',
**kwargs
): ...
def get_config(cfg_name: str = 'settings.ini', path=None): ...
def config_key(c, default=None, path=True, missing_ok=None): ... # Deprecated
def is_nbdev() -> bool: ...Convert Jupyter notebook cells to Python modules with proper imports, documentation, and structure.
def nb_export(
nbname: str,
lib_path: str = None,
procs=None,
name: str = None,
mod_maker=ModuleMaker,
debug: bool = False,
solo_nb: bool = False
): ...
def black_format(cell, force: bool = False): ...
class ExportModuleProc: ...Generate comprehensive API documentation and create documentation sites from notebooks.
def nbdev_export(path: str = None, procs=["black_format"], **kwargs): ...
def show_doc(sym, renderer=None, name: str = None, title_level: int = 3): ...
def create_index(url, pre=None): ...
class NbdevLookup(strip_libs=None, incl_libs=None, skip_mods=None, ns=None): ...Run tests defined in notebook cells across your project in parallel.
def nbdev_test(
path: str = None,
flags: str = '',
n_workers: int = None,
timing: bool = False,
do_print: bool = False,
pause: float = 0.01,
ignore_fname: str = '.notest',
**kwargs
): ...
def test_nb(
fn,
skip_flags=None,
force_flags=None,
do_print: bool = False,
showerr: bool = True,
basepath=None
): ...Clean notebook metadata, outputs, and configure git integration for notebooks.
def nbdev_clean(
fname: str = None,
clear_all: bool = False,
disp: bool = False,
stdin: bool = False
): ...
def clean_nb(
nb,
clear_all: bool = False,
allowed_metadata_keys: list = None,
allowed_cell_metadata_keys: list = None,
clean_ids: bool = True
): ...
def nbdev_trust(fname: str = None, force_all: bool = False): ...
def nbdev_install_hooks(): ...Synchronize between notebooks and plain Python source code for IDE compatibility.
def nbdev_update(fname: str = None): ...
def absolute_import(name, fname, level): ...Handle git merge conflicts and notebook-specific version control concerns.
def nbdev_merge(base: str, ours: str, theirs: str, path: str): ...
def nbdev_fix(
nbname: str,
outname: str = None,
nobackup: bool = True,
theirs: bool = False,
noprint: bool = False
): ...
def unpatch(s: str): ...Automated publishing to PyPI, GitHub releases, and changelog generation.
class Release(owner=None, repo=None, token=None, **groups): ...
def release_git(token: str = None): ...
def release_gh(token: str = None): ...
def changelog(debug: bool = False, repo: str = None): ...Development server, project migration, and various utility functions.
def nbdev_new(**kwargs): ...
def nbdev_migrate(path: str = None, no_skip: bool = False): ...
def proc_nbs(
path: str = '',
n_workers: int = None,
force: bool = False,
file_glob: str = '',
file_re: str = '',
**kwargs
): ...nbdev provides comprehensive CLI commands:
# Create new project
nbdev_new
# Export notebooks to modules
nbdev_export
# Run tests
nbdev_test
# Clean notebooks
nbdev_clean
# Install git hooks
nbdev_install_hooks
# Update from source
nbdev_update
# Merge conflicts
nbdev_merge
# Trust notebooks
nbdev_trust