docsprocs

A docs-build notebook processor that color-codes cells by boopiter type, so the rendered site echoes the app’s colored left bars.

Registered via doc_procs in pyproject.toml [tool.nbdev], color_cells runs over every notebook during the docs build (before Quarto renders). It wraps each markdown/raw cell’s source in a Quarto fenced div classed by its boopiter cell type (.boop-note green, .boop-prompt red, .boop-raw orange); styles.css turns those into the colored left bar. Code cells already carry .cell-code, so they’re colored in CSS alone. The page’s H1 title cell is left untouched so Quarto’s title handling isn’t disturbed.


source

color_cells

def color_cells(
    cell
):

nbdev docs processor: wrap a markdown/raw cell’s source in a Quarto fenced div classed by its boopiter cell type, so styles.css can draw boopiter’s colored left bar (green note / red prompt / orange raw). Code cells carry .cell-code and are colored via CSS; the page-title (H1) cell is left alone.


source

share_notebook

def share_notebook(
    nb_path, listed:bool=True, images_dir:NoneType=None
)->str:

*Render nb_path into the share site and publish it, returning the public URL. listed puts it on the site’s index; unlisted pages are still rendered and reachable by URL, just not indexed – and re-sharing with the other choice flips that, since the state lives in a file that gets rewritten. Overwrites in place: the directory is named from the notebook’s identity (see share_slug), so a correction updates the page a recipient already has the link to. Renders locally and pushes only the built site to the gh-pages branch, which is why notebook sources never leave this machine. The push is ours rather than quarto publish gh-pages because that command clears the branch before copying its render in, which deletes every page published from a different machine; see _publish_additive. The index is not published from here at all: it is rebuilt by the build-index workflow from every page on the branch, which is the only vantage point that sees shares from every machine – so the site reads the same no matter which machine published last, and publishing only ever adds. Returns as soon as the push lands; GitHub Pages then takes roughly a minute to rebuild.*


source

share_name

def share_name(
    path
)->str:

*The published page’s directory name for a notebook: ’_’ (see share_slug).*


source

share_slug

def share_slug(
    path
)->str:

Six hex chars identifying a notebook by machine and location: sha256 of hostname + its canonical path. Deterministic, so re-sharing the same file overwrites the same page and a link you’ve already sent stays current – that’s the whole point of not using a random suffix. Keyed on more than the basename because ‘example.ipynb’ in two checkouts, or on two machines, are different documents that would otherwise fight over one URL. realpath (not abspath) so two symlinked routes to one file still collapse to a single page, and a NUL separator so host ‘a’ + path ‘b/c’ can’t collide with host ‘a/b’ + path ‘c’.