jellycell.tearsheets._template

Shared header + helper rendering for :mod:jellycell.tearsheets.

Every helper in :mod:jellycell.tearsheets emits a manuscript-style markdown file with a consistent, pinnable header block so the output is byte-stable across runs when the caller passes template_overrides (author, month_year, version, author_url).

Kept private; the public surface is the three helper functions in

mod:

jellycell.tearsheets (findings, methodology, audit).

Module Contents

Functions

resolve_template_fields

Merge caller overrides over defaults, filling month_year from now if absent.

render_header

Render the top-of-file header shared across all tearsheet helpers.

render_key_value_table

Render a two-column markdown table from {key: value} pairs.

render_frontmatter_block

Emit a plain JSON block that’s machine-parseable and GitHub-renderable.

ensure_output_path

Resolve + create parent directories for an output path.

Data

API

jellycell.tearsheets._template.DEFAULT_TEMPLATE_FIELDS: dict[str, str]

None

jellycell.tearsheets._template.resolve_template_fields(overrides: dict[str, str] | None) dict[str, str]

Merge caller overrides over defaults, filling month_year from now if absent.

jellycell.tearsheets._template.render_header(*, kind: str, title: str, subtitle: str, project: str, template_overrides: dict[str, str] | None) str

Render the top-of-file header shared across all tearsheet helpers.

kind is one of findings / methodology / audit and shows up in an HTML comment so regeneration origin is obvious. The header line carries project name, author (+ optional URL), month_year, and jellycell version — all pinnable via template_overrides for byte-stable regen.

jellycell.tearsheets._template.render_key_value_table(rows: dict[str, Any], *, key_header: str = 'Metric') str

Render a two-column markdown table from {key: value} pairs.

Values are formatted with :func:_format_value — bools / numbers get inline code ticks, lists collapse to [n items] when long, None becomes null. Nested dicts flatten with dotted keys so {"cs": {"att": 0.2}} becomes a cs.att row.

jellycell.tearsheets._template.render_frontmatter_block(fields: dict[str, str]) str

Emit a plain JSON block that’s machine-parseable and GitHub-renderable.

Some teams pin extra metadata (PR number, DOI, dataset snapshot id) beyond the header fields. This block lets downstream tooling recover those values without re-parsing the header.

jellycell.tearsheets._template.ensure_output_path(out_path: str | pathlib.Path) pathlib.Path

Resolve + create parent directories for an output path.