Skip to content

Commit

Permalink
Re-add WebP artefacts
Browse files Browse the repository at this point in the history
  • Loading branch information
tpvasconcelos committed Dec 24, 2024
1 parent fdf0c6d commit 61e56a8
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Project specific
# ============================================================================

docs/_static/charts
docs/_static/charts/*.html
docs/api/autogen
docs/api/public

Expand Down
3 changes: 1 addition & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,12 @@ include docs/make.bat
include docs/robots.txt
include docs/_static/favicon.ico
recursive-include docs *.md *.py *.rst
recursive-include docs/_static/charts *.html *.webp
recursive-include docs/_static/charts *.webp
recursive-include docs/_static/css *.css
recursive-include docs/_static/img *.png *.webp *.svg *.gif *.jpg
recursive-include docs/_static/js *.js
recursive-include docs/_templates *.html
prune docs/_build
prune docs/_static/charts
prune docs/api/autogen
prune docs/api/public

Expand Down
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ clean-all: clean-docs clean-build clean-pyc clean-cov clean-ci-caches clean-tox
.PHONY: clean-docs
clean-docs: ## remove documentation build artifacts
@echo "==> Removing documentation build artifacts..."
rm -fr docs/_build/ docs/_static/charts docs/api/autogen/ docs/api/public/
rm -fr docs/_build/ docs/api/autogen/ docs/api/public/
find . -wholename 'docs/_static/charts/*.html' -exec rm -fr {} +


.PHONY: clean-build
Expand Down
Binary file added docs/_static/charts/basic.webp
Binary file not shown.
Binary file added docs/_static/charts/basic_hist.webp
Binary file not shown.
Binary file added docs/_static/charts/lincoln_weather.webp
Binary file not shown.
Binary file not shown.
Binary file added docs/_static/charts/probly.webp
Binary file not shown.
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,8 +400,8 @@ def compile_all_plotly_charts() -> None:
path_charts = PATH_DOCS / "_static/charts"
print(f"Writing image artefacts to {path_charts}...")
for example in ALL_EXAMPLES:
example.to_html(path=path_charts, minify_html=True)
example.to_webp(path=path_charts)
example.to_html(path_charts, minify_html=True)
example.to_webp(path_charts)

# Fix the end-of-file markers in the generated HTML files
from pre_commit_hooks.end_of_file_fixer import main as end_of_file_fixer
Expand Down
22 changes: 18 additions & 4 deletions tests/e2e/test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,18 @@
from ridgeplot_examples import ALL_EXAMPLES, Example
from ridgeplot_examples._base import round_fig_data

JSON_SIG_FIGS = 8

PATH_ROOT = Path(__file__).parents[2].resolve()
PATH_ARTIFACTS = PATH_ROOT / "tests/e2e/artifacts"
PATH_CHARTS = PATH_ROOT / "docs/_static/charts"


def test_paths_exist() -> None:
assert PATH_ROOT.name == "ridgeplot"
assert PATH_ARTIFACTS.is_dir()
assert PATH_CHARTS.is_dir()


@pytest.mark.parametrize("example", ALL_EXAMPLES, ids=lambda e: e.plot_id)
def test_examples_width_height_set(example: Example) -> None:
Expand All @@ -16,10 +28,6 @@ def test_examples_width_height_set(example: Example) -> None:
assert isinstance(example.fig.layout.height, int), msg


JSON_SIG_FIGS = 8
PATH_ARTIFACTS = Path(__file__).parent / "artifacts"


@pytest.mark.parametrize("example", ALL_EXAMPLES, ids=lambda e: e.plot_id)
def test_regressions(example: Example) -> None:
"""Verify that the rendered JPEG images match the current artifacts."""
Expand All @@ -46,6 +54,12 @@ def _update_all_artifacts() -> None:
# (Don't use JPEGs for regression tests because outputs
# will vary between Plotly versions and platforms)
example.to_jpeg(PATH_ARTIFACTS)
# Just to keep things in sync with the docs, we should also
# regenerate the WebP images used there. These are tracked
# by Git because some are used in the README (which needs
# to be rendered on GitHub), otherwise they would be in
# the .gitignore file (like the HTML artifacts).
example.to_webp(PATH_CHARTS)


if __name__ == "__main__":
Expand Down

0 comments on commit 61e56a8

Please sign in to comment.