From c0e29bc5569555ce508297d6191951eb694888fe Mon Sep 17 00:00:00 2001 From: Joergen Schartum Dokken Date: Wed, 7 Oct 2026 09:49:45 +0000 Subject: [PATCH] Fix gallery --- docs/_ext/demo_gallery.py | 34 +++++++++++++++++++++++++--------- pyproject.toml | 2 ++ 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/docs/_ext/demo_gallery.py b/docs/_ext/demo_gallery.py index 094528d..7ba52e8 100644 --- a/docs/_ext/demo_gallery.py +++ b/docs/_ext/demo_gallery.py @@ -57,18 +57,31 @@ GALLERY = "_static/gallery" SCENES = "_static/scenes" VIEWER = "viewer.html" -# Added to the viewer: load the script of the scene named by ?scene=, and show it +# Added to the viewer: show the scene named by ?scene=, from its script next to the viewer. The +# script is written into the page rather than requested, so that it also loads from file://, and +# before the viewer runs, as a module that only runs once the page is read. Like trame_vtk's own +# export, the scene is then shown by loadDataSet, which the viewer calls once it is ready; an +# older viewer, without that call, is ready already. LOADER = """ + """ @@ -78,7 +91,10 @@ ) # A plot of the html backend: the viewer with the scene, in base64, as the source of a frame EMBEDDED = re.compile(r'^\s*$', re.DOTALL) -EMBEDDED_SCENE = re.compile(r"var base64Str = "(?P[A-Za-z0-9+/=]+)";") +# Declared with var by trame_vtk before its viewer called loadDataSet, and with const since +EMBEDDED_SCENE = re.compile( + r"(?:var|let|const) base64Str = "(?P[A-Za-z0-9+/=]+)";" +) def _title(demo: Path) -> str: diff --git a/pyproject.toml b/pyproject.toml index aae8952..ca85f85 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -31,6 +31,8 @@ docs = [ "jupyter-book<2.0", "jupytext", "pyvista[all]>=0.45.0", + # The documentation's shared vtk.js viewer depends on the viewer and plots of trame-vtk + "trame-vtk>=2.11.16", "sphinxcontrib-bibtex", "sphinx-codeautolink", "scifem[gmsh]",