From 85f3ea537ea77bca8c9bc6ca8a7044fc694ab497 Mon Sep 17 00:00:00 2001 From: Sebastian Pfitzner Date: Wed, 19 May 2021 13:42:23 +0200 Subject: [PATCH 01/13] retrocatively generate warning for outdated docs --- Project.toml | 4 + src/DocumenterTools.jl | 1 + src/OutdatedWarning.jl | 173 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 178 insertions(+) create mode 100644 src/OutdatedWarning.jl diff --git a/Project.toml b/Project.toml index 19a97da..ad9e28d 100644 --- a/Project.toml +++ b/Project.toml @@ -3,16 +3,20 @@ uuid = "35a29f4d-8980-5a13-9543-d66fff28ecb8" version = "0.1.10" [deps] +AbstractTrees = "1520ce14-60c1-5f80-bbc7-55ef81b5835c" Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae" Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" FileWatching = "7b1f6079-737a-58dc-b8bc-7a2ca5c1b5ee" +Gumbo = "708ec375-b3d6-5a57-a7ce-8257bf98657a" LibGit2 = "76f85450-5226-5b5a-8eaa-529ad045b433" Sass = "322a6be2-4ae8-5d68-aaf1-3e960788d1d9" [compat] +AbstractTrees = "0.8" DocStringExtensions = "0.7, 0.8" Documenter = "0.20, 0.21, 0.22, 0.23, 0.24, 0.25, 0.26" +Gumbo = "0.3" Sass = "0.1, 0.2" julia = "1" diff --git a/src/DocumenterTools.jl b/src/DocumenterTools.jl index 9b48950..c7d7c77 100644 --- a/src/DocumenterTools.jl +++ b/src/DocumenterTools.jl @@ -177,5 +177,6 @@ end include("genkeys.jl") include("Generator.jl") include("Themes.jl") +include("OutdatedWarning.jl") end # module diff --git a/src/OutdatedWarning.jl b/src/OutdatedWarning.jl new file mode 100644 index 0000000..ef5c66d --- /dev/null +++ b/src/OutdatedWarning.jl @@ -0,0 +1,173 @@ +module OutdatedWarning + +using Gumbo, AbstractTrees + +OLD_VERSION_CSS = replace(""" +.outdated-warning-overlay { + position: fixed; + width: 100%; + top: 0; + left: 0; + box-shadow: 0 0 10px rgba(0, 0, 0, 0.3); + z-index: 999; + background-color: #ffaba7; + color: rgba(0, 0, 0, 0.7); + border-bottom: 3px solid #da0b00; + padding: 10px 35px; + text-align: center; + font-size: 15px; } + .outdated-warning-overlay .outdated-warning-closer { + position: absolute; + top: calc(50% - 10px); + right: 18px; + cursor: pointer; + width: 12px; } + .outdated-warning-overlay a { + color: #2e63b8; } + .outdated-warning-overlay a:hover { + color: #363636; } +""", '\n' => "") + +OLD_VERSION_SCRIPT_ATTR = "data-is-old-version" +OLD_VERSION_WARNER = """ +function maybeAddWarning () { + const head = document.getElementsByTagName('head')[0]; + + // Add a noindex meta tag (unless one exists) so that search engines don't index this version of the docs. + if (document.body.querySelector('meta[name="robots"]') === null) { + const meta = document.createElement('meta'); + meta.name = 'robots'; + meta.content = 'noindex'; + + head.appendChild(meta); + }; + + // Add a stylesheet to avoid inline styling + const style = document.createElement('style'); + style.type = 'text/css'; + style.appendChild(document.createTextNode('$(OLD_VERSION_CSS)')); + head.appendChild(style); + + const div = document.createElement('div'); + div.classList.add('outdated-warning-overlay'); + const closer = document.createElement('div'); + closer.classList.add('outdated-warning-closer'); + + // Icon by font-awesome (license: https://fontawesome.com/license, link: https://fontawesome.com/icons/times?style=solid) + closer.innerHTML = ''; + closer.addEventListener('click', function () { + document.body.removeChild(div); + }); + let href = '/stable'; + if (window.documenterBaseURL) { + href = window.documenterBaseURL + '/../stable'; + } + div.innerHTML = 'This is an old version of the documentation.
Go to the newest version.'; + div.appendChild(closer); + document.body.appendChild(div); +}; + +if (document.readyState === 'loading') { + document.addEventListener('DOMContentLoaded', maybeAddWarning); +} else { + maybeAddWarning(); +}; +""" + +function add_old_docs_notice(index, force = false) + html = read(index, String) + parsed = Gumbo.parsehtml(html) + + for el in PreOrderDFS(parsed.root) + if el isa HTMLElement && Gumbo.tag(el) == :head + old_notice = get_notice(el) + + if old_notice === nothing + push!(el.children, make_notice(el)) + elseif force + update_notice(old_notice) + end + + break + end + end + + open(string(index), "w") do io + print(io, parsed) + end +end + +function make_notice(parent) + script = Gumbo.HTMLElement{:script}([], parent, Dict(OLD_VERSION_SCRIPT_ATTR => "")) + content = Gumbo.HTMLText(script, OLD_VERSION_WARNER) + push!(script.children, content) + return script +end + +function update_notice(script) + content = Gumbo.HTMLText(script, OLD_VERSION_WARNER) + empty!(script.children) + push!(script.children, content) + return script +end + +function get_notice(html) + for el in PreOrderDFS(html) + if el isa HTMLElement && Gumbo.tag(el) == :script + attrs = Gumbo.attrs(el) + if haskey(attrs, OLD_VERSION_SCRIPT_ATTR) + return el + end + end + end + return nothing +end + +""" + generate([io::IO = stdout,] root::String; latest = "stable", force = false) + +This function adds a warning (and `noindex` meta tag) to all versions of +the documentation in `root` except for `latest`. + +`force` overwrites a previous injected warning message created by this function. + +A typical use case is to run this on the `gh-pages` branch of a packge. +""" +generate(root::String; kwargs...) = generate(stdout, root; kwargs...) +function generate(io::IO, root::String; latest = "stable", force = false) + latest = joinpath(root, latest) + while islink(latest) + latest = joinpath(root, readlink(latest)) + end + + for dir in readdir(root) + path = joinpath(root, dir) + islink(path) && continue + isdir(path) || continue + index = joinpath(path, "index.html") + isfile(index) || continue + + if endswith(path, "dev") + println(io, "Skipping $(dir) since it's a dev version.") + continue + end + + if path == latest + println(io, "Skipping $(dir) since it's the latest version.") + else + print(io, "Processing $(dir): ") + for (root, _, files) in walkdir(path) + for file in files + _, ext = splitext(file) + if ext == ".html" + print(io, ".") + add_old_docs_notice(joinpath(root, file), force) + end + end + end + println(io) + end + end +end + +end From 913c2fafa3b0bdcac9f8e1a25bd822edb9a4c64a Mon Sep 17 00:00:00 2001 From: Sebastian Pfitzner Date: Wed, 19 May 2021 13:50:49 +0200 Subject: [PATCH 02/13] fix version mixup --- Project.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Project.toml b/Project.toml index ad9e28d..ce78755 100644 --- a/Project.toml +++ b/Project.toml @@ -13,10 +13,10 @@ LibGit2 = "76f85450-5226-5b5a-8eaa-529ad045b433" Sass = "322a6be2-4ae8-5d68-aaf1-3e960788d1d9" [compat] -AbstractTrees = "0.8" +AbstractTrees = "0.3" DocStringExtensions = "0.7, 0.8" Documenter = "0.20, 0.21, 0.22, 0.23, 0.24, 0.25, 0.26" -Gumbo = "0.3" +Gumbo = "0.8" Sass = "0.1, 0.2" julia = "1" From 229c482fa0979501bee9b0dae0fc24ed155e41e5 Mon Sep 17 00:00:00 2001 From: Sebastian Pfitzner Date: Wed, 19 May 2021 13:58:01 +0200 Subject: [PATCH 03/13] allow Gumbo@0.7 --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index ce78755..9ccca40 100644 --- a/Project.toml +++ b/Project.toml @@ -16,7 +16,7 @@ Sass = "322a6be2-4ae8-5d68-aaf1-3e960788d1d9" AbstractTrees = "0.3" DocStringExtensions = "0.7, 0.8" Documenter = "0.20, 0.21, 0.22, 0.23, 0.24, 0.25, 0.26" -Gumbo = "0.8" +Gumbo = "0.7, 0.8" Sass = "0.1, 0.2" julia = "1" From d00cf105cae4d9608bdfd630a9dd293fb5f2edde Mon Sep 17 00:00:00 2001 From: Sebastian Pfitzner Date: Wed, 19 May 2021 14:17:18 +0200 Subject: [PATCH 04/13] use documenter data attr if possible --- src/OutdatedWarning.jl | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/OutdatedWarning.jl b/src/OutdatedWarning.jl index ef5c66d..fdadf7e 100644 --- a/src/OutdatedWarning.jl +++ b/src/OutdatedWarning.jl @@ -1,6 +1,6 @@ module OutdatedWarning -using Gumbo, AbstractTrees +using Gumbo, AbstractTrees, Documenter OLD_VERSION_CSS = replace(""" .outdated-warning-overlay { @@ -28,7 +28,9 @@ OLD_VERSION_CSS = replace(""" color: #363636; } """, '\n' => "") -OLD_VERSION_SCRIPT_ATTR = "data-is-old-version" +OUTDATED_VERSION_ATTR = isdefined(Documenter.Writers.HTMLWriter, :OUTDATED_VERSION_ATTR) ? + Documenter.Writers.HTMLWriter.OUTDATED_VERSION_ATTR : "data-outdated-warner" + OLD_VERSION_WARNER = """ function maybeAddWarning () { const head = document.getElementsByTagName('head')[0]; @@ -98,7 +100,7 @@ function add_old_docs_notice(index, force = false) end function make_notice(parent) - script = Gumbo.HTMLElement{:script}([], parent, Dict(OLD_VERSION_SCRIPT_ATTR => "")) + script = Gumbo.HTMLElement{:script}([], parent, Dict(OUTDATED_VERSION_ATTR => "")) content = Gumbo.HTMLText(script, OLD_VERSION_WARNER) push!(script.children, content) return script @@ -115,7 +117,7 @@ function get_notice(html) for el in PreOrderDFS(html) if el isa HTMLElement && Gumbo.tag(el) == :script attrs = Gumbo.attrs(el) - if haskey(attrs, OLD_VERSION_SCRIPT_ATTR) + if haskey(attrs, OUTDATED_VERSION_ATTR) return el end end From 9d92345cb906d4d6bfacb5231cb2e040beba78c0 Mon Sep 17 00:00:00 2001 From: Sebastian Pfitzner Date: Wed, 19 May 2021 14:20:01 +0200 Subject: [PATCH 05/13] adjust style --- src/OutdatedWarning.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OutdatedWarning.jl b/src/OutdatedWarning.jl index fdadf7e..633a419 100644 --- a/src/OutdatedWarning.jl +++ b/src/OutdatedWarning.jl @@ -5,9 +5,9 @@ using Gumbo, AbstractTrees, Documenter OLD_VERSION_CSS = replace(""" .outdated-warning-overlay { position: fixed; - width: 100%; top: 0; left: 0; + right: 0; box-shadow: 0 0 10px rgba(0, 0, 0, 0.3); z-index: 999; background-color: #ffaba7; From 3742ec6f93dc26c9ffad8422632bc7d082867808 Mon Sep 17 00:00:00 2001 From: Sebastian Pfitzner Date: Thu, 27 May 2021 11:22:27 +0200 Subject: [PATCH 06/13] tests, export, no latest skip --- src/OutdatedWarning.jl | 47 +++++++++++++----------- test/fixtures/.gitignore | 2 + test/fixtures/index.html | 7 ++++ test/fixtures/index_after.html | 46 +++++++++++++++++++++++ test/fixtures/post/latest | 1 + test/fixtures/post/v0.5.0/foo/index.html | 46 +++++++++++++++++++++++ test/fixtures/post/v0.5.0/index.html | 46 +++++++++++++++++++++++ test/fixtures/post/v1.0.0/bar/index.html | 46 +++++++++++++++++++++++ test/fixtures/post/v1.0.0/index.html | 9 +++++ test/fixtures/pre/latest | 1 + test/fixtures/pre/v0.5.0/foo/index.html | 7 ++++ test/fixtures/pre/v0.5.0/index.html | 7 ++++ test/fixtures/pre/v1.0.0/bar/index.html | 7 ++++ test/fixtures/pre/v1.0.0/index.html | 9 +++++ test/outdated.jl | 25 +++++++++++++ test/runtests.jl | 4 +- 16 files changed, 287 insertions(+), 23 deletions(-) create mode 100644 test/fixtures/.gitignore create mode 100644 test/fixtures/index.html create mode 100644 test/fixtures/index_after.html create mode 120000 test/fixtures/post/latest create mode 100644 test/fixtures/post/v0.5.0/foo/index.html create mode 100644 test/fixtures/post/v0.5.0/index.html create mode 100644 test/fixtures/post/v1.0.0/bar/index.html create mode 100644 test/fixtures/post/v1.0.0/index.html create mode 120000 test/fixtures/pre/latest create mode 100644 test/fixtures/pre/v0.5.0/foo/index.html create mode 100644 test/fixtures/pre/v0.5.0/index.html create mode 100644 test/fixtures/pre/v1.0.0/bar/index.html create mode 100644 test/fixtures/pre/v1.0.0/index.html create mode 100644 test/outdated.jl diff --git a/src/OutdatedWarning.jl b/src/OutdatedWarning.jl index 633a419..f0e7728 100644 --- a/src/OutdatedWarning.jl +++ b/src/OutdatedWarning.jl @@ -1,5 +1,6 @@ -module OutdatedWarning +export OutdatedWarning +module OutdatedWarning using Gumbo, AbstractTrees, Documenter OLD_VERSION_CSS = replace(""" @@ -80,23 +81,29 @@ function add_old_docs_notice(index, force = false) html = read(index, String) parsed = Gumbo.parsehtml(html) + did_update = false for el in PreOrderDFS(parsed.root) if el isa HTMLElement && Gumbo.tag(el) == :head old_notice = get_notice(el) if old_notice === nothing push!(el.children, make_notice(el)) + did_update = true elseif force update_notice(old_notice) + did_update = true end break end end - open(string(index), "w") do io - print(io, parsed) + if did_update + open(index, "w") do io + print(io, parsed) + end end + return did_update end function make_notice(parent) @@ -126,22 +133,17 @@ function get_notice(html) end """ - generate([io::IO = stdout,] root::String; latest = "stable", force = false) + generate([io::IO = stdout,] root::String;force = false) This function adds a warning (and `noindex` meta tag) to all versions of -the documentation in `root` except for `latest`. +the documentation in `root`. `force` overwrites a previous injected warning message created by this function. A typical use case is to run this on the `gh-pages` branch of a packge. """ generate(root::String; kwargs...) = generate(stdout, root; kwargs...) -function generate(io::IO, root::String; latest = "stable", force = false) - latest = joinpath(root, latest) - while islink(latest) - latest = joinpath(root, readlink(latest)) - end - +function generate(io::IO, root::String;force = false) for dir in readdir(root) path = joinpath(root, dir) islink(path) && continue @@ -154,21 +156,22 @@ function generate(io::IO, root::String; latest = "stable", force = false) continue end - if path == latest - println(io, "Skipping $(dir) since it's the latest version.") - else - print(io, "Processing $(dir): ") - for (root, _, files) in walkdir(path) - for file in files - _, ext = splitext(file) - if ext == ".html" - print(io, ".") - add_old_docs_notice(joinpath(root, file), force) + print(io, "Processing $(dir): ") + for (root, _, files) in walkdir(path) + for file in files + _, ext = splitext(file) + if ext == ".html" + try + did_change = add_old_docs_notice(joinpath(root, file), force) + print(io, did_change ? "." : " ") + catch err + @debug "Fatally failed to add a outdated warning" exception = (err, catch_backtrace()) + print(io, "!") end end end - println(io) end + println(io) end end diff --git a/test/fixtures/.gitignore b/test/fixtures/.gitignore new file mode 100644 index 0000000..91968ba --- /dev/null +++ b/test/fixtures/.gitignore @@ -0,0 +1,2 @@ +index_changed.html +transient \ No newline at end of file diff --git a/test/fixtures/index.html b/test/fixtures/index.html new file mode 100644 index 0000000..130f984 --- /dev/null +++ b/test/fixtures/index.html @@ -0,0 +1,7 @@ + + + + + nothing much in here + + \ No newline at end of file diff --git a/test/fixtures/index_after.html b/test/fixtures/index_after.html new file mode 100644 index 0000000..80f657c --- /dev/null +++ b/test/fixtures/index_after.html @@ -0,0 +1,46 @@ + + nothing much in here + + \ No newline at end of file diff --git a/test/fixtures/post/latest b/test/fixtures/post/latest new file mode 120000 index 0000000..60453e6 --- /dev/null +++ b/test/fixtures/post/latest @@ -0,0 +1 @@ +v1.0.0 \ No newline at end of file diff --git a/test/fixtures/post/v0.5.0/foo/index.html b/test/fixtures/post/v0.5.0/foo/index.html new file mode 100644 index 0000000..80f657c --- /dev/null +++ b/test/fixtures/post/v0.5.0/foo/index.html @@ -0,0 +1,46 @@ + + nothing much in here + + \ No newline at end of file diff --git a/test/fixtures/post/v0.5.0/index.html b/test/fixtures/post/v0.5.0/index.html new file mode 100644 index 0000000..80f657c --- /dev/null +++ b/test/fixtures/post/v0.5.0/index.html @@ -0,0 +1,46 @@ + + nothing much in here + + \ No newline at end of file diff --git a/test/fixtures/post/v1.0.0/bar/index.html b/test/fixtures/post/v1.0.0/bar/index.html new file mode 100644 index 0000000..80f657c --- /dev/null +++ b/test/fixtures/post/v1.0.0/bar/index.html @@ -0,0 +1,46 @@ + + nothing much in here + + \ No newline at end of file diff --git a/test/fixtures/post/v1.0.0/index.html b/test/fixtures/post/v1.0.0/index.html new file mode 100644 index 0000000..4942e74 --- /dev/null +++ b/test/fixtures/post/v1.0.0/index.html @@ -0,0 +1,9 @@ + + + + + + + nothing much in here + + \ No newline at end of file diff --git a/test/fixtures/pre/latest b/test/fixtures/pre/latest new file mode 120000 index 0000000..60453e6 --- /dev/null +++ b/test/fixtures/pre/latest @@ -0,0 +1 @@ +v1.0.0 \ No newline at end of file diff --git a/test/fixtures/pre/v0.5.0/foo/index.html b/test/fixtures/pre/v0.5.0/foo/index.html new file mode 100644 index 0000000..130f984 --- /dev/null +++ b/test/fixtures/pre/v0.5.0/foo/index.html @@ -0,0 +1,7 @@ + + + + + nothing much in here + + \ No newline at end of file diff --git a/test/fixtures/pre/v0.5.0/index.html b/test/fixtures/pre/v0.5.0/index.html new file mode 100644 index 0000000..130f984 --- /dev/null +++ b/test/fixtures/pre/v0.5.0/index.html @@ -0,0 +1,7 @@ + + + + + nothing much in here + + \ No newline at end of file diff --git a/test/fixtures/pre/v1.0.0/bar/index.html b/test/fixtures/pre/v1.0.0/bar/index.html new file mode 100644 index 0000000..130f984 --- /dev/null +++ b/test/fixtures/pre/v1.0.0/bar/index.html @@ -0,0 +1,7 @@ + + + + + nothing much in here + + \ No newline at end of file diff --git a/test/fixtures/pre/v1.0.0/index.html b/test/fixtures/pre/v1.0.0/index.html new file mode 100644 index 0000000..4942e74 --- /dev/null +++ b/test/fixtures/pre/v1.0.0/index.html @@ -0,0 +1,9 @@ + + + + + + + nothing much in here + + \ No newline at end of file diff --git a/test/outdated.jl b/test/outdated.jl new file mode 100644 index 0000000..d681353 --- /dev/null +++ b/test/outdated.jl @@ -0,0 +1,25 @@ + +index_changed = joinpath(@__DIR__, "fixtures", "index_changed.html") +cp(joinpath(@__DIR__, "fixtures", "index.html"), index_changed, force=true) +OutdatedWarning.add_old_docs_notice(index_changed) +output = read(index_changed, String) +rm(index_changed) + +@test occursin("data-outdated-warner", output) +# The following is sensitive to how Gumbo.jl writes HTML, but let's hope that doesn't change often: +@test output == read(joinpath(@__DIR__, "fixtures", "index_after.html"), String) + + +transient_path = joinpath(@__DIR__, "fixtures", "transient") +cp(joinpath(@__DIR__, "fixtures", "pre"), transient_path, force=true) +OutdatedWarning.generate(transient_path) + +for (root, _, files) in walkdir(transient_path) + for file in files + content = read(joinpath(root, file), String) + expected = read(joinpath(replace(root, "transient" => "post"), file), String) + @test content == expected + end +end + +rm(transient_path, recursive=true) \ No newline at end of file diff --git a/test/runtests.jl b/test/runtests.jl index 48ee826..099cc4f 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -18,5 +18,7 @@ using DocumenterTools DocumenterTools.genkeys(DocumenterMarkdown) end - + @testset "outdated warnings" begin + include("outdated.jl") + end end From a045ec61a164db51342a283126be7645c16111fb Mon Sep 17 00:00:00 2001 From: Sebastian Pfitzner Date: Thu, 27 May 2021 11:49:25 +0200 Subject: [PATCH 07/13] fix CI? --- src/OutdatedWarning.jl | 5 ++++- test/outdated.jl | 6 +++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/OutdatedWarning.jl b/src/OutdatedWarning.jl index f0e7728..6d9a0df 100644 --- a/src/OutdatedWarning.jl +++ b/src/OutdatedWarning.jl @@ -163,8 +163,11 @@ function generate(io::IO, root::String;force = false) if ext == ".html" try did_change = add_old_docs_notice(joinpath(root, file), force) - print(io, did_change ? "." : " ") + print(io, did_change ? "✓" : ".") catch err + if err isa InterruptException + rethrow() + end @debug "Fatally failed to add a outdated warning" exception = (err, catch_backtrace()) print(io, "!") end diff --git a/test/outdated.jl b/test/outdated.jl index d681353..4253047 100644 --- a/test/outdated.jl +++ b/test/outdated.jl @@ -1,20 +1,20 @@ - index_changed = joinpath(@__DIR__, "fixtures", "index_changed.html") cp(joinpath(@__DIR__, "fixtures", "index.html"), index_changed, force=true) OutdatedWarning.add_old_docs_notice(index_changed) output = read(index_changed, String) -rm(index_changed) @test occursin("data-outdated-warner", output) # The following is sensitive to how Gumbo.jl writes HTML, but let's hope that doesn't change often: @test output == read(joinpath(@__DIR__, "fixtures", "index_after.html"), String) +rm(index_changed) + transient_path = joinpath(@__DIR__, "fixtures", "transient") cp(joinpath(@__DIR__, "fixtures", "pre"), transient_path, force=true) OutdatedWarning.generate(transient_path) -for (root, _, files) in walkdir(transient_path) +for (root, _, files) in walkdir(transient_path, follow_symlinks=true) for file in files content = read(joinpath(root, file), String) expected = read(joinpath(replace(root, "transient" => "post"), file), String) From 314a0614ad6574b3022333051b1d7596f4a7be79 Mon Sep 17 00:00:00 2001 From: Sebastian Pfitzner Date: Thu, 27 May 2021 11:55:06 +0200 Subject: [PATCH 08/13] fix tests? --- test/outdated.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/outdated.jl b/test/outdated.jl index 4253047..b6dd911 100644 --- a/test/outdated.jl +++ b/test/outdated.jl @@ -5,7 +5,7 @@ output = read(index_changed, String) @test occursin("data-outdated-warner", output) # The following is sensitive to how Gumbo.jl writes HTML, but let's hope that doesn't change often: -@test output == read(joinpath(@__DIR__, "fixtures", "index_after.html"), String) +@test replace(output, "\r\n" => "\n") == read(joinpath(@__DIR__, "fixtures", "index_after.html"), String) rm(index_changed) @@ -14,11 +14,11 @@ transient_path = joinpath(@__DIR__, "fixtures", "transient") cp(joinpath(@__DIR__, "fixtures", "pre"), transient_path, force=true) OutdatedWarning.generate(transient_path) -for (root, _, files) in walkdir(transient_path, follow_symlinks=true) +for (root, _, files) in walkdir(transient_path, onerror=identity) for file in files content = read(joinpath(root, file), String) expected = read(joinpath(replace(root, "transient" => "post"), file), String) - @test content == expected + @test replace(content, "\r\n" => "\n") == expected end end From 10a6846ad6f0cc1e27456f36ebb66948a9fbb674 Mon Sep 17 00:00:00 2001 From: Sebastian Pfitzner Date: Thu, 27 May 2021 12:00:05 +0200 Subject: [PATCH 09/13] rm symlink --- test/fixtures/post/latest | 1 - test/fixtures/pre/latest | 1 - test/outdated.jl | 2 +- 3 files changed, 1 insertion(+), 3 deletions(-) delete mode 120000 test/fixtures/post/latest delete mode 120000 test/fixtures/pre/latest diff --git a/test/fixtures/post/latest b/test/fixtures/post/latest deleted file mode 120000 index 60453e6..0000000 --- a/test/fixtures/post/latest +++ /dev/null @@ -1 +0,0 @@ -v1.0.0 \ No newline at end of file diff --git a/test/fixtures/pre/latest b/test/fixtures/pre/latest deleted file mode 120000 index 60453e6..0000000 --- a/test/fixtures/pre/latest +++ /dev/null @@ -1 +0,0 @@ -v1.0.0 \ No newline at end of file diff --git a/test/outdated.jl b/test/outdated.jl index b6dd911..2f50921 100644 --- a/test/outdated.jl +++ b/test/outdated.jl @@ -14,7 +14,7 @@ transient_path = joinpath(@__DIR__, "fixtures", "transient") cp(joinpath(@__DIR__, "fixtures", "pre"), transient_path, force=true) OutdatedWarning.generate(transient_path) -for (root, _, files) in walkdir(transient_path, onerror=identity) +for (root, _, files) in walkdir(transient_path) for file in files content = read(joinpath(root, file), String) expected = read(joinpath(replace(root, "transient" => "post"), file), String) From 8904c983c58e6caab37c268014d1629a981b791b Mon Sep 17 00:00:00 2001 From: Sebastian Pfitzner Date: Thu, 27 May 2021 12:09:52 +0200 Subject: [PATCH 10/13] normalize line endings in tests --- test/outdated.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/outdated.jl b/test/outdated.jl index 2f50921..12d2cd0 100644 --- a/test/outdated.jl +++ b/test/outdated.jl @@ -5,7 +5,7 @@ output = read(index_changed, String) @test occursin("data-outdated-warner", output) # The following is sensitive to how Gumbo.jl writes HTML, but let's hope that doesn't change often: -@test replace(output, "\r\n" => "\n") == read(joinpath(@__DIR__, "fixtures", "index_after.html"), String) +@test replace(output, "\r\n" => "\n") == replace(read(joinpath(@__DIR__, "fixtures", "index_after.html"), String), "\r\n" => "\n") rm(index_changed) @@ -18,7 +18,7 @@ for (root, _, files) in walkdir(transient_path) for file in files content = read(joinpath(root, file), String) expected = read(joinpath(replace(root, "transient" => "post"), file), String) - @test replace(content, "\r\n" => "\n") == expected + @test replace(content, "\r\n" => "\n") == replace(expected, "\r\n" => "\n") end end From 290682ddbc0fa4bc410dd1b945303684dac06248 Mon Sep 17 00:00:00 2001 From: Morten Piibeleht Date: Sun, 6 Jun 2021 12:03:37 +1200 Subject: [PATCH 11/13] Update CHANGELOG.md --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4eec504..3a0949e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # DocumenterTools.jl changelog +## Version `v0.1.11` + +* DocumenterTools now provides the `OutdatedWarning.generate` which can be used to add outdated version warning boxed to old documentation builds (on `gh-pages`). ([#51][github-51]) + ## Version `v0.1.10` * Declare compatibility with Sass.jl 0.2. ([#49][github-49]) @@ -60,6 +64,7 @@ Maintenance release declaring compatibility with Documenter 0.25. ([#39][github- [github-44]: https://github.com/JuliaDocs/DocumenterTools.jl/pull/44 [github-46]: https://github.com/JuliaDocs/DocumenterTools.jl/pull/46 [github-49]: https://github.com/JuliaDocs/DocumenterTools.jl/pull/49 +[github-51]: https://github.com/JuliaDocs/DocumenterTools.jl/pull/51 [badge-breaking]: https://img.shields.io/badge/BREAKING-red.svg From ae879242f739c569591ba6980f0fe89335d66b62 Mon Sep 17 00:00:00 2001 From: Morten Piibeleht Date: Sun, 6 Jun 2021 12:05:12 +1200 Subject: [PATCH 12/13] Set version to 0.1.11 --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 9ccca40..6197744 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "DocumenterTools" uuid = "35a29f4d-8980-5a13-9543-d66fff28ecb8" -version = "0.1.10" +version = "0.1.11" [deps] AbstractTrees = "1520ce14-60c1-5f80-bbc7-55ef81b5835c" From f0c73497ea3eed19f44c1d346e5a077a9aa7a243 Mon Sep 17 00:00:00 2001 From: Morten Piibeleht Date: Sun, 6 Jun 2021 12:14:20 +1200 Subject: [PATCH 13/13] Fix typos --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3a0949e..6878d7c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## Version `v0.1.11` -* DocumenterTools now provides the `OutdatedWarning.generate` which can be used to add outdated version warning boxed to old documentation builds (on `gh-pages`). ([#51][github-51]) +* DocumenterTools now provides the `OutdatedWarning.generate` function which can be used to add outdated version warnings to old documentation builds (on `gh-pages`). ([#51][github-51]) ## Version `v0.1.10`