From d2816dce34f3e6f6b468da049dfc13e860ab7b43 Mon Sep 17 00:00:00 2001 From: Olivier Cots Date: Mon, 31 Aug 2026 15:21:49 +0200 Subject: [PATCH] docs: start the left sidebar with every group collapsed DocumenterVitepress 0.3.5 hard-codes `collapsed: false` on every sidebar group (vitepress_config.jl's `pagelist2str`), with no MarkdownVitepress option to change it, so the whole nav tree renders fully expanded. Override that one method in make.jl to emit `collapsed: true` for the sidebar: each group starts folded and VitePress auto-expands the one containing the current page. The navbar branch is left untouched. Verified: generated .vitepress/config.mts now has `collapsed: true` on all 8 groups; full docs build clean. Co-Authored-By: Claude Sonnet 5 --- docs/make.jl | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/docs/make.jl b/docs/make.jl index d9bb0dff8..acb7e3982 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -50,6 +50,26 @@ using Plots # "Plot image format — SVG vs PNG". Base.showable(::MIME"image/png", ::Plots.Plot) = 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 +# whole navigation tree renders fully expanded and there is no `MarkdownVitepress` option +# to change it. Override that one method to emit `collapsed: true` for the sidebar: each +# group starts folded, and VitePress still auto-expands the group containing the current +# page. The navbar branch (`sidenav === Val(:navbar)`) is left untouched. +@eval DocumenterVitepress function pagelist2str( + doc, name_contents::Pair{<:AbstractString,<:AbstractArray}, sidenav::Val +) + name, contents = name_contents + rendered_contents = String[] + for content in contents + str = pagelist2str(doc, content, sidenav) + isempty(str) || push!(rendered_contents, "{" * str * "}") + end + final_contents = join(rendered_contents, ",\n") + collapse = sidenav === Val(:sidebar) ? "collapsed: true," : "" + return "text: '$(replace(name, "'" => "\\'"))', $collapse items: [\n$(final_contents)\n]" +end + # function _ext(pkg, sym) m = Base.get_extension(pkg, sym)