Skip to content

Commit

Permalink
rc docs: hack Documenter to insert rc docs in the version selector.
Browse files Browse the repository at this point in the history
  • Loading branch information
fredrikekre committed Jul 30, 2020
1 parent 50c4e67 commit cd4330d
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion doc/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -233,11 +233,33 @@ end

const devurl = "v$(VERSION.major).$(VERSION.minor)-dev"

# Hack to make rc docs visible in the version selector
struct Versions versions end
function Documenter.Writers.HTMLWriter.expand_versions(dir::String, v::Versions)
# Find all available docs
available_folders = readdir(dir)
cd(() -> filter!(!islink, available_folders), dir)
filter!(x -> occursin(Base.VERSION_REGEX, x), available_folders)

# Look for docs for an "active" release candidate and insert it
vnums = [VersionNumber(x) for x in available_folders]
master_version = maximum(vnums)
filter!(x -> x.major == 1 && x.minor == master_version.minor-1, vnums)
rc = maximum(vnums)
if !isempty(rc.prerelease) && occursin(r"^rc", rc.prerelease[1])
src = "v$(rc)"
@assert src available_folders
push!(v.versions, src => src, pop!(v.versions))
end

return Documenter.Writers.HTMLWriter.expand_versions(dir, v.versions)
end

deploydocs(
repo = "github.com/JuliaLang/docs.julialang.org.git",
deploy_config = BuildBotConfig(),
target = joinpath(buildroot, "doc", "_build", "html", "en"),
dirname = "en",
devurl = devurl,
versions = ["v#.#", devurl => devurl]
versions = Versions(["v#.#", devurl => devurl]),
)

0 comments on commit cd4330d

Please sign in to comment.