Skip to content

Commit 245b1e5

Browse files
authored
v3.0.0 (#90)
- API - Page now accepts `max_width` and `output_options` arguments - Content classes no longer accept `width` or `height` arguments - New Features - Output rendering options can now be configured at page level - Additional markdown features recognised - Fixes - JavaScript is now placed at end of page so HTML is loaded first - Page Style - Removed unnecessary indentation - Tables now render in minimal, clean style - Improvements to sizing and centring of plots - Cleaned up unnecessary HTML and CSS - Majority of CSS attributes moved to `esparto.css` - Dependencies - Pillow is now optional - BeautifulSoup4 is now required - Upper version limits removed from all - Other - Type hints implemented with ~100% coverage
1 parent 5e27471 commit 245b1e5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+6897
-7983
lines changed

‎.flake8‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[flake8]
22
max-line-length = 120
3-
exclude = scratch.*, docs/
3+
exclude = scratch.py, docs/
44
ignore =
55
W503, # line break before binary operator
66
E203, # whitespace before ':'

‎.github/workflows/lint-and-test.yml‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
22
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
33

4-
name: Lint and Test Python Library
4+
name: tests
55

66
on:
77
push:
@@ -33,7 +33,7 @@ jobs:
3333
- name: Install dependencies
3434
run: |
3535
python -m pip install --upgrade pip
36-
python -m pip install flake8 pytest coverage
36+
python -m pip install flake8 pytest coverage html5lib
3737
python -m pip install .
3838
- name: Lint with flake8
3939
run: |
@@ -46,11 +46,10 @@ jobs:
4646
coverage run --append --source esparto -m pytest
4747
- name: Install optional dependencies
4848
run: |
49-
python -m pip install ipython pandas matplotlib bokeh plotly kaleido "weasyprint<53" beautifulsoup4 html5lib
50-
- name: Test full install with pytest
49+
python -m pip install ipython pandas matplotlib bokeh plotly kaleido "weasyprint<53" html5lib
50+
- name: Test full install with pytest
5151
run: |
5252
coverage run --append --source esparto -m pytest
5353
- name: Upload coverage to codecov.io
5454
run: |
5555
bash <(curl -s https://codecov.io/bash)
56-

‎.gitignore‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ esparto-doc.html
66
esparto-quick.html
77
esparto-doc.pdf
88
docs/examples/*.html
9+
/*.html
10+
/*.pdf
911

1012
# IDE files
1113
.vscode
@@ -113,3 +115,5 @@ ENV/
113115

114116
# mypy
115117
.mypy_cache/
118+
.markdownlint.json
119+
my-report.html

‎.pre-commit-config.yaml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ repos:
3131
language: system
3232
entry: poetry run mypy
3333
types: [python]
34+
exclude: tests/
3435
- id: version
3536
name: Version
3637
language: system

‎.travis.yml‎

Lines changed: 0 additions & 22 deletions
This file was deleted.

‎Makefile‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,10 @@ lint: ## check style with flake8
5757
flake8 esparto tests
5858

5959
mypy: ## check type hints
60-
mypy esparto tests
60+
mypy esparto --strict
6161

6262
isort: ## sort imports
63-
isort esparto tests
63+
isort esparto tests --profile black
6464

6565
cqa: format isort lint mypy ## run all cqa tools
6666

‎README.md‎

Lines changed: 80 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -3,98 +3,131 @@ esparto
33

44
[![image](https://img.shields.io/pypi/v/esparto.svg)](https://pypi.python.org/pypi/esparto)
55
[![PyPI pyversions](https://img.shields.io/pypi/pyversions/esparto.svg)](https://pypi.python.org/pypi/esparto/)
6-
[![Build Status](https://travis-ci.com/domvwt/esparto.svg?branch=main)](https://travis-ci.com/domvwt/esparto)
6+
![Build Status](https://github.com/domvwt/esparto/actions/workflows/lint-and-test.yml/badge.svg)
77
[![codecov](https://codecov.io/gh/domvwt/esparto/branch/main/graph/badge.svg?token=35J8NZCUYC)](https://codecov.io/gh/domvwt/esparto)
88
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=domvwt_esparto&metric=alert_status)](https://sonarcloud.io/dashboard?id=domvwt_esparto)
99
![PyPI - Downloads](https://img.shields.io/pypi/dm/esparto)
1010

11+
Introduction
12+
------------
1113

12-
## Introduction
13-
**esparto** is a Python package for building shareable reports with content
14-
from popular data analysis libraries.
15-
With just a few lines of code, **esparto** turns DataFrames, plots, and
16-
Markdown into an interactive webpage or PDF document.
14+
**esparto** is a Python library for building data driven reports with content
15+
from popular analytics packages. The project takes a straightforward approach
16+
to document design; with a focus on usability, portability, and extensiblity.
1717

18-
Documents produced by **esparto** are completely portable - no backend server
19-
is required - and entirely customisable using CSS and Jinja templating.
20-
All content dependencies are declared inline or loaded via a CDN, meaning your
21-
reports can be shared by email, hosted on a standard http server, or made
22-
available as static pages as-is.
18+
Creating a report is as simple as instantiating a Page object and 'adding' content
19+
in the form of DataFrames, plots, and markdown text. Documents can be built interactively
20+
in a notebook environment, and the results shared as a self-contained HTML
21+
page or PDF file.
2322

23+
Further customisation of the output is possible by passing a CSS stylesheet,
24+
changing the [Jinja](Jinja) template, or declaring additional element styles within
25+
the code. The responsive [Bootstrap](Bootstrap) grid ensures documents adapt to
26+
any viewing device.
27+
28+
Basic Usage
29+
-----------
2430

25-
## Basic Usage
2631
```python
2732
import esparto as es
33+
34+
# Do some analysis
35+
pandas_dataframe = ...
36+
plotly_figure = ...
37+
38+
# Create a Page object
2839
page = es.Page(title="My Report")
29-
page["Data Analysis"] = (pandas_dataframe, plotly_figure)
40+
41+
# Add content
42+
page["Data Analysis"]["Plot"] = plotly_figure
43+
page["Data Analysis"]["Data"] = pandas_dataframe
44+
45+
# Save to HTML or PDF
3046
page.save_html("my-report.html")
47+
page.save_pdf("my-report.pdf")
48+
3149
```
3250

51+
Main Features
52+
-------------
3353

34-
## Main Features
35-
* Automatic and adaptive layout
36-
* Customisable with CSS or Jinja
37-
* Jupyter Notebook friendly
38-
* Output as HTML or PDF
39-
* Built-in adaptors for:
40-
* Markdown
41-
* Images
42-
* [Pandas DataFrames][Pandas]
43-
* [Matplotlib][Matplotlib]
44-
* [Bokeh][Bokeh]
45-
* [Plotly][Plotly]
54+
- Interactive document design with Jupyter Notebooks
55+
- Share as self-contained HTML or PDF
56+
- Customise with CSS and Jinja
57+
- Responsive Bootstrap grid layout
58+
- Content adaptors for:
59+
- [Markdown][Markdown]
60+
- [Images][Pillow]
61+
- [Pandas DataFrames][Pandas]
62+
- [Matplotlib][Matplotlib]
63+
- [Bokeh][Bokeh]
64+
- [Plotly][Plotly]
4665

66+
Installation
67+
------------
4768

48-
## Installation
4969
**esparto** is available from [PyPI][PyPI] and [Conda][Conda]:
70+
5071
```bash
5172
pip install esparto
5273
```
74+
5375
```bash
5476
conda install esparto -c conda-forge
5577
```
5678

57-
If PDF output is required, [Weasyprint](https://weasyprint.org/) must also be installed.
79+
Dependencies
80+
------------
81+
82+
- [python](https://python.org/) >= 3.6
83+
- [jinja2](https://palletsprojects.com/p/jinja/)
84+
- [markdown](https://python-markdown.github.io/)
85+
- [BeautifulSoup](https://www.crummy.com/software/BeautifulSoup/)
86+
- [PyYAML](https://pyyaml.org/)
5887

59-
## Dependencies
60-
* [python](https://python.org/) >= 3.6
61-
* [jinja2](https://palletsprojects.com/p/jinja/)
62-
* [markdown](https://python-markdown.github.io/)
63-
* [Pillow](https://python-pillow.org/)
64-
* [PyYAML](https://pyyaml.org/)
65-
* [weasyprint](https://weasyprint.org/) _(optional - required for PDF output)_
88+
#### Optional
6689

90+
- [Pillow](https://python-pillow.org/) *(for image content)*
91+
- [weasyprint](https://weasyprint.org/) *(for PDF output)*
92+
93+
License
94+
-------
6795

68-
## License
6996
[MIT](https://opensource.org/licenses/MIT)
7097

98+
Documentation
99+
-------------
100+
101+
Documentation and examples are available at
102+
[domvwt.github.io/esparto/](https://domvwt.github.io/esparto/).
71103

72-
## Documentation
73-
Full documentation and examples are available at [domvwt.github.io/esparto/](https://domvwt.github.io/esparto/).
104+
Contributions, Issues, and Requests
105+
-----------------------------------
74106

75-
## Contributions, Issues, and Requests
76-
All feedback and contributions are welcome - please raise an issue or pull request on [GitHub][GitHub].
107+
Feedback and contributions are welcome - please raise an issue or pull request
108+
on [GitHub][GitHub].
77109

110+
Examples
111+
--------
78112

79-
## Examples
80113
Iris Report - [Webpage](https://domvwt.github.io/esparto/examples/iris-report.html) |
81114
[PDF](https://domvwt.github.io/esparto/examples/iris-report.pdf)
82115

83-
Bokeh and Plotly - [Webpage](https://domvwt.github.io/esparto/examples/interactive-plots.html) |
84-
[PDF](https://domvwt.github.io/esparto/examples/interactive-plots.pdf)
85-
86116
<br>
87117

88118
<p width=100%>
89-
<img width=80% src="https://github.com/domvwt/esparto/blob/fdc0e787c0bc013d16667773e82e21c647b71d91/docs/images/iris-report-compressed.png?raw=true" alt="example page" style="border-radius:0.5%;">
119+
<img width=100% src="https://github.com/domvwt/esparto/blob/1857f1d7411f12c37c96f8f5d60ff7012071851f/docs/images/iris-report-compressed.png?raw=true" alt="example page" style="border-radius:0.5%;">
90120
</p>
91121

92-
<!-- Links -->
122+
<!-- * Links -->
93123
[PyPI]: https://pypi.org/project/esparto/
94124
[Conda]: https://anaconda.org/conda-forge/esparto
95-
[Bootstrap]: https://getbootstrap.com/docs/4.6/getting-started/introduction/
125+
[Bootstrap]: https://getbootstrap.com/
126+
[Jinja]: https://jinja.palletsprojects.com/
127+
[Markdown]: https://www.markdownguide.org/
128+
[Pillow]: https://python-pillow.org/
96129
[Pandas]: https://pandas.pydata.org/
97130
[Matplotlib]: https://matplotlib.org/
98-
[Bokeh]: https://docs.bokeh.org/en/latest/index.html
131+
[Bokeh]: https://bokeh.org/
99132
[Plotly]: https://plotly.com/
100133
[GitHub]: https://github.com/domvwt/esparto

‎devdocs/classes.png‎

96 KB
Loading
-720 KB
Binary file not shown.
-51.8 KB
Binary file not shown.

0 commit comments

Comments
 (0)