assembler
tit.reporting.core.assembler ¶
Report assembler for combining reportlets into complete HTML reports.
The ReportAssembler class provides a high-level interface for building
reports from individual reportlets organized into sections.
Public API¶
ReportAssembler Main assembler class that manages sections, renders the table of contents, and produces the final HTML document.
See Also¶
tit.reporting.core.base : Base reportlet classes added to sections. tit.reporting.core.templates : HTML/CSS/JS templates used during rendering.
ReportAssembler ¶
ReportAssembler(metadata: ReportMetadata | None = None, title: str | None = None)
Assemble reportlets into a complete HTML report.
Manages sections, handles ordering, generates the table of contents, and renders the final HTML document.
Parameters¶
metadata : ReportMetadata or None, optional
Report metadata (title, subject, etc.). A default is created
when None.
title : str or None, optional
Report title. Overrides metadata.title when provided.
See Also¶
ReportMetadata : Dataclass holding report-level metadata.
ReportSection : Container for reportlets within a section.
BaseReportGenerator : Abstract generator that wraps ReportAssembler.
Source code in tit/reporting/core/assembler.py
add_section ¶
add_section(section_id: str, title: str, description: str | None = None, collapsed: bool = False, order: int | None = None) -> ReportSection
Add a new section to the report.
Parameters¶
section_id : str Unique identifier for the section. title : str Section title displayed in the report. description : str or None, optional Optional section description shown below the title. collapsed : bool, optional Whether the section starts collapsed (default False). order : int or None, optional Sort order (lower = earlier in report). Defaults to the current number of sections.
Returns¶
ReportSection The newly created section object.
Source code in tit/reporting/core/assembler.py
get_section ¶
get_section(section_id: str) -> ReportSection | None
Get a section by its ID.
Parameters¶
section_id : str The section identifier.
Returns¶
ReportSection or None The matching section, or None if not found.
Source code in tit/reporting/core/assembler.py
add_reportlet_to_section ¶
add_reportlet_to_section(section_id: str, reportlet: Any, create_if_missing: bool = True, section_title: str | None = None) -> None
Add a reportlet to a specific section.
Parameters¶
section_id : str The section identifier. reportlet : Reportlet The reportlet instance to add. create_if_missing : bool, optional Create the section if it does not exist (default True). section_title : str or None, optional Title for the new section when it is auto-created.
Raises¶
ValueError If the section is not found and create_if_missing is False.
Source code in tit/reporting/core/assembler.py
render_toc ¶
render_toc() -> str
Render the table of contents as HTML.
Returns¶
str HTML string for the table of contents.
Source code in tit/reporting/core/assembler.py
render_metadata ¶
render_metadata() -> str
Render the header metadata as HTML.
Returns¶
str HTML string for the header metadata.
Source code in tit/reporting/core/assembler.py
render_sections ¶
render_sections() -> str
Render all sections as HTML.
Returns¶
str HTML string for all sections.
Source code in tit/reporting/core/assembler.py
render_html ¶
render_html() -> str
Render the complete report as HTML.
Returns¶
str Complete HTML document as a string.
Source code in tit/reporting/core/assembler.py
save ¶
Save the report to a file.
Parameters¶
output_path : str or pathlib.Path Path to save the HTML file. create_dirs : bool, optional Create parent directories if needed (default True).
Returns¶
pathlib.Path Path to the saved file.
Source code in tit/reporting/core/assembler.py
to_dict ¶
Convert the report to a dictionary representation.
Returns¶
dict Dictionary containing all report data.
Source code in tit/reporting/core/assembler.py
from_dict
classmethod
¶
Create a ReportAssembler from a dictionary.
Reconstructs the structure but not the reportlet instances. Use this for loading report metadata, not for full reconstruction.
Parameters¶
data : dict
Dictionary containing report data (as produced by to_dict).
Returns¶
ReportAssembler Reconstructed instance.