Repository navigation
docs: force SVG output for Plots-generated figures - #903
Merged
Merged
Conversation
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. CairoMakie isn't affected (its figures
don't respond to image/png at all), but Plots.jl responds to both, so PNG
won by default: every one of the 14 pages that `using Plots` was rendering
raster images instead of vector ones, a regression from the Documenter →
DocumenterVitepress migration that went unnoticed since nothing failed —
the pages just looked different.
Documented precisely in Handbook/VITEPRESS-DOC.md ("Plot image format — SVG
vs PNG"), which suggests a per-page `Base.showable(::MIME"image/png",
::Plots.Plot) = false` override. Applied globally instead, once in
docs/make.jl right where Plots is already loaded: Base.showable is a method
on the Plots.Plot type, so setting it before any @example block runs covers
every page that calls `using Plots`, present or future, rather than needing
each new page to remember it.
Verified: rebuilt from scratch, every one of the 46 generated figures is now
.svg (previously counted at least 1 raster .png per Plots-using page); the
only remaining .png in the build output is the pre-existing static
rocket-def.png asset, untouched. Full test suite unchanged (2246 pass / 0
fail / 2 broken) — docs/make.jl isn't loaded by Pkg.test().
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
DocumenterVitepress picks the highest-priority MIME type a plot object responds to
(
image/png: 4.0 overimage/svg+xml: 3.0) — the opposite ofDocumenter.HTML, whichprefers SVG.
CairoMakieisn't affected (its figures don't respond toimage/pngat all), butPlots.jlresponds to both, so PNG wins by default: every one of the 14 pages thatusing Plotswas rendering raster images instead of vector ones — a regression from theDocumenter → DocumenterVitepress migration that went unnoticed since nothing failed, the pages
just looked different.
Documented precisely in
Handbook/VITEPRESS-DOC.md("Plot image format — SVG vs PNG"), whichsuggests a per-page
Base.showable(::MIME"image/png", ::Plots.Plot) = falseoverride. Appliedglobally instead, once in
docs/make.jlright wherePlotsis already loaded —Base.showableis a method on the
Plots.Plottype, so setting it before any@exampleblock runs coversevery page that calls
using Plots, present or future.Verification
.svg. The only remaining.pngin the build output is the pre-existing staticrocket-def.pngasset, untouched.docs/make.jlisn't loaded byPkg.test()).🤖 Generated with Claude Code