Skip to content

Commit

Permalink
v4.0.0 (#112)
Browse files Browse the repository at this point in the history
- New Features
    - Command line tools for printing default Jinja and CSS files
- Fixes
    - Config YAML now read with safe loader
- Deprecations
    - Removed CDN theme links
- Dependencies
    - Image content now supported without PIL
  • Loading branch information
domvwt authored Apr 19, 2022
1 parent 784a0b5 commit 05d0b98
Show file tree
Hide file tree
Showing 43 changed files with 891 additions and 685 deletions.
1 change: 1 addition & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ exclude_lines =
ignore_errors = True
omit =
tests/*
_cli.py
2 changes: 1 addition & 1 deletion .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ ignore =
E203, # whitespace before ':'
per-file-ignores =
__init__.py:E402, F401
_cdnlinks.py:E501
cdnlinks.py:E501
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Scratch files for testing
/scratch
*scratch*.ipynb
*scratch*.py
image.jpg
Expand Down
11 changes: 7 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,20 @@ help:

clean: clean-build clean-pyc clean-test ## remove all build, test, coverage and Python artifacts

clean-build: ## remove build artifacts
clean-build:
rm -fr build/
rm -fr dist/
rm -fr .eggs/
find . -name '*.egg-info' -exec rm -fr {} +
find . -name '*.egg' -exec rm -f {} +

clean-pyc: ## remove Python file artifacts
clean-pyc:
find . -name '*.pyc' -exec rm -f {} +
find . -name '*.pyo' -exec rm -f {} +
find . -name '*~' -exec rm -f {} +
find . -name '__pycache__' -exec rm -fr {} +

clean-test: ## remove test and coverage artifacts
clean-test:
rm -fr .tox/
rm -f .coverage
rm -fr htmlcov/
Expand Down Expand Up @@ -90,7 +90,7 @@ deploydocs: ## deploy docs to github pages
mkdocs gh-deploy

class-diagram: ## make UML class diagram
pyreverse esparto -o png -f ALL --ignore _contentdeps.py,_options.py,_publish.py
pyreverse esparto -o png --ignore cdnlinks.py,contentdeps.py,_options.py,
mv classes.png devdocs/classes.png
rm packages.png

Expand All @@ -109,3 +109,6 @@ hooks: ## run pre-commit hooks on all files

install: clean ## install the package to the active Python's site-packages
poetry install

example_pages: ## make example pages
python tests/example_pages.py
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ Main Features
- Responsive Bootstrap grid layout
- Content adaptors for:
- [Markdown][Markdown]
- [Images][Pillow]
- [Images]
- [Pandas DataFrames][Pandas]
- [Matplotlib][Matplotlib]
- [Bokeh][Bokeh]
Expand Down Expand Up @@ -87,7 +87,6 @@ Dependencies

#### Optional

- [Pillow](https://python-pillow.org/) *(for image content)*
- [weasyprint](https://weasyprint.org/) *(for PDF output)*

License
Expand Down Expand Up @@ -125,7 +124,6 @@ Iris Report - [Webpage](https://domvwt.github.io/esparto/examples/iris-report.ht
[Bootstrap]: https://getbootstrap.com/
[Jinja]: https://jinja.palletsprojects.com/
[Markdown]: https://www.markdownguide.org/
[Pillow]: https://python-pillow.org/
[Pandas]: https://pandas.pydata.org/
[Matplotlib]: https://matplotlib.org/
[Bokeh]: https://bokeh.org/
Expand Down
Binary file modified devdocs/classes.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 0 additions & 9 deletions docs/02-user-guide/customisation.md

This file was deleted.

69 changes: 69 additions & 0 deletions docs/02-user-guide/output-options.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Output Options

## CSS and Jinja

Customising the look and feel of **esparto** pages is best achieved through
modifying or replacing the Jinja template and CSS style sheets.
Alternatively, CSS and Jinja sources can be passed to `es.options` as global
defaults, or passed to the `es.Page` constructor using the `es.OutputOptions` class.

```python
# Updating global defaults.
es.options.esparto_css = "./esparto.css"
es.options.jinja_template = "./esparto.html.jinja"
```

```python
# Using page level options.
output_options = es.OutputOptions(
esparto_css="./esparto.css",
jinja_template="./esparto.html.jinja",
)
page = es.Page(output_options=output_options)
```

Options can be saved and loaded from disk using class methods.
If an `esparto-config.yaml` file is found in the working directory, or at
`~/esparto-data/esparto-config.yaml`, it will be loaded automatically when
the library is imported.

```python
# These options will be loaded automatically for sessions in the same directory.
output_options.save("./esparto-config.yaml")

# These will be loaded only if no yaml file is found in the working directory.
output_options.save("~/esparto-data/esparto-config.yaml")
```

## Printing Default Resources

It's recommended to use the standard CSS and Jinja template files as a starting
point for any changes.
A command line interface is provided for printing the default resources.

```bash
# Print default esparto.css to `esparto.css`.
python -m esparto print_esparto_css > esparto.css
```

```bash
# Print default jinja template to `esparto.html.jinja`.
python -m esparto print_jinja_template > esparto.html.jinja
```

```bash
# Print default Bootstrap CSS to `bootstrap.css`.
python -m esparto print_bootstrap_css > bootstrap.css
```

```bash
# Print default output options to `esparto-config.yaml`.
python -m esparto print_default_options > esparto-config.yaml
```

## More options

For details on additional options please read the
[documentation for the Options module.](/03-api-reference/options/)

<br>
2 changes: 2 additions & 0 deletions docs/02-user-guide/quick-start.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Quick Start

A brief overview of the main API features.

## Create a Page

```python
Expand Down
6 changes: 3 additions & 3 deletions docs/03-api-reference/adaptors.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# esparto._adaptors
# esparto.design.adaptors

!!! info
The `content_adaptor` function is called internally when an explicit `Content` class is not provided.

Expand All @@ -16,7 +17,6 @@
{'New Page': [{'New Section': [{'Row 0': [{'Column 0': ['Markdown']}]}]}]}
```


## ::: esparto._adaptors
## ::: esparto.design.adaptors

<br>
18 changes: 9 additions & 9 deletions docs/03-api-reference/content.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# esparto._content
# esparto.design.content

!!! info
`Content` classes will usually be inferred from the content object type.
Expand All @@ -12,22 +12,22 @@

```

## ::: esparto._content.Content
## ::: esparto.design.content.Content

<br>

## ::: esparto._content.Markdown
## ::: esparto.design.content.Markdown

## ::: esparto._content.DataFramePd
## ::: esparto.design.content.DataFramePd

## ::: esparto._content.FigureMpl
## ::: esparto.design.content.FigureMpl

## ::: esparto._content.FigureBokeh
## ::: esparto.design.content.FigureBokeh

## ::: esparto._content.FigurePlotly
## ::: esparto.design.content.FigurePlotly

## ::: esparto._content.Image
## ::: esparto.design.content.Image

## ::: esparto._content.RawHTML
## ::: esparto.design.content.RawHTML

<br>
25 changes: 13 additions & 12 deletions docs/03-api-reference/layout.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# esparto._layout
# esparto.design.layout

!!! info
`Layout` classes are accessed from the top level module.
Expand All @@ -11,27 +11,28 @@

```

## ::: esparto._layout.Layout
## ::: esparto.design.layout.Layout

<br>

## ::: esparto._layout.Page
## ::: esparto.design.layout.Page

## ::: esparto._layout.Section
## ::: esparto.design.layout.Section

## ::: esparto._layout.CardSection
## ::: esparto.design.layout.CardSection

## ::: esparto._layout.Row
## ::: esparto.design.layout.Row

## ::: esparto._layout.CardRow
## ::: esparto.design.layout.CardRow

## ::: esparto._layout.CardRowEqual
## ::: esparto.design.layout.CardRowEqual

## ::: esparto._layout.Column
## ::: esparto.design.layout.Column

## ::: esparto._layout.Card
## ::: esparto.design.layout.Card

## ::: esparto._layout.Spacer
## ::: esparto.design.layout.Spacer

## ::: esparto._layout.PageBreak
## ::: esparto.design.layout.PageBreak

<br>
5 changes: 4 additions & 1 deletion docs/03-api-reference/options.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# esparto._options

!!! info
Default output options are configured through `es.options`.
Default options are configured through `es.options`, page level options can
be passed to the `Page` constructor.

Please read [the user guide](/02-user-guide/output-options) for more details.

## ::: esparto._options.OutputOptions

Expand Down
8 changes: 4 additions & 4 deletions docs/03-api-reference/publish.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# esparto._publish
# esparto.publish.output

!!! info
Publishing methods are accessed via Layout classes.
Expand All @@ -17,10 +17,10 @@

```

## ::: esparto._publish.publish_html
## ::: esparto.publish.output.publish_html

## ::: esparto._publish.publish_pdf
## ::: esparto.publish.output.publish_pdf

## ::: esparto._publish.nb_display
## ::: esparto.publish.output.nb_display

<br>
12 changes: 12 additions & 0 deletions docs/04-about/release-notes.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
Release Notes
=============

4.0.0 (2022-04-19)
------------------

- New Features
- Command line tools for printing default Jinja and CSS files
- Fixes
- Config YAML now read with safe loader
- Deprecations
- Removed CDN theme links
- Dependencies
- Image content now supported without PIL

3.0.2 (2022-02-28)
------------------

Expand Down
13 changes: 5 additions & 8 deletions esparto/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@

__author__ = """Dominic Thorn"""
__email__ = "[email protected]"
__version__ = "3.0.2"
__version__ = "4.0.0"

_MODULE_PATH: _Path = _Path(__file__).parent.absolute()


_OPTIONAL_DEPENDENCIES: _Set[str] = {
"PIL",
"PIL", # Only used for type checking and conversion
"IPython",
"matplotlib",
"pandas",
Expand All @@ -34,8 +34,8 @@
x.name for x in [_find_spec(dep) for dep in _OPTIONAL_DEPENDENCIES] if x
}

from esparto._cdnlinks import bootstrap_cdn_themes
from esparto._content import (
from esparto._options import OutputOptions, options
from esparto.design.content import (
DataFramePd,
FigureBokeh,
FigureMpl,
Expand All @@ -44,7 +44,7 @@
Markdown,
RawHTML,
)
from esparto._layout import (
from esparto.design.layout import (
Card,
CardRow,
CardRowEqual,
Expand All @@ -56,6 +56,3 @@
Section,
Spacer,
)
from esparto._options import OutputOptions, options

options._autoload()
4 changes: 4 additions & 0 deletions esparto/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from esparto import _cli

if __name__ == "__main__":
_cli.main()
Loading

0 comments on commit 05d0b98

Please sign in to comment.