Report generator
Project description
repyter
A tiny, Python-first HTML report builder. Compose sections and blocks in pure Python, render once via Jinja2. Optional helpers let you embed Pandas tables, Plotly figures, and Matplotlib images — all without leaving your Python debugger or notebook.
Note: This package intentionally keeps everything in Python. There are no separate CLI tools or Markdown engines; you build the document programmatically and render to a single HTML file using a Jinja2 template.
Installation
repyter is a regular Python package. For now, install from source:
pip install -e .
Requirements:
- Python >= 3.13
- jinja2
- pandas
Optional (only needed if you use the respective helpers):
- plotly
- matplotlib
Quick start
from repyter import Report
import pandas as pd
report = Report(title="My Analysis Report")
# Intro block shown above all sections
report.set_intro(Report.alert("This report was generated automatically."))
# Section with a Pandas table
sec = report.add_section("Run Summary")
df = pd.DataFrame({
"Metric": ["Rows", "Features", "Accuracy"],
"Value": [12_345, 42, 0.9123],
})
report.add_block(Report.table_from_df(df), section=sec)
# Optional: Plotly (if installed)
# import plotly.express as px
# fig = px.line(pd.DataFrame({"x": range(10), "y": [v * 1.5 for v in range(10)]}), x="x", y="y")
# report.add_section("Interactive Chart")
# report.add_block(Report.plotly_div(fig))
# Optional: Matplotlib (if installed)
# import matplotlib.pyplot as plt
# fig, ax = plt.subplots(figsize=(4, 3))
# ax.plot([0, 1, 2], [0, 1, 0])
# report.add_section("Static Figure")
# report.add_block(Report.mpl_img(fig, alt="A simple curve"))
# Render to HTML
out_file = report.render("reports/report.html")
print(f"Wrote: {out_file}")
Open the file in your browser to view the result.
Concepts
- Section: a logical grouping with a title and a list of HTML blocks.
- Block: any HTML string. Helpers are provided to generate consistent blocks:
Report.table_from_df(df): Pandas DataFrame -> styled HTML table.Report.plotly_div(fig): Plotly figure -> embeddable<div>(requiresplotly).Report.mpl_img(fig): Matplotlib figure -> base64<img>(requiresmatplotlib).Report.image_src(path): simple image by path/URL.Report.alert(text, kind=""): styled alert box.
Template
The default template is repyter/template.html. You can pass a custom template path to the Report constructor if desired. The template receives:
title(str)generated_at(str,YYYY-MM-DD HH:MM:SS)sections(list ofSection)intro_html(str)use_plotly_cdn(bool)plotly_js_inline(str, reserved for inline delivery)
Note: The repository ships with a template; you typically don't need to modify it. The README does not document the template's internals.
Minimal API reference
from repyter import Report, Section
-
Report(template_path: str = default_template, use_plotly_cdn: bool = True, title: str | None = None)set_intro(html: str) -> Reportadd_section(title: str) -> Sectionadd_block(block: str | pandas.DataFrame, section: Section | None = None) -> Reportrender(out_path: str) -> str# returns absolute path- Helpers (all
@staticmethod):table_from_df(df: pd.DataFrame, float_fmt: str = "{:,.4f}") -> strhtml_block(html: str) -> strplotly_div(fig, width: str = "100%", height: str = "auto") -> strmpl_img(fig, fmt: str = "png", dpi: int = 144, alt: str = "figure") -> strimage_src(path: str, alt: str = "image") -> stralert(text: str, kind: str = "") -> str
-
Section(title: str, blocks: list[str])
Development
- Running tests (uses pytest):
python -m pytest -q
-
Code style: Follow the simple, explicit style in
repyter/report.py. Keep public docstrings clear and concise. -
Backwards compatibility: Please avoid adding new features without discussion; this project focuses on a compact Python API for now.
License
MIT (see LICENSE).
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file repyter-0.1.0.tar.gz.
File metadata
- Download URL: repyter-0.1.0.tar.gz
- Upload date:
- Size: 8.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2789b14f54fc38ccae734e0ef9e991ed639e033b99e2d8772ae90e6f423ad511
|
|
| MD5 |
3a63317e3eb8c727dfca2410a939e3f6
|
|
| BLAKE2b-256 |
aa069b7ead3b549a9d44ee3f575ec34f6c6c0544984317cf7581d14d4fb8a4ca
|
Provenance
The following attestation bundles were made for repyter-0.1.0.tar.gz:
Publisher:
release.yml on CameronJGrant/repyter
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
repyter-0.1.0.tar.gz -
Subject digest:
2789b14f54fc38ccae734e0ef9e991ed639e033b99e2d8772ae90e6f423ad511 - Sigstore transparency entry: 739275273
- Sigstore integration time:
-
Permalink:
CameronJGrant/repyter@6972739737ba1e0e356905a950393973cca472a2 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/CameronJGrant
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@6972739737ba1e0e356905a950393973cca472a2 -
Trigger Event:
push
-
Statement type:
File details
Details for the file repyter-0.1.0-py3-none-any.whl.
File metadata
- Download URL: repyter-0.1.0-py3-none-any.whl
- Upload date:
- Size: 10.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
af25e919d6ac2109a317619ce20d4b10969692f6508d4a10324da6ce7836b6fa
|
|
| MD5 |
7685815d842531ca2546f0f040c0e864
|
|
| BLAKE2b-256 |
dd68f0030a9491ab53fa214ac4391ef54c2dd28bdaa153c36fdda6f6d2d68baf
|
Provenance
The following attestation bundles were made for repyter-0.1.0-py3-none-any.whl:
Publisher:
release.yml on CameronJGrant/repyter
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
repyter-0.1.0-py3-none-any.whl -
Subject digest:
af25e919d6ac2109a317619ce20d4b10969692f6508d4a10324da6ce7836b6fa - Sigstore transparency entry: 739275282
- Sigstore integration time:
-
Permalink:
CameronJGrant/repyter@6972739737ba1e0e356905a950393973cca472a2 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/CameronJGrant
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@6972739737ba1e0e356905a950393973cca472a2 -
Trigger Event:
push
-
Statement type: