Skip to content

common_reports.contracts.builders.document

Document — the immutable root of the component tree. Frozen; TOC and fill are derived (a tree op, never string-matching). Rendering is delegated to a renderer (the visitor), so the contract layer stays free of rendering logic.

TocEntry lives here (not in schemas/) because Document.toc — a contract method — returns it; keeping it at the contract layer preserves the one-way arrow.

Classes

Document

The immutable component tree. One Document = one report (or one strategy).

__init__

def __init__(name: str, children: tuple[Component, ...] = (), theme: Theme = DEFAULT_THEME, default_style: RenderStyle = RenderStyle.SECTION) -> None

Fields and properties declared here; inherited members belong to the bases above.

children

children: tuple[Component, ...] = ()

default_style

default_style: RenderStyle = RenderStyle.SECTION

name

name: str

theme

theme: Theme = DEFAULT_THEME

toc

Read-only property.

toc: list[TocEntry]

unfilled

Read-only property.

unfilled: list[str]

Placeholder keys still {open} anywhere in the tree.

fill

def fill(**kwargs: Any) -> Document

Multi-step {key} fill across text/headings/captions; returns a new Document.

render

def render(renderer: Any) -> Any

Walk the tree once via renderer.render(self) -> str | RenderResult.

to_email

def to_email(**kwargs: Any) -> Any

to_ghost

def to_ghost(uploader: Any = None, **kwargs: Any) -> Any

to_html

def to_html(**kwargs: Any) -> Any

with_children

def with_children(children: tuple[Component, ...]) -> Document

with_theme

def with_theme(theme: Theme) -> Document

TocEntry

__init__

def __init__(title: str, anchor: str, level: int = 2) -> None

Fields and properties declared here; inherited members belong to the bases above.

anchor

anchor: str

level

level: int = 2

title

title: str