report-toolkit 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- report_toolkit-0.1.0/LICENSE +21 -0
- report_toolkit-0.1.0/PKG-INFO +136 -0
- report_toolkit-0.1.0/README.md +103 -0
- report_toolkit-0.1.0/pyproject.toml +44 -0
- report_toolkit-0.1.0/setup.cfg +4 -0
- report_toolkit-0.1.0/src/report_toolkit/__init__.py +44 -0
- report_toolkit-0.1.0/src/report_toolkit/_template.py +488 -0
- report_toolkit-0.1.0/src/report_toolkit/_tree.py +76 -0
- report_toolkit-0.1.0/src/report_toolkit/adapters.py +195 -0
- report_toolkit-0.1.0/src/report_toolkit/composer.py +671 -0
- report_toolkit-0.1.0/src/report_toolkit/model.py +152 -0
- report_toolkit-0.1.0/src/report_toolkit/resources/artifacts.js +188 -0
- report_toolkit-0.1.0/src/report_toolkit/resources/report.css +105 -0
- report_toolkit-0.1.0/src/report_toolkit/themes/__init__.py +7 -0
- report_toolkit-0.1.0/src/report_toolkit/themes/_validation.py +28 -0
- report_toolkit-0.1.0/src/report_toolkit/themes/palette.py +240 -0
- report_toolkit-0.1.0/src/report_toolkit/themes/style.py +71 -0
- report_toolkit-0.1.0/src/report_toolkit/themes/theme.py +183 -0
- report_toolkit-0.1.0/src/report_toolkit/writer.py +557 -0
- report_toolkit-0.1.0/src/report_toolkit.egg-info/PKG-INFO +136 -0
- report_toolkit-0.1.0/src/report_toolkit.egg-info/SOURCES.txt +32 -0
- report_toolkit-0.1.0/src/report_toolkit.egg-info/dependency_links.txt +1 -0
- report_toolkit-0.1.0/src/report_toolkit.egg-info/requires.txt +27 -0
- report_toolkit-0.1.0/src/report_toolkit.egg-info/top_level.txt +1 -0
- report_toolkit-0.1.0/tests/test_artifact_options.py +516 -0
- report_toolkit-0.1.0/tests/test_examples.py +106 -0
- report_toolkit-0.1.0/tests/test_integrations.py +79 -0
- report_toolkit-0.1.0/tests/test_model.py +127 -0
- report_toolkit-0.1.0/tests/test_navigation_options.py +242 -0
- report_toolkit-0.1.0/tests/test_structure_features.py +433 -0
- report_toolkit-0.1.0/tests/test_templates.py +252 -0
- report_toolkit-0.1.0/tests/test_themes.py +267 -0
- report_toolkit-0.1.0/tests/test_tree.py +58 -0
- report_toolkit-0.1.0/tests/test_writer.py +134 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Heladio Lopes
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: report-toolkit
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Compose analytical reports in Python and render them as HTML
|
|
5
|
+
Author: Heladio Lopes
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Classifier: Topic :: Text Processing :: Markup :: HTML
|
|
9
|
+
Requires-Python: >=3.10
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Requires-Dist: mistune<4,>=3
|
|
13
|
+
Provides-Extra: pandas
|
|
14
|
+
Requires-Dist: pandas>=2; extra == "pandas"
|
|
15
|
+
Provides-Extra: altair
|
|
16
|
+
Requires-Dist: altair>=5; extra == "altair"
|
|
17
|
+
Provides-Extra: matplotlib
|
|
18
|
+
Requires-Dist: matplotlib>=3.7; extra == "matplotlib"
|
|
19
|
+
Provides-Extra: plotly
|
|
20
|
+
Requires-Dist: plotly>=5; extra == "plotly"
|
|
21
|
+
Provides-Extra: templates
|
|
22
|
+
Requires-Dist: PyYAML<7,>=6; extra == "templates"
|
|
23
|
+
Provides-Extra: all
|
|
24
|
+
Requires-Dist: pandas>=2; extra == "all"
|
|
25
|
+
Requires-Dist: altair>=5; extra == "all"
|
|
26
|
+
Requires-Dist: matplotlib>=3.7; extra == "all"
|
|
27
|
+
Requires-Dist: plotly>=5; extra == "all"
|
|
28
|
+
Requires-Dist: PyYAML<7,>=6; extra == "all"
|
|
29
|
+
Provides-Extra: offline
|
|
30
|
+
Requires-Dist: altair>=5; extra == "offline"
|
|
31
|
+
Requires-Dist: vl-convert-python>=1; extra == "offline"
|
|
32
|
+
Dynamic: license-file
|
|
33
|
+
|
|
34
|
+
# report-toolkit
|
|
35
|
+
|
|
36
|
+
Build analytical reports in Python or Markdown templates and export styled HTML
|
|
37
|
+
with tables, charts, sections, and column layouts.
|
|
38
|
+
|
|
39
|
+
## Install
|
|
40
|
+
|
|
41
|
+
Install the package:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
pip install report-toolkit
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
From a checkout:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
uv sync
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
For tables, charts, and YAML template metadata, use `uv sync --extra all`.
|
|
54
|
+
Individual extras are `pandas`, `altair`, `matplotlib`, `plotly`, and `templates`;
|
|
55
|
+
`offline` additionally supports embedding Altair's JavaScript.
|
|
56
|
+
|
|
57
|
+
## Quick start
|
|
58
|
+
|
|
59
|
+
```python
|
|
60
|
+
from report_toolkit import Report
|
|
61
|
+
|
|
62
|
+
report = Report('Sales review', author='Report author')
|
|
63
|
+
report.heading(1, 'Summary')
|
|
64
|
+
report.markdown('Revenue **increased** this month.')
|
|
65
|
+
report.unordered(['Review the results', 'Plan the next month'])
|
|
66
|
+
report.write('sales.html', toc=True)
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Open `sales.html` in a browser.
|
|
70
|
+
|
|
71
|
+
## Documentation
|
|
72
|
+
|
|
73
|
+
Start with [Getting Started](docs/getting-started.md), use
|
|
74
|
+
[Common Tasks](docs/common-tasks.md) for recipes, and consult the
|
|
75
|
+
[API Reference](docs/api-reference.md) for signatures and constraints.
|
|
76
|
+
|
|
77
|
+
## Two equivalent examples
|
|
78
|
+
|
|
79
|
+
[Python composition](examples/sales_report.py) and
|
|
80
|
+
[Markdown templates](examples/template_report.py), using
|
|
81
|
+
[monthly_sales.md](examples/monthly_sales.md), generate the same sales report.
|
|
82
|
+
They demonstrate shared text, list, table, chart, and layout capabilities.
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
uv run --extra all python examples/sales_report.py
|
|
86
|
+
uv run --extra all python examples/template_report.py
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Each prints its report tree and output path. Open `examples/sales_report.html`
|
|
90
|
+
and `examples/template_report.html` in a browser. Altair and Plotly charts
|
|
91
|
+
require network access for their JavaScript. Raw HTML is covered in the
|
|
92
|
+
[recipes](docs/common-tasks.md#insert-trusted-html), since templates escape it.
|
|
93
|
+
|
|
94
|
+
## Themes
|
|
95
|
+
|
|
96
|
+
Export with `style={'mode': 'dark'}`, or use `style={'mode': 'auto'}` to follow
|
|
97
|
+
the reader's system appearance. Choose `slate`, `azure`, `parchment`, or `ember`
|
|
98
|
+
with `style={'palette': 'parchment'}`. The default preserves the previous light
|
|
99
|
+
appearance. Define reusable `Style`, `Theme`, and `Palette` objects;
|
|
100
|
+
see [Themes](docs/themes.md) for customization and migration from `theme=`, and the
|
|
101
|
+
[theme gallery](examples/theme_gallery.py).
|
|
102
|
+
|
|
103
|
+
## Development
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
uv run --extra all pytest
|
|
107
|
+
uv run --extra all make test
|
|
108
|
+
uv run ruff check .
|
|
109
|
+
uv run ruff format --check .
|
|
110
|
+
uv run make build
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
`make test` and pytest both run the unittest-compatible suite, including the
|
|
114
|
+
example integration test. Optional integration tests skip when dependencies are absent.
|
|
115
|
+
Version tags run tests, Ruff lint, and a format check before the release workflow
|
|
116
|
+
builds and publishes to PyPI.
|
|
117
|
+
|
|
118
|
+
Theming code lives in `src/report_toolkit/themes/`: structural defaults belong in
|
|
119
|
+
`theme.py`, color values in `palette.py`, and configuration normalization in
|
|
120
|
+
`style.py`. Edit `src/report_toolkit/resources/report.css` for static report CSS;
|
|
121
|
+
HTML-specific scoping and dynamic style generation live in the writer. CSS is
|
|
122
|
+
packaged with the library and embedded in exported HTML. After changing resources
|
|
123
|
+
or package-data settings, run `make build` and verify the built distributions.
|
|
124
|
+
|
|
125
|
+
Artifact layout is configurable per item:
|
|
126
|
+
|
|
127
|
+
```python
|
|
128
|
+
report.add(table, center=True)
|
|
129
|
+
report.add(chart, width='full', expand='always')
|
|
130
|
+
report.write('report.html', pretty=True) # Compact markup is the default.
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
Tables and charts use native width by default. Oversized artifacts offer an
|
|
134
|
+
centered expanded view with zoom controls and a Close icon. Zoom is available
|
|
135
|
+
only in the expanded preview.
|
|
136
|
+
See [artifact options](docs/api-reference.md#analytical-artifacts) for details.
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# report-toolkit
|
|
2
|
+
|
|
3
|
+
Build analytical reports in Python or Markdown templates and export styled HTML
|
|
4
|
+
with tables, charts, sections, and column layouts.
|
|
5
|
+
|
|
6
|
+
## Install
|
|
7
|
+
|
|
8
|
+
Install the package:
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
pip install report-toolkit
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
From a checkout:
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
uv sync
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
For tables, charts, and YAML template metadata, use `uv sync --extra all`.
|
|
21
|
+
Individual extras are `pandas`, `altair`, `matplotlib`, `plotly`, and `templates`;
|
|
22
|
+
`offline` additionally supports embedding Altair's JavaScript.
|
|
23
|
+
|
|
24
|
+
## Quick start
|
|
25
|
+
|
|
26
|
+
```python
|
|
27
|
+
from report_toolkit import Report
|
|
28
|
+
|
|
29
|
+
report = Report('Sales review', author='Report author')
|
|
30
|
+
report.heading(1, 'Summary')
|
|
31
|
+
report.markdown('Revenue **increased** this month.')
|
|
32
|
+
report.unordered(['Review the results', 'Plan the next month'])
|
|
33
|
+
report.write('sales.html', toc=True)
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Open `sales.html` in a browser.
|
|
37
|
+
|
|
38
|
+
## Documentation
|
|
39
|
+
|
|
40
|
+
Start with [Getting Started](docs/getting-started.md), use
|
|
41
|
+
[Common Tasks](docs/common-tasks.md) for recipes, and consult the
|
|
42
|
+
[API Reference](docs/api-reference.md) for signatures and constraints.
|
|
43
|
+
|
|
44
|
+
## Two equivalent examples
|
|
45
|
+
|
|
46
|
+
[Python composition](examples/sales_report.py) and
|
|
47
|
+
[Markdown templates](examples/template_report.py), using
|
|
48
|
+
[monthly_sales.md](examples/monthly_sales.md), generate the same sales report.
|
|
49
|
+
They demonstrate shared text, list, table, chart, and layout capabilities.
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
uv run --extra all python examples/sales_report.py
|
|
53
|
+
uv run --extra all python examples/template_report.py
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Each prints its report tree and output path. Open `examples/sales_report.html`
|
|
57
|
+
and `examples/template_report.html` in a browser. Altair and Plotly charts
|
|
58
|
+
require network access for their JavaScript. Raw HTML is covered in the
|
|
59
|
+
[recipes](docs/common-tasks.md#insert-trusted-html), since templates escape it.
|
|
60
|
+
|
|
61
|
+
## Themes
|
|
62
|
+
|
|
63
|
+
Export with `style={'mode': 'dark'}`, or use `style={'mode': 'auto'}` to follow
|
|
64
|
+
the reader's system appearance. Choose `slate`, `azure`, `parchment`, or `ember`
|
|
65
|
+
with `style={'palette': 'parchment'}`. The default preserves the previous light
|
|
66
|
+
appearance. Define reusable `Style`, `Theme`, and `Palette` objects;
|
|
67
|
+
see [Themes](docs/themes.md) for customization and migration from `theme=`, and the
|
|
68
|
+
[theme gallery](examples/theme_gallery.py).
|
|
69
|
+
|
|
70
|
+
## Development
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
uv run --extra all pytest
|
|
74
|
+
uv run --extra all make test
|
|
75
|
+
uv run ruff check .
|
|
76
|
+
uv run ruff format --check .
|
|
77
|
+
uv run make build
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
`make test` and pytest both run the unittest-compatible suite, including the
|
|
81
|
+
example integration test. Optional integration tests skip when dependencies are absent.
|
|
82
|
+
Version tags run tests, Ruff lint, and a format check before the release workflow
|
|
83
|
+
builds and publishes to PyPI.
|
|
84
|
+
|
|
85
|
+
Theming code lives in `src/report_toolkit/themes/`: structural defaults belong in
|
|
86
|
+
`theme.py`, color values in `palette.py`, and configuration normalization in
|
|
87
|
+
`style.py`. Edit `src/report_toolkit/resources/report.css` for static report CSS;
|
|
88
|
+
HTML-specific scoping and dynamic style generation live in the writer. CSS is
|
|
89
|
+
packaged with the library and embedded in exported HTML. After changing resources
|
|
90
|
+
or package-data settings, run `make build` and verify the built distributions.
|
|
91
|
+
|
|
92
|
+
Artifact layout is configurable per item:
|
|
93
|
+
|
|
94
|
+
```python
|
|
95
|
+
report.add(table, center=True)
|
|
96
|
+
report.add(chart, width='full', expand='always')
|
|
97
|
+
report.write('report.html', pretty=True) # Compact markup is the default.
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Tables and charts use native width by default. Oversized artifacts offer an
|
|
101
|
+
centered expanded view with zoom controls and a Close icon. Zoom is available
|
|
102
|
+
only in the expanded preview.
|
|
103
|
+
See [artifact options](docs/api-reference.md#analytical-artifacts) for details.
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "report-toolkit"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "Compose analytical reports in Python and render them as HTML"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
requires-python = ">=3.10"
|
|
7
|
+
license = "MIT"
|
|
8
|
+
authors = [{name = "Heladio Lopes"}]
|
|
9
|
+
dependencies = ["mistune>=3,<4"]
|
|
10
|
+
classifiers = [
|
|
11
|
+
"Programming Language :: Python :: 3",
|
|
12
|
+
"Topic :: Text Processing :: Markup :: HTML",
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
[project.optional-dependencies]
|
|
16
|
+
pandas = ["pandas>=2"]
|
|
17
|
+
altair = ["altair>=5"]
|
|
18
|
+
matplotlib = ["matplotlib>=3.7"]
|
|
19
|
+
plotly = ["plotly>=5"]
|
|
20
|
+
templates = ["PyYAML>=6,<7"]
|
|
21
|
+
all = ["pandas>=2", "altair>=5", "matplotlib>=3.7", "plotly>=5", "PyYAML>=6,<7"]
|
|
22
|
+
offline = ["altair>=5", "vl-convert-python>=1"]
|
|
23
|
+
|
|
24
|
+
[dependency-groups]
|
|
25
|
+
dev = ["pytest>=8", "ruff>=0.9", "build>=1"]
|
|
26
|
+
|
|
27
|
+
[tool.setuptools.packages.find]
|
|
28
|
+
where = ["src"]
|
|
29
|
+
|
|
30
|
+
[tool.setuptools.package-data]
|
|
31
|
+
report_toolkit = ["resources/*.css", "resources/*.js"]
|
|
32
|
+
|
|
33
|
+
[build-system]
|
|
34
|
+
requires = ["setuptools>=77"]
|
|
35
|
+
build-backend = "setuptools.build_meta"
|
|
36
|
+
|
|
37
|
+
[tool.ruff.format]
|
|
38
|
+
quote-style = "single"
|
|
39
|
+
indent-style = "space"
|
|
40
|
+
|
|
41
|
+
[tool.ruff.lint.per-file-ignores]
|
|
42
|
+
"__init__.py" = ["E402"]
|
|
43
|
+
"**/{tests,docs,tools}/*" = ["E402"]
|
|
44
|
+
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"""Compose analytical reports and render them as HTML."""
|
|
2
|
+
|
|
3
|
+
from ._template import TemplateError
|
|
4
|
+
from .adapters import Adapter, AdapterRegistry, RenderedArtifact, default_registry
|
|
5
|
+
from .composer import Report
|
|
6
|
+
from .model import (
|
|
7
|
+
Artifact,
|
|
8
|
+
Columns,
|
|
9
|
+
Container,
|
|
10
|
+
Document,
|
|
11
|
+
List,
|
|
12
|
+
Markdown,
|
|
13
|
+
Node,
|
|
14
|
+
Panel,
|
|
15
|
+
RawHTML,
|
|
16
|
+
Section,
|
|
17
|
+
)
|
|
18
|
+
from .themes import Palette, Style, Theme, get_palette, get_theme
|
|
19
|
+
from .writer import HTMLWriter
|
|
20
|
+
|
|
21
|
+
__all__ = [
|
|
22
|
+
'Adapter',
|
|
23
|
+
'AdapterRegistry',
|
|
24
|
+
'Artifact',
|
|
25
|
+
'Columns',
|
|
26
|
+
'Container',
|
|
27
|
+
'Document',
|
|
28
|
+
'HTMLWriter',
|
|
29
|
+
'List',
|
|
30
|
+
'Markdown',
|
|
31
|
+
'Node',
|
|
32
|
+
'Palette',
|
|
33
|
+
'Panel',
|
|
34
|
+
'RawHTML',
|
|
35
|
+
'RenderedArtifact',
|
|
36
|
+
'Report',
|
|
37
|
+
'Section',
|
|
38
|
+
'Style',
|
|
39
|
+
'TemplateError',
|
|
40
|
+
'Theme',
|
|
41
|
+
'default_registry',
|
|
42
|
+
'get_palette',
|
|
43
|
+
'get_theme',
|
|
44
|
+
]
|