Skip to content

Commit

Permalink
Patch Documenter v0.19.6 to create a correct version selector
Browse files Browse the repository at this point in the history
Co-authored-by: Morten Piibeleht <[email protected]>
Co-authored-by: Fredrik Ekre <[email protected]>
  • Loading branch information
fredrikekre and mortenpi committed Aug 23, 2018
1 parent c366143 commit f9f3c4f
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions doc/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,36 @@ makedocs(
assets = ["assets/julia-manual.css", ]
)

# This overloads the function in Documenter that generates versions.js, to include
# v1/ in the version selector, instead of stable/.
#
# The function is identical to the version found in Documenter v0.19.6, except that
# it includes "v1" instead of "stable".
#
# Original:
# https://github.com/JuliaDocs/Documenter.jl/blob/v0.19.6/src/Writers/HTMLWriter.jl#L481-L506
#
import Documenter.Writers.HTMLWriter: generate_version_file
function generate_version_file(dir::AbstractString)
named_folders = ["v1", "latest"]
tag_folders = []
for each in readdir(dir)
each == "v1" && continue # skip the v1 symlink
occursin(Base.VERSION_REGEX, each) && push!(tag_folders, each)
end
# sort tags by version number
sort!(tag_folders, lt = (x, y) -> VersionNumber(x) < VersionNumber(y), rev = true)
open(joinpath(dir, "versions.js"), "w") do buf
println(buf, "var DOC_VERSIONS = [")
for group in (named_folders, tag_folders)
for folder in group
println(buf, " \"", folder, "\",")
end
end
println(buf, "];")
end
end

# Only deploy docs from 64bit Linux to avoid committing multiple versions of the same
# docs from different workers.
if "deploy" in ARGS && Sys.ARCH === :x86_64 && Sys.KERNEL === :Linux
Expand Down

0 comments on commit f9f3c4f

Please sign in to comment.