energytrackr.plot.builtin_page_sections package¶
Submodules¶
energytrackr.plot.builtin_page_sections.base module¶
Base page section for energytrackr.
- class energytrackr.plot.builtin_page_sections.base.Base(**params: dict[str, Any])[source]¶
Bases:
PageObj,Configurable[BaseConfig]Base page section for energytrackr.
This class serves as a base for creating page sections in the energytrackr application. It provides a template path and a render method to generate HTML content using Jinja2 templates.
- render(env: Environment, ctx: Context) str[source]¶
Render the page section using Jinja2 templates.
- Parameters:
env (Environment) – Jinja2 environment for rendering templates.
ctx (Context) – Context object containing data for rendering.
- Returns:
Rendered HTML content.
- Return type:
str
- property template_path: str¶
Get the path to the template file.
- Returns:
Path to the template file.
- Return type:
str
- class energytrackr.plot.builtin_page_sections.base.BaseConfig(template: str = '/home/docs/checkouts/readthedocs.org/user_builds/energy-analyzer/checkouts/latest/src/energytrackr/plot/builtin_page_sections/templates/base.html')[source]¶
Bases:
objectConfiguration for the Base page section.
- template: str = '/home/docs/checkouts/readthedocs.org/user_builds/energy-analyzer/checkouts/latest/src/energytrackr/plot/builtin_page_sections/templates/base.html'¶
energytrackr.plot.builtin_page_sections.change_table module¶
Defines a ChangeTable class for rendering a table of commit changes with statistical metrics.
- class energytrackr.plot.builtin_page_sections.change_table.ChangeTable(**params: dict[str, Any])[source]¶
Bases:
PageObj,Configurable[ChangeTableConfig]Renders a table of every commit with computed metrics.
- property columns: list[dict[str, str]]¶
Returns the list of columns for the change table.
- render(env: Environment, ctx: Context) str[source]¶
Renders the change table section as an HTML string using a Jinja2 template.
- Parameters:
env (Environment) – The Jinja2 environment used for template rendering.
ctx (Context) – The context object containing artefacts, statistics, and energy fields.
- Returns:
The rendered HTML string for the change table. If the template is missing, returns an error message.
- Return type:
str
- Workflow:
Checks if the template file exists; logs an error and returns an error message if not found.
Determines whether to use the provided environment or create a local one based on the template’s location.
Loads the template.
Prepares table rows by extracting commit and statistical data from the context.
Formats each row with commit details, statistical values, and change event information.
Renders the template with the prepared columns and rows.
- property template_path: Path¶
Returns the path to the template file.
- class energytrackr.plot.builtin_page_sections.change_table.ChangeTableConfig(template: Path = PosixPath('/home/docs/checkouts/readthedocs.org/user_builds/energy-analyzer/checkouts/latest/src/energytrackr/plot/builtin_page_sections/templates/change_table.html'), columns: list[dict[str, str]] | None = None)[source]¶
Bases:
objectConfiguration for the ChangeTable class.
- template: Path = PosixPath('/home/docs/checkouts/readthedocs.org/user_builds/energy-analyzer/checkouts/latest/src/energytrackr/plot/builtin_page_sections/templates/change_table.html')¶
energytrackr.plot.builtin_page_sections.level_legend module¶
Level Legend Page Section.
- class energytrackr.plot.builtin_page_sections.level_legend.LevelLegend(**params: dict[str, Any])[source]
Bases:
PageObj,Configurable[LevelLegendConfig]Renders the Change-Event Level Legend as an HTML fragment.
Reads threshold values from the YAML config via settings.
- render(env: Environment, ctx: Context) str[source]
Renders the level legend template using the provided Jinja2 environment and context.
This method checks if the specified template file exists. If not, it logs an error and returns an HTML error message. If the template exists, it ensures the correct Jinja2 environment is used (either the provided one or a new one with the appropriate loader), loads the template, and renders it with threshold values from the application settings.
- Parameters:
env (Environment) – The Jinja2 environment to use for template rendering.
ctx (Context) – The rendering context (currently unused).
- Returns:
The rendered HTML string of the level legend, or an error message if the template is missing.
- Return type:
str
- property template_path: str
Get the path to the template file.
- Returns:
The path to the template file.
- Return type:
str
- class energytrackr.plot.builtin_page_sections.level_legend.LevelLegendConfig(template: str = '/home/docs/checkouts/readthedocs.org/user_builds/energy-analyzer/checkouts/latest/src/energytrackr/plot/builtin_page_sections/templates/level_legend.html')[source]
Bases:
objectConfiguration for the LevelLegend page section.
- template
Path to a custom template file. If None, defaults to the package template.
- Type:
str | None
- template: str = '/home/docs/checkouts/readthedocs.org/user_builds/energy-analyzer/checkouts/latest/src/energytrackr/plot/builtin_page_sections/templates/level_legend.html'
energytrackr.plot.builtin_page_sections.plot_embed module¶
PlotEmbed - embeds registered Bokeh plots into HTML report using Tabs.
- class energytrackr.plot.builtin_page_sections.plot_embed.PlotEmbed(div_class: str = 'bokeh-chart')[source]¶
Bases:
PageObjPage section that injects the interactive Bokeh charts into HTML.
- render(env: Environment, ctx: Context) str[source]¶
Return HTML snippet containing Bokeh resources, script, and div.
- Parameters:
env (Environment) – Jinja2 environment for rendering.
ctx (Context) – Context object containing the plots to embed.
- Returns:
HTML snippet with Bokeh resources and embedded plots.
- Return type:
str
energytrackr.plot.builtin_page_sections.summary_box module¶
SummaryBox - first HTML section in the default report.
Renders a quick statistics overview for the active energy column. Uses a Jinja partial summary_box.html that ships with plot; users can override by encoding their own PageObj in YAML.
- class energytrackr.plot.builtin_page_sections.summary_box.SummaryBox(**params: dict[str, Any])[source]¶
Bases:
PageObj,Configurable[SummaryBoxConfig]Render general & statistical summary values.
- render(env: Environment, ctx: Context) str[source]¶
Renders the summary box using a Jinja2 template.
This method checks if the specified template file exists. If not, it logs an error and returns an HTML error message. If the template is outside the default environment’s loader path, it creates a new Jinja2 Environment with the appropriate loader. It then loads the template, computes the overall summary for the first energy field in the context, and renders the template with the computed summary and the column name.
- Parameters:
env (Environment) – The Jinja2 environment to use for template rendering.
ctx (Context) – The context containing energy fields and other relevant data.
- Returns:
The rendered HTML string for the summary box, or an error message if the template is missing.
- Return type:
str
- property template_path: str¶
Get the path to the template file.
- class energytrackr.plot.builtin_page_sections.summary_box.SummaryBoxConfig(template: str = '/home/docs/checkouts/readthedocs.org/user_builds/energy-analyzer/checkouts/latest/src/energytrackr/plot/builtin_page_sections/templates/summary_box.html')[source]¶
Bases:
objectConfiguration for the SummaryBox page section.
- template: str = '/home/docs/checkouts/readthedocs.org/user_builds/energy-analyzer/checkouts/latest/src/energytrackr/plot/builtin_page_sections/templates/summary_box.html'¶
Module contents¶
Builtin page sections for the energytrackr package.