Skip to content

Commit f9f3c4f

Browse files
fredrikekremortenpi
andcommitted
Patch Documenter v0.19.6 to create a correct version selector
Co-authored-by: Morten Piibeleht <[email protected]> Co-authored-by: Fredrik Ekre <[email protected]>
1 parent c366143 commit f9f3c4f

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

doc/make.jl

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,36 @@ makedocs(
166166
assets = ["assets/julia-manual.css", ]
167167
)
168168

169+
# This overloads the function in Documenter that generates versions.js, to include
170+
# v1/ in the version selector, instead of stable/.
171+
#
172+
# The function is identical to the version found in Documenter v0.19.6, except that
173+
# it includes "v1" instead of "stable".
174+
#
175+
# Original:
176+
# https://github.com/JuliaDocs/Documenter.jl/blob/v0.19.6/src/Writers/HTMLWriter.jl#L481-L506
177+
#
178+
import Documenter.Writers.HTMLWriter: generate_version_file
179+
function generate_version_file(dir::AbstractString)
180+
named_folders = ["v1", "latest"]
181+
tag_folders = []
182+
for each in readdir(dir)
183+
each == "v1" && continue # skip the v1 symlink
184+
occursin(Base.VERSION_REGEX, each) && push!(tag_folders, each)
185+
end
186+
# sort tags by version number
187+
sort!(tag_folders, lt = (x, y) -> VersionNumber(x) < VersionNumber(y), rev = true)
188+
open(joinpath(dir, "versions.js"), "w") do buf
189+
println(buf, "var DOC_VERSIONS = [")
190+
for group in (named_folders, tag_folders)
191+
for folder in group
192+
println(buf, " \"", folder, "\",")
193+
end
194+
end
195+
println(buf, "];")
196+
end
197+
end
198+
169199
# Only deploy docs from 64bit Linux to avoid committing multiple versions of the same
170200
# docs from different workers.
171201
if "deploy" in ARGS && Sys.ARCH === :x86_64 && Sys.KERNEL === :Linux

0 commit comments

Comments
 (0)