coverage.renderer

Render a CoverageStore to an HTML report directory.

The report layout follows the familiar gcovr information architecture:

  • index.html — project summary (aggregate + per-tier breakdown), a legend, a “Captures” provenance table (when the store has any), and a sortable file table.

  • files/<mangled_path>.html — per-file annotated source with a file summary block, a legend, and a code table that shows per-tier hit counts and branch status alongside the source.

Tier ordering is read from store.tier_order (the precedence order established at load time, first = highest). When the store has no tiers — typically because the run produced no coverage data — the renderer falls back to ("system",) so the templates still have something to iterate. All per-tier columns, percentages, and the winner-take-all row coloring on the annotated source view are driven by that list, so adding a new tier requires no changes here.

Row precedence (spec §9). Each annotated source line resolves to exactly one CSS class, in this order: state-excluded (source-scanned exclusion markers, spec §8 — always wins, even over a covered/stale/aging line) → tier-<index> (the highest-precedence tier in tier_order with a nonzero hit count on that line) → state-agingstate-stalestate-uncovered. A line with no LineRecord at all (not excluded, never measured by any tier — e.g. a blank line or a declaration gcov never emits a DA: for) gets state-uncoverable, a sixth, deliberately-unlisted bucket so those lines don’t read as bright-red misses.

Colors are resolved once per report and emitted as CSS custom properties (--tier-<index>, --state-<name>) in an inline <style> block on both pages; report.css consumes them via color-mix() so the actual row background never needs a template-side computation.

class otto.coverage.renderer.html_renderer.HtmlRenderer(output_dir: Path, templates_dir: Path = PosixPath('/home/docs/checkouts/readthedocs.org/user_builds/otto-sh/checkouts/v0.6.0/src/otto/coverage/renderer/templates'), project_name: str = 'Coverage Report', *, extra_markers: list[str] | None = None, prefix: Path | None = None)

Bases: object

Render a CoverageStore to an HTML report directory.

Parameters:
  • output_dir – Directory to write the report into (created if needed).

  • templates_dir – Override for the default templates directory.

  • project_name – Title shown in the HTML report header.

  • extra_markers – Extra source exclusion-marker strings (spec §8), forwarded from [coverage.exclusions].markers via the reporter. Scanned alongside the built-in LCOV_EXCL_* markers when annotating each file’s source.

  • prefix – Strip this leading directory from file paths shown in the report (display only, like genhtml --prefix). Files outside the prefix display unchanged; links and store keys always use the full path.

render(store: CoverageStore) None

Render the full HTML report.