From 1dba70b65ee5d3f29860f02cf52447f19cbc531c Mon Sep 17 00:00:00 2001 From: Olivier Cots Date: Tue, 1 Sep 2026 22:16:35 +0200 Subject: [PATCH] Fix documentation Makie rendering and SVG output Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- docs/make.jl | 18 +++++++++++++++++- docs/src/serialization/plotting.md | 3 +-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/docs/make.jl b/docs/make.jl index c55cfb8b..7b2cbb0f 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -61,7 +61,23 @@ end # ═══════════════════════════════════════════════════════════════════════════════ # Docstrings from external packages # ═══════════════════════════════════════════════════════════════════════════════ -using JLD2, JSON3, Plots, CairoMakie +using JLD2, JSON3 + +# plotting +using Plots +import CairoMakie # `import`, not `using`: keeps Makie's `plot`/`plot!` out of Main, + # which would collide with Plots' `plot`/`plot!` 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. 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 + const CTModelsJLD = Base.get_extension(CTModels, :CTModelsJLD) const CTModelsJSON = Base.get_extension(CTModels, :CTModelsJSON) const CTModelsPlots = Base.get_extension(CTModels, :CTModelsPlots) diff --git a/docs/src/serialization/plotting.md b/docs/src/serialization/plotting.md index 868ea711..db52bc17 100644 --- a/docs/src/serialization/plotting.md +++ b/docs/src/serialization/plotting.md @@ -7,7 +7,6 @@ CurrentModule = CTModels ```@setup plt using Plots using CairoMakie: CairoMakie, Makie -Base.showable(::MIME"image/png", ::Plots.Plot) = false ``` When `Plots` is loaded, the `CTModelsPlots` extension adds a recipe so a @@ -50,7 +49,7 @@ The recipe accepts keyword arguments that control the arrangement and how the co displayed: | Keyword | Values | Effect | -|---|---|---| +| --- | --- | --- | | `layout` | `:group` / `:split` | one figure per quantity, or state/costate split | | `control` | `:components` / `:norm` / `:all` | plot each control, its norm, or both | | `time` | `:default` / `:normalize` | physical time, or rescaled to ``[0, 1]`` |