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.
ReportAssembler ¶
ReportAssembler(metadata: ReportMetadata | None = None, title: str | None = None)
Assembles reportlets into a complete HTML report.
The assembler manages sections, handles ordering, generates the table of contents, and renders the final HTML document.
Initialize the report assembler.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
metadata
|
ReportMetadata | None
|
Report metadata (title, subject, etc.) |
None
|
title
|
str | None
|
Report title (overrides metadata.title if provided) |
None
|
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:
| Name | Type | Description | Default |
|---|---|---|---|
section_id
|
str
|
Unique identifier for the section |
required |
title
|
str
|
Section title |
required |
description
|
str | None
|
Optional section description |
None
|
collapsed
|
bool
|
Whether section starts collapsed |
False
|
order
|
int | None
|
Sort order (lower = earlier in report) |
None
|
Returns:
| Type | Description |
|---|---|
ReportSection
|
The created ReportSection 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:
| Name | Type | Description | Default |
|---|---|---|---|
section_id
|
str
|
The section identifier |
required |
Returns:
| Type | Description |
|---|---|
ReportSection | None
|
The ReportSection 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:
| Name | Type | Description | Default |
|---|---|---|---|
section_id
|
str
|
The section identifier |
required |
reportlet
|
Any
|
The reportlet to add |
required |
create_if_missing
|
bool
|
Create section if it doesn't exist |
True
|
section_title
|
str | None
|
Title for new section (if created) |
None
|
Source code in tit/reporting/core/assembler.py
render_toc ¶
render_toc() -> str
Render the table of contents as HTML.
Returns:
| Type | Description |
|---|---|
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:
| Type | Description |
|---|---|
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:
| Type | Description |
|---|---|
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:
| Type | Description |
|---|---|
str
|
Complete HTML document as a string |
Source code in tit/reporting/core/assembler.py
save ¶
Save the report to a file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output_path
|
str | Path
|
Path to save the HTML file |
required |
create_dirs
|
bool
|
Create parent directories if needed |
True
|
Returns:
| Type | Description |
|---|---|
Path
|
Path to the saved file |
Source code in tit/reporting/core/assembler.py
to_dict ¶
from_dict
classmethod
¶
Create a ReportAssembler from a dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
dict[str, Any]
|
Dictionary containing report data |
required |
Returns:
| Type | Description |
|---|---|
Self
|
Reconstructed ReportAssembler instance |
Note
This reconstructs the structure but not the reportlet instances. Use this for loading report metadata, not for full reconstruction.