Report Creator

PyPI Python GitHub

Overview

Report Creator is a Python library for generating shareable, self-contained HTML reports. These reports are designed to be:

  • Self-Contained: Includes base64-encoded images, ensuring the report is fully portable.

  • Versatile: Viewable in any web browser and can be easily printed to PDF.

  • Comprehensive: Supports a wide array of components including:

    • Text and Code blocks

    • Callouts / Admonitions (Info, Warning, Error)

    • Images (local, URLs, or base64)

    • Data visualizations/Charts (powered by Plotly Express)

    • Tables (static or interactive)

    • Diagrams (using Mermaid.js)

  • Customizable: Markdown support within components or as labels/descriptions for other components.

  • Flexible Layout: Components can be arranged horizontally (rc.Group()), vertically (rc.Block()), or even as an interactive slide presentation (rc.Deck()).

  • Extendable By using the rc.Widget() class, any python object that implements the _repr_html_() method can be included in the report.

Basic Example

Here’s a basic example of how to use Report Creator:

import report_creator as rc
import plotly.express as px

with rc.ReportCreator(title="My Report", description="A simple example") as report:
    view = rc.Block(
        rc.Heading("Hello World", level=1),
        rc.Markdown("This is a simple report using **Report Creator**."),
        rc.Group(
            rc.Metric(heading="Records", value="1,024"),
            rc.Metric(heading="Accuracy", value="98.6", unit="%"),
        ),
        rc.Bar(px.data.medals_long(), x="nation", y="count", dimension="medal",
               label="Olympic Medals"),
    )
    report.save(view, "report.html")

See the Getting Started section for more details.

A comprehensive example demonstrating all components and their options can be found in the kitchen_sink.py example file kitchen_sink.py. The resulting report can be viewed here.

Table of Contents