jellycell.render.renderer

Notebook + manifests → self-contained HTML.

Spec §2.6 pipeline:

  1. Parse notebook (format.parse).

  2. Match cells to cached manifests.

  3. Render each cell via jinja partial; outputs via :mod:jellycell.render.outputs.

  4. Assemble via :file:templates/page.html.j2.

  5. Write to <reports>/<notebook-stem>.html.

--standalone mode base64-inlines image blobs instead of writing external assets.

Module Contents

Classes

RenderedNotebook

Outcome of rendering a single notebook.

RenderedIndex

Outcome of rendering the project index page.

TocItem

A single table-of-contents entry for the notebook sidebar.

SiblingNotebook

Adjacent-notebook link data for cross-navigation.

RendererEnv

Shared long-lived state for the rendering pipeline.

Renderer

Converts notebooks + cached manifests into a browsable HTML catalogue.

API

class jellycell.render.renderer.RenderedNotebook

Outcome of rendering a single notebook.

notebook: str

None

Path of the source notebook, relative to project root.

output_path: pathlib.Path

None

Path where the HTML would be / was written.

When write_pages=False the file is not actually created; the path is still reported so callers know where the canonical artifact would live in a static render. The HTML text is in :attr:html.

cell_count: int

None

cached_count: int

None

html: str | None

None

Rendered HTML string — populated when the Renderer was created with write_pages=False (server path). None in the default CLI jellycell render flow where the file at :attr:output_path is authoritative.

class jellycell.render.renderer.RenderedIndex

Outcome of rendering the project index page.

Mirrors :class:RenderedNotebook so the server can fetch the HTML string directly (write_pages=False) without touching disk.

output_path: pathlib.Path

None

html: str | None

None

class jellycell.render.renderer.TocItem

A single table-of-contents entry for the notebook sidebar.

anchor: str

None

label: str

None

level: int

None

kind: str

None

class jellycell.render.renderer.SiblingNotebook

Adjacent-notebook link data for cross-navigation.

href: str

None

title: str

None

current: bool

None

class jellycell.render.renderer.RendererEnv

Shared long-lived state for the rendering pipeline.

The Jinja environment (with compiled templates) and the Pygments CSS are expensive to build and completely stateless across requests — perfect to keep alive for the life of a server process. The CacheStore and CacheIndex are deliberately not here; those are opened per-render for simple SQLite thread safety.

assets_dir is captured at env-build time so the live server points at .jellycell/cache/assets/ while static jellycell render stays with site/_assets/.

jinja: jinja2.Environment

None

pygments_css: str

None

assets_dir: pathlib.Path

None

classmethod for_static(project: jellycell.paths.Project) jellycell.render.renderer.RendererEnv

Env for jellycell render — assets under site/_assets/.

classmethod for_server(project: jellycell.paths.Project) jellycell.render.renderer.RendererEnv

Env for jellycell view — assets under .jellycell/cache/assets/ (served by the /_assets/ static mount). Live server is disk-write-free for HTML pages; assets still land on disk as content-hashed blobs so the static mount has something to serve.

class jellycell.render.renderer.Renderer(project: jellycell.paths.Project, *, standalone: bool = False, env: jellycell.render.renderer.RendererEnv | None = None, write_pages: bool = True)

Converts notebooks + cached manifests into a browsable HTML catalogue.

Pass write_pages=False to skip writing HTML files to disk (the live server uses this mode and returns the HTML string directly via

Attr:

RenderedNotebook.html).

Pass env=RendererEnv.for_server(project) in the server to reuse a long-lived Jinja environment across requests; the default builds a fresh env which is appropriate for the one-shot CLI path.

Initialization

render_notebook(notebook_path: pathlib.Path) jellycell.render.renderer.RenderedNotebook

Render a single notebook to site/<stem>.html. Returns the result.

With write_pages=True (the default) the HTML is written to site/<stem>.html and :attr:RenderedNotebook.html is None. With write_pages=False (server path) disk is untouched and the rendered string is returned via :attr:RenderedNotebook.html.

render_index() jellycell.render.renderer.RenderedIndex

Render a project-level index listing every notebook + recent cache entries.

Returns a :class:RenderedIndex. write_pages=True (default) writes site/index.html to disk; write_pages=False stashes the HTML in :attr:RenderedIndex.html without touching disk.

render_all() list[jellycell.render.renderer.RenderedNotebook]

Render every notebook in the project plus the index.

close() None

Close cache store + index.