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) -> NoneFields and properties declared here; inherited members belong to the bases above.
children
children: tuple[Component, ...] = ()default_style
default_style: RenderStyle = RenderStyle.SECTIONname
name: strtheme
theme: Theme = DEFAULT_THEMEtoc
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) -> DocumentMulti-step {key} fill across text/headings/captions; returns a new Document.
render
def render(renderer: Any) -> AnyWalk the tree once via renderer.render(self) -> str | RenderResult.
to_email
def to_email(**kwargs: Any) -> Anyto_ghost
def to_ghost(uploader: Any = None, **kwargs: Any) -> Anyto_html
def to_html(**kwargs: Any) -> Anywith_children
def with_children(children: tuple[Component, ...]) -> Documentwith_theme
def with_theme(theme: Theme) -> DocumentTocEntry
__init__
def __init__(title: str, anchor: str, level: int = 2) -> NoneFields and properties declared here; inherited members belong to the bases above.
anchor
anchor: strlevel
level: int = 2title
title: str