smalldocs.browser
imports
imports(notebook: dict) -> set[str]Find imports in Python cells, leaving IPython magic and shell lines out of the parser.
| Parameter | Type | Default | Description |
|---|---|---|---|
notebook |
dict | required | The source notebook |
| returns | set[str] | Its top-level import names |
dependencies
dependencies(notebook: dict) -> list[str]Map imported modules to package names, excluding the standard library and the browser kernel.
| Parameter | Type | Default | Description |
|---|---|---|---|
notebook |
dict | required | The source notebook |
| returns | list[str] | Sorted distribution names for its imports |
lint
lint(notebook: dict) -> list[str]Check the Python kernel, code cells and package disallow list without running code.
| Parameter | Type | Default | Description |
|---|---|---|---|
notebook |
dict | required | The source notebook |
| returns | list[str] | The reasons it cannot have a browser runner, empty when it passes |
with_metadata
with_metadata(notebook: dict, packages: list[str]) -> dictPut generated dependency metadata into a copy of a notebook.
| Parameter | Type | Default | Description |
|---|---|---|---|
notebook |
dict | required | The source notebook, which stays unchanged |
packages |
list[str] | required | The packages found from its imports |
| returns | dict | A copy with one generated PEP 723 cell |
enabled
enabled(site: Site) -> boolRead the opt-in setting, rejecting values other than true and false.
| Parameter | Type | Default | Description |
|---|---|---|---|
site |
Site | required | The site being built |
| returns | bool | Whether browser notebooks are turned on |
collect
collect(site: Site) -> dict[str, dict]Lint the site’s notebooks and attach passing bundle entries to their pages.
| Parameter | Type | Default | Description |
|---|---|---|---|
site |
Site | required | The site whose rendered pages have been discovered |
| returns | dict[str, dict] | Eligible notebooks, keyed by their source paths |
require_jupyterlite
require_jupyterlite() -> NoneCheck that the optional JupyterLite builder and Pyodide kernel are installed.
build_runtime
build_runtime(output: Path) -> NoneBuild the same static JupyterLite apps and Pyodide kernel used by the website runner.
| Parameter | Type | Default | Description |
|---|---|---|---|
output |
Path | required | The lab folder inside the site output |
bundle
bundle(path: Path, destination: Path, packages: list[str]) -> list[str]Bundle a notebook copy with the files under its assets and data folders.
| Parameter | Type | Default | Description |
|---|---|---|---|
path |
Path | required | The source notebook |
destination |
Path | required | The generated zip file |
packages |
list[str] | required | Packages to put in its PEP 723 cell |
| returns | list[str] | The paths inside the zip |
build
build(site: Site, nav: SiteNav, entries: dict[str, dict]) -> NoneWrite bundles, their manifest, and the themed JupyterLite loading page.
| Parameter | Type | Default | Description |
|---|---|---|---|
site |
Site | required | The site being built |
nav |
SiteNav | required | Its navigation, also used by the themed loading page |
entries |
dict[str, dict] | required | The passing notebook entries |