Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: change the canonical url to v1 instead of stable. #28792

Merged
merged 2 commits into from
Aug 23, 2018

Conversation

fredrikekre
Copy link
Member

Ref #26825

Should not be merged until we have made some changes to the gh-pages branch.

cc @mortenpi

@fredrikekre fredrikekre added docs This change adds or pertains to documentation backport pending 1.0 labels Aug 21, 2018
@KristofferC KristofferC mentioned this pull request Aug 21, 2018
@mortenpi
Copy link
Contributor

mortenpi commented Aug 22, 2018

Could you add the following to make.jl? This should ensure that the master generates the correct version selector.

# 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 for
# the first line in the first for loop, which now include "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 = []
    release_folders = []
    tag_folders = []
    for each in readdir(dir)
        each in ("v1", "latest")             ? push!(named_folders,   each) :
        occursin(r"release\-\d+\.\d+", each) ? push!(release_folders, each) :
        occursin(Base.VERSION_REGEX, each)   ? push!(tag_folders,     each) : nothing
    end
    # put stable before latest
    sort!(named_folders, rev = true)
    # sort tags by version number
    sort!(tag_folders, lt = (x, y) -> VersionNumber(x) < VersionNumber(y), rev = true)
    # sort release- folders by version number
    vnum(x) = VersionNumber(match(r"release\-(\d+\.\d+)", x)[1])
    sort!(release_folders, lt = (x, y) -> vnum(x) < vnum(y), rev = true)
    open(joinpath(dir, "versions.js"), "w") do buf
        println(buf, "var DOC_VERSIONS = [")
        for group in (named_folders, release_folders, tag_folders)
            for folder in group
                println(buf, "  \"", folder, "\",")
            end
        end
        println(buf, "];")
    end
end

@mortenpi
Copy link
Contributor

If we want, we could actually change the latest right away as well..

Co-authored-by: Morten Piibeleht <morten.piibeleht@gmail.com>
Co-authored-by: Fredrik Ekre <fredrik.ekre@chalmers.se>
@mortenpi
Copy link
Contributor

LGTM

@fredrikekre fredrikekre changed the title [don't merge] doc: change the canonical url to v1 instead of stable. doc: change the canonical url to v1 instead of stable. Aug 22, 2018
@fredrikekre fredrikekre merged commit f9f3c4f into master Aug 23, 2018
@fredrikekre fredrikekre deleted the fe/canonical-v1 branch August 23, 2018 05:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs This change adds or pertains to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants