diff --git a/.gitignore b/.gitignore index 0390233..9002680 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,7 @@ # Project specific # ============================================================================ -docs/_static/charts +docs/_static/charts/*.html docs/api/autogen docs/api/public diff --git a/MANIFEST.in b/MANIFEST.in index a167133..a1de031 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -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 diff --git a/Makefile b/Makefile index bbab492..dbabb31 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/docs/_static/charts/basic.webp b/docs/_static/charts/basic.webp new file mode 100644 index 0000000..9581732 Binary files /dev/null and b/docs/_static/charts/basic.webp differ diff --git a/docs/_static/charts/basic_hist.webp b/docs/_static/charts/basic_hist.webp new file mode 100644 index 0000000..e83da63 Binary files /dev/null and b/docs/_static/charts/basic_hist.webp differ diff --git a/docs/_static/charts/lincoln_weather.webp b/docs/_static/charts/lincoln_weather.webp new file mode 100644 index 0000000..737fecc Binary files /dev/null and b/docs/_static/charts/lincoln_weather.webp differ diff --git a/docs/_static/charts/lincoln_weather_red_blue.webp b/docs/_static/charts/lincoln_weather_red_blue.webp new file mode 100644 index 0000000..8f2f8da Binary files /dev/null and b/docs/_static/charts/lincoln_weather_red_blue.webp differ diff --git a/docs/_static/charts/probly.webp b/docs/_static/charts/probly.webp new file mode 100644 index 0000000..6dbd688 Binary files /dev/null and b/docs/_static/charts/probly.webp differ diff --git a/docs/conf.py b/docs/conf.py index 04f69a3..2754ece 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -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 diff --git a/tests/e2e/test_examples.py b/tests/e2e/test_examples.py index 2e3821d..475399a 100644 --- a/tests/e2e/test_examples.py +++ b/tests/e2e/test_examples.py @@ -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: @@ -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.""" @@ -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__":