common_reports.builders.renderers.html
HTML renderers — the three concrete views of one Document tree.
- :class:
InteractiveHtmlRenderer←report_template_v2.html— full standalone page: flex shell + sticky TOC + accordion + JS resize, figures rendered TWICE (CDN interactive + base64 PNG fallback). - :class:
EmailRenderer←email_report_template.html— single-column stacked block, static PNG only, no JS/TOC/accordion. [G10] viewport initial-scale=2.0, [G11] title=None self-labelling via<h2>, [G12]<style>block + inline critical CSS on elements (multipart-safe). - :class:
GhostRenderer←ghost.py— the SAME body wrapped into ONE Mobiledoc HTML-card viaGhostPost.mobiledoc_for; figures use hosted PNG URLs.
[G14/G15] honour Section.render_figures. [G16] FigureAsset order
(interactive, static, url). Renderers import contracts + schemas only and NEVER
mutate components.
Classes
EmailRenderer
Bases: Renderer
Single-column, static-PNG, multipart-safe email view
(email_report_template.html). Serves both the report email and the algo
update email (algo_update_template == email_template, G17).
images chooses how plots and byte images embed:
"data-uri"(default, AlgoReports parity): base64<img>in the HTML. Gmail’s web client blocks data URIs and clips HTML over ~102 KB."cid":<img src="cid:figure-N">plus inline image parts onRenderResult.attachments— send them with the HTML. Email-client-safe and keeps the HTML small.
style chooses the look:
"classic"(default): the 0.1.x look, byte-for-byte."modern": the branded, email-client-safe layout (:class:~common_reports.builders.renderers.modern.ModernEmailRenderer), which also takesbrand=andpreheader=and defaults toimages="cid".
Carried state: per-render figure counter and collected inline attachments
(reset by each render). The manifest reports size_bytes and
gmail_clip_risk so senders can react before a report is truncated.
__init__
def __init__(*, theme: Theme | None = None, title: str | None = None, date: str | None = None, images: str = 'data-uri', style: str = 'classic', **kw: Any) -> NoneFields and properties declared here; inherited members belong to the bases above.
GMAIL_CLIP_BYTES
GMAIL_CLIP_BYTES = 102 * 1024STYLES
STYLES = ('classic', 'modern')style
style = styletarget
target = Target.EMAILfinalize
def finalize(document: Document, body: str) -> RenderResultrender
def render(document: Document) -> RenderResultvisit_button
def visit_button(node: Button) -> strvisit_callout
def visit_callout(node: Callout) -> strvisit_cell
def visit_cell(node: Cell) -> strvisit_columns
def visit_columns(node: Columns) -> strvisit_divider
def visit_divider(node: Divider) -> strvisit_figure
def visit_figure(node: Figure) -> strvisit_grid
def visit_grid(node: Grid) -> strvisit_heading
def visit_heading(node: Heading) -> strvisit_image
def visit_image(node: Image) -> strvisit_kpis
def visit_kpis(node: Kpis) -> strvisit_row
def visit_row(node: Row) -> strvisit_section
def visit_section(node: Section) -> strvisit_spacer
def visit_spacer(node: Spacer) -> strvisit_status
def visit_status(node: Status) -> strvisit_table
def visit_table(node: Table) -> strvisit_text
def visit_text(node: Text) -> strGhostRenderer
Bases: InteractiveHtmlRenderer
Ghost Admin view — the SAME interactive body, but figures use HOSTED PNG
URLs (uploaded via uploader), and the WHOLE rendered HTML is wrapped into
one Mobiledoc HTML-card via :meth:GhostPost.mobiledoc_for.
The render result’s manifest['ghost_post'] carries a :class:GhostPost
ready for the Admin API POST.
__init__
def __init__(*, uploader: Any = None, theme: Theme | None = None, title: str | None = None, status: str = 'draft', **kw: Any) -> NoneFields and properties declared here; inherited members belong to the bases above.
status
status = statustarget
target = Target.GHOSTuploader
uploader = uploaderfinalize
def finalize(document: Document, body: str) -> RenderResultvisit_figure
def visit_figure(node: Figure) -> strInteractiveHtmlRenderer
Bases: Renderer
Full standalone interactive page (report_template_v2.html).
style="modern" builds the branded page instead
(:class:~common_reports.builders.renderers.page.ModernPageRenderer).
__init__
def __init__(*, theme: Theme | None = None, title: str | None = None, style: str = 'classic', **kw: Any) -> NoneFields and properties declared here; inherited members belong to the bases above.
STYLES
STYLES = ('classic', 'modern')style
style = styletarget
target = Target.INTERACTIVEfinalize
def finalize(document: Document, body: str) -> RenderResultvisit_button
def visit_button(node: Button) -> strvisit_callout
def visit_callout(node: Callout) -> strvisit_cell
def visit_cell(node: Cell) -> strvisit_columns
def visit_columns(node: Columns) -> strvisit_divider
def visit_divider(node: Divider) -> strvisit_figure
def visit_figure(node: Figure) -> strvisit_grid
def visit_grid(node: Grid) -> strvisit_heading
def visit_heading(node: Heading) -> strvisit_image
def visit_image(node: Image) -> strvisit_kpis
def visit_kpis(node: Kpis) -> strvisit_row
def visit_row(node: Row) -> strvisit_section
def visit_section(node: Section) -> strvisit_spacer
def visit_spacer(node: Spacer) -> strvisit_status
def visit_status(node: Status) -> strvisit_table
def visit_table(node: Table) -> strvisit_text
def visit_text(node: Text) -> strFunctions
render_table_html
def render_table_html(table: Table, *, inline: bool = False) -> strRender a :class:Table to an HTML <table> honouring the full
:class:TableFormat (membership / per-column overrides / scale / colour /
index). inline=True adds element-level styles for email robustness [G12].
The values come from the one table engine (builders/tables.py); this is
the classic markup all three renderers share.