From 8181b46b58c2d9215088275608bd4ab875b48006 Mon Sep 17 00:00:00 2001 From: Olivier Cots Date: Tue, 1 Sep 2026 09:24:47 +0200 Subject: [PATCH] docs: render CairoMakie figures as SVG, like Plots MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Phase K added the first Makie page (examples/logo.md) but its figures came out as raster PNG: DocumenterVitepress ranks image/png (4.0) above image/svg+xml (3.0), and CairoMakie — contrary to the note in Handbook/VITEPRESS-DOC.md — responds to both MIME types, so PNG won. Fixed the same way as Plots (#903): disable PNG capture globally in make.jl so DocumenterVitepress falls back to SVG. - `import CairoMakie`, not `using`: `using` would pull Makie's `plot` / `plot!` into Main, where they collide with Plots' and break the `@docs` block on results/plot.md (`undefined binding 'plot!'`). - `CairoMakie.activate!(; type="svg")` + `Base.showable(::MIME"image/png", ::CairoMakie.Makie.Figure) = false`. Verified: full build exit 0, 0 unresolved @ref, all 50 built figures are now .svg (the logo page's three included). Co-Authored-By: Claude Sonnet 5 --- docs/make.jl | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/docs/make.jl b/docs/make.jl index 8dfa53eb8..481389409 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -40,15 +40,18 @@ using JLD2 # plotting using Plots +import CairoMakie # `import`, not `using`: keeps Makie's `plot`/`plot!` out of Main, +# which would collide with Plots' in the `@docs` block on results/plot.md # DocumenterVitepress picks the highest-priority MIME type a plot object responds to # (image/png: 4.0 over image/svg+xml: 3.0) — the opposite of Documenter.HTML, which -# prefers SVG. Plots.jl (unlike CairoMakie) responds to both, so PNG wins unless this -# is disabled. Global, not per-page: Base.showable is a method on the Plots.Plot type, -# so setting it once here — before any @example block runs — covers every page that -# ever calls `using Plots`, not just the ones that do today. See Handbook/VITEPRESS-DOC.md -# "Plot image format — SVG vs PNG". +# prefers SVG. Both Plots.jl and CairoMakie respond to `image/png`, so PNG wins for +# every figure unless it is disabled. Set once here, before any @example block runs, +# so it covers every page present or future — not just the ones plotting today. See +# Handbook/VITEPRESS-DOC.md "Plot image format — SVG vs PNG". Base.showable(::MIME"image/png", ::Plots.Plot) = false +CairoMakie.activate!(; type="svg") +Base.showable(::MIME"image/png", ::CairoMakie.Makie.Figure) = false # DocumenterVitepress (0.3.5) hard-codes `collapsed: false` on every sidebar group # (`vitepress_config.jl`'s `pagelist2str` for a nested `name => children` entry), so the