Skip to main content

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> (requires plotly).
    • Report.mpl_img(fig): Matplotlib figure -> base64 <img> (requires matplotlib).
    • 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 of Section)
  • 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) -> Report
    • add_section(title: str) -> Section
    • add_block(block: str | pandas.DataFrame, section: Section | None = None) -> Report
    • render(out_path: str) -> str # returns absolute path
    • Helpers (all @staticmethod):
      • table_from_df(df: pd.DataFrame, float_fmt: str = "{:,.4f}") -> str
      • html_block(html: str) -> str
      • plotly_div(fig, width: str = "100%", height: str = "auto") -> str
      • mpl_img(fig, fmt: str = "png", dpi: int = 144, alt: str = "figure") -> str
      • image_src(path: str, alt: str = "image") -> str
      • alert(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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

repyter-0.1.0.tar.gz (8.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

repyter-0.1.0-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

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

Hashes for repyter-0.1.0.tar.gz
Algorithm Hash digest
SHA256 2789b14f54fc38ccae734e0ef9e991ed639e033b99e2d8772ae90e6f423ad511
MD5 3a63317e3eb8c727dfca2410a939e3f6
BLAKE2b-256 aa069b7ead3b549a9d44ee3f575ec34f6c6c0544984317cf7581d14d4fb8a4ca

See more details on using hashes here.

Provenance

The following attestation bundles were made for repyter-0.1.0.tar.gz:

Publisher: release.yml on CameronJGrant/repyter

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for repyter-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 af25e919d6ac2109a317619ce20d4b10969692f6508d4a10324da6ce7836b6fa
MD5 7685815d842531ca2546f0f040c0e864
BLAKE2b-256 dd68f0030a9491ab53fa214ac4391ef54c2dd28bdaa153c36fdda6f6d2d68baf

See more details on using hashes here.

Provenance

The following attestation bundles were made for repyter-0.1.0-py3-none-any.whl:

Publisher: release.yml on CameronJGrant/repyter

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page