From 60e61eed1ab8c81ee4eb869f447b9ad1c497054e Mon Sep 17 00:00:00 2001 From: Fredrik Ekre Date: Sun, 5 Jun 2022 13:48:50 +0200 Subject: [PATCH 1/2] Raise minimum required Julia version from 1.0 to 1.6, fixes #1835. --- .github/workflows/CI.yml | 1 - CHANGELOG.md | 3 ++ Project.toml | 2 +- src/DocTests.jl | 8 ++---- src/Expanders.jl | 8 ++---- src/Utilities/Utilities.jl | 45 ++++++++++++------------------ src/Writers/LaTeXWriter.jl | 6 +--- src/deployconfig.jl | 16 ++--------- test/TestUtilities.jl | 10 +------ test/doctests/doctests.jl | 17 +++--------- test/doctests/fix/tests.jl | 3 +- test/doctests/src/hardscope.md | 51 ---------------------------------- test/utilities.jl | 8 ++---- 13 files changed, 40 insertions(+), 138 deletions(-) delete mode 100644 test/doctests/src/hardscope.md diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index aaf4b2bde8..6365db23cc 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -14,7 +14,6 @@ jobs: fail-fast: false matrix: version: - - '1.0' - '1.6' - '1' - 'nightly' diff --git a/CHANGELOG.md b/CHANGELOG.md index c554177435..e5ebd94845 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## Version `v0.28.0` (unreleased) * ![Enhancement][badge-enhancement] The `ansicolor` keyword to `HTML()` now defaults to true, meaning that executed outputs from `@example`- and `@repl`-blocks are now by default colored (if they emit colored output). ([#1828][github-1828]) +* ![Maintenance][badge-maintenance] The (minimum) required Julia version has been raised from 1.0 to 1.6. For older Julia versions the 0.27.X release can still be used. ([#1835][github-1835], [#1841][github-1841]) ## Version `v0.27.19` @@ -1054,8 +1055,10 @@ [github-1829]: https://github.com/JuliaDocs/Documenter.jl/pull/1829 [github-1833]: https://github.com/JuliaDocs/Documenter.jl/pull/1833 [github-1834]: https://github.com/JuliaDocs/Documenter.jl/pull/1834 +[github-1835]: https://github.com/JuliaDocs/Documenter.jl/issues/1835 [github-1836]: https://github.com/JuliaDocs/Documenter.jl/pull/1836 [github-1838]: https://github.com/JuliaDocs/Documenter.jl/pull/1838 +[github-1841]: https://github.com/JuliaDocs/Documenter.jl/pull/1841 [julia-38079]: https://github.com/JuliaLang/julia/issues/38079 diff --git a/Project.toml b/Project.toml index a93235f60b..3b6de6d0f7 100644 --- a/Project.toml +++ b/Project.toml @@ -22,7 +22,7 @@ ANSIColoredPrinters = "0.0.1" DocStringExtensions = "0.4, 0.5, 0.6, 0.7, 0.8" IOCapture = "0.2" JSON = "0.19, 0.20, 0.21" -julia = "1" +julia = "1.6" [extras] DocumenterMarkdown = "997ab1e6-3595-5248-9280-8efb232c3433" diff --git a/src/DocTests.jl b/src/DocTests.jl index 5cf3412e43..2721adfaa8 100644 --- a/src/DocTests.jl +++ b/src/DocTests.jl @@ -236,11 +236,9 @@ function eval_repl(block, sandbox, meta::Dict, doc::Documents.Document, page) for (ex, str) in Utilities.parseblock(input, doc, page; keywords = false, raise=false) # Input containing a semi-colon gets suppressed in the final output. result.hide = REPL.ends_with_semicolon(str) - if VERSION >= v"1.5.0-DEV.178" - # Use the REPL softscope for REPL jldoctests, - # see https://github.com/JuliaLang/julia/pull/33864 - ex = REPL.softscope!(ex) - end + # Use the REPL softscope for REPL jldoctests, + # see https://github.com/JuliaLang/julia/pull/33864 + ex = REPL.softscope!(ex) c = IOCapture.capture(rethrow = InterruptException) do Core.eval(sandbox, ex) end diff --git a/src/Expanders.jl b/src/Expanders.jl index bd48d26d7d..cbb497fa7b 100644 --- a/src/Expanders.jl +++ b/src/Expanders.jl @@ -711,11 +711,9 @@ function Selectors.runner(::Type{REPLBlocks}, x, page, doc) for (ex, str) in Utilities.parseblock(x.code, doc, page; keywords = false, linenumbernode = linenumbernode) input = droplines(str) - if VERSION >= v"1.5.0-DEV.178" - # Use the REPL softscope for REPLBlocks, - # see https://github.com/JuliaLang/julia/pull/33864 - ex = REPL.softscope!(ex) - end + # Use the REPL softscope for REPLBlocks, + # see https://github.com/JuliaLang/julia/pull/33864 + ex = REPL.softscope!(ex) c = IOCapture.capture(rethrow = InterruptException, color = ansicolor) do cd(page.workdir) do Core.eval(mod, ex) diff --git a/src/Utilities/Utilities.jl b/src/Utilities/Utilities.jl index 579ea87569..0eb88bb9cf 100644 --- a/src/Utilities/Utilities.jl +++ b/src/Utilities/Utilities.jl @@ -150,26 +150,24 @@ function parseblock(code::AbstractString, doc, file; skip = 0, keywords = true, end cursor = ncursor end - if VERSION >= v"1.6.0" # required for Meta.parseall(...) - if linenumbernode isa LineNumberNode - exs = Meta.parseall(code; filename=linenumbernode.file).args - @assert length(exs) == 2 * length(results) - for (i, ex) in enumerate(Iterators.partition(exs, 2)) - @assert ex[1] isa LineNumberNode - expr = Expr(:toplevel, ex...) # LineNumberNode + expression - # in the REPL each evaluation is considered a new file, e.g. - # REPL[1], REPL[2], ..., so try to mimic that by incrementing - # the counter for each sub-expression in this code block - if linenumbernode.file === Symbol("REPL") - newfile = "REPL[$i]" - # to reset the line counter for each new "file" - lineshift = 1 - ex[1].line - update_linenumbernodes!(expr, newfile, lineshift) - else - update_linenumbernodes!(expr, linenumbernode.file, linenumbernode.line) - end - results[i] = (expr , results[i][2]) + if linenumbernode isa LineNumberNode + exs = Meta.parseall(code; filename=linenumbernode.file).args + @assert length(exs) == 2 * length(results) + for (i, ex) in enumerate(Iterators.partition(exs, 2)) + @assert ex[1] isa LineNumberNode + expr = Expr(:toplevel, ex...) # LineNumberNode + expression + # in the REPL each evaluation is considered a new file, e.g. + # REPL[1], REPL[2], ..., so try to mimic that by incrementing + # the counter for each sub-expression in this code block + if linenumbernode.file === Symbol("REPL") + newfile = "REPL[$i]" + # to reset the line counter for each new "file" + lineshift = 1 - ex[1].line + update_linenumbernodes!(expr, newfile, lineshift) + else + update_linenumbernodes!(expr, linenumbernode.file, linenumbernode.line) end + results[i] = (expr , results[i][2]) end end results @@ -798,14 +796,7 @@ function git_remote_head_branch(varname, root; remotename = "origin", fallback = cmd = `git remote show $(remotename)` stderr_output = IOBuffer() git_remote_output = try - # Older Julia versions don't support pipeline-ing into IOBuffer. - stderr_redirect = if VERSION >= v"1.6.0" - stderr_output - else - write(stderr_output, "(no output redirect on Julia $VERSION)") - devnull - end - read(pipeline(setenv(cmd, env; dir=root); stderr = stderr_redirect), String) + read(pipeline(setenv(cmd, env; dir=root); stderr = stderr_output), String) catch e @warn """ Unable to determine $(varname) from remote HEAD branch, defaulting to "$(fallback)". diff --git a/src/Writers/LaTeXWriter.jl b/src/Writers/LaTeXWriter.jl index cd7d048d9d..f06db16076 100644 --- a/src/Writers/LaTeXWriter.jl +++ b/src/Writers/LaTeXWriter.jl @@ -103,11 +103,7 @@ const DOCUMENT_STRUCTURE = ( # https://github.com/JuliaLang/julia/pull/32851 function mktempdir(args...; kwargs...) - if VERSION < v"1.3.0-alpha.112" - return Base.mktempdir(args...; kwargs...) - else - return Base.mktempdir(args...; cleanup=false, kwargs...) - end + return Base.mktempdir(args...; cleanup=false, kwargs...) end function render(doc::Documents.Document, settings::LaTeX=LaTeX()) diff --git a/src/deployconfig.jl b/src/deployconfig.jl index c459fedfff..b5e5522dd8 100644 --- a/src/deployconfig.jl +++ b/src/deployconfig.jl @@ -533,19 +533,9 @@ function verify_github_pull_repository(repo, prnr) end function run_and_capture(cmd) - stdout, stderr = if VERSION < v"1.1" - # On Julia 1.0, we can not pass IOBuffer() to pipeline(), so we're using the workaround - # described here: - # https://discourse.julialang.org/t/how-to-capture-stdout-and-stderr-in-1-1/20712/2 - stdout_pipe, stderr_pipe = Pipe(), Pipe() - run(pipeline(cmd; stdout = stdout_pipe, stderr = stderr_pipe)) - close(stdout_pipe.in); close(stderr_pipe.in) - stdout, stderr = read(stdout_pipe, String), read(stderr_pipe, String) - else - stdout_buffer, stderr_buffer = IOBuffer(), IOBuffer() - run(pipeline(cmd; stdout = stdout_buffer, stderr = stderr_buffer)) - stdout, stderr = String(take!(stdout_buffer)), String(take!(stderr_buffer)) - end + stdout_buffer, stderr_buffer = IOBuffer(), IOBuffer() + run(pipeline(cmd; stdout = stdout_buffer, stderr = stderr_buffer)) + stdout, stderr = String(take!(stdout_buffer)), String(take!(stderr_buffer)) return (; stdout = stdout, stderr = stderr) end diff --git a/test/TestUtilities.jl b/test/TestUtilities.jl index dacc18f9d5..415ac81127 100644 --- a/test/TestUtilities.jl +++ b/test/TestUtilities.jl @@ -87,15 +87,7 @@ end function trun(cmd::Base.AbstractCmd) buffer = IOBuffer() - cmd_redirected = if VERSION < v"1.6.0" - # Okay, older Julia versions have a missing method, which don't allow a redirect: - # MethodError: no method matching rawhandle(::Base.GenericIOBuffer{Array{UInt8,1}}) - # Not sure when it was exactly fixed, but 1.6 seems to work fine. - write(buffer, "no output recorded") - cmd - else - pipeline(cmd; stdin = devnull, stdout = buffer, stderr = buffer) - end + cmd_redirected = pipeline(cmd; stdin = devnull, stdout = buffer, stderr = buffer) try run(cmd_redirected) return true diff --git a/test/doctests/doctests.jl b/test/doctests/doctests.jl index 7571f4c0cf..1285098973 100644 --- a/test/doctests/doctests.jl +++ b/test/doctests/doctests.jl @@ -228,19 +228,10 @@ rfile(filename) = joinpath(@__DIR__, "stdouts", filename) @test is_same_as_file(output, rfile("32.stdout")) end - if VERSION >= v"1.5.0-DEV.178" - # Julia 1.5 REPL softscope, - # see https://github.com/JuliaLang/julia/pull/33864 - run_makedocs(["softscope.md"]) do result, success, backtrace, output - @test success - @test is_same_as_file(output, rfile("41.stdout")) - end - else - # Old REPL scoping behaviour on older Julia version - run_makedocs(["hardscope.md"]) do result, success, backtrace, output - @test success - @test is_same_as_file(output, rfile("42.stdout")) - end + # Tests for special REPL softscope + run_makedocs(["softscope.md"]) do result, success, backtrace, output + @test success + @test is_same_as_file(output, rfile("41.stdout")) end end diff --git a/test/doctests/fix/tests.jl b/test/doctests/fix/tests.jl index 00abf9d620..98cd27bbe9 100644 --- a/test/doctests/fix/tests.jl +++ b/test/doctests/fix/tests.jl @@ -17,8 +17,7 @@ using ..TestUtilities: @quietly const DocTestFixArray_2468 = Main.ShowWrap("4×1×1 Array{Int64,3}:\n[:, :, 1] =\n 2\n 4\n 6\n 8") end -# The version check is necessary due to a behaviour change in https://github.com/JuliaLang/julia/pull/32851 -mktempdir_nocleanup(dir) = VERSION >= v"1.3.0-alpha.112" ? mktempdir(dir, cleanup = false) : mktempdir(dir) +mktempdir_nocleanup(dir) = mktempdir(dir, cleanup = false) function normalize_line_endings(filename) s = read(filename, String) diff --git a/test/doctests/src/hardscope.md b/test/doctests/src/hardscope.md deleted file mode 100644 index 73142f5f96..0000000000 --- a/test/doctests/src/hardscope.md +++ /dev/null @@ -1,51 +0,0 @@ -REPL scoping behaviour when Julia < 1.5 - -```jldoctest; filter = r"Stacktrace:(\n \[[0-9]+\].*)+" -julia> s = 0 # global -0 - -julia> for i = 1:10 - t = s + i # new local `t` - s = t # assign global `s` - end -ERROR: UndefVarError: s not defined -Stacktrace: - [1] top-level scope at ./none:2 -[...] -``` - -```jldoctest; filter = r"Stacktrace:(\n \[[0-9]+\].*)+" -julia> code = """ - s = 0 # global - for i = 1:10 - t = s + i # new local `t` - s = t # new local `s` with warning - end - s, # global - @isdefined(t) # global - """; - -julia> include_string(Main, code) -ERROR: LoadError: UndefVarError: s not defined -Stacktrace: - [1] top-level scope at ./string:3 - [2] include_string(::Module, ::String, ::String) at ./loading.jl:1075 -[...] -``` - -```jldoctest; filter = r"Stacktrace:(\n \[[0-9]+\].*)+" -s = 0 # global -for i = 1:10 - t = s + i # new local `t` - s = t # new local `s` with warning -end -s, # global -@isdefined(t) # global - -# output - -ERROR: UndefVarError: s not defined -Stacktrace: - [1] top-level scope at ./none:2 -[...] -``` diff --git a/test/utilities.jl b/test/utilities.jl index 5024158f3b..69d909440b 100644 --- a/test/utilities.jl +++ b/test/utilities.jl @@ -52,10 +52,6 @@ module A end end -# hasfield was added in Julia 1.2. This definition borrowed from Compat.jl (MIT) -# Note: this can not be inside the testset -(VERSION < v"1.2.0-DEV.272") && (hasfield(::Type{T}, name::Symbol) where T = Base.fieldindex(T, name, false) > 0) - @testset "Utilities" begin let doc = @doc(length) a = Documenter.Utilities.filterdocs(doc, Set{Module}()) @@ -299,7 +295,7 @@ end end end - @testset "PR #1634, issue #1655" begin; if VERSION > v"1.6.0" + @testset "PR #1634, issue #1655" begin let parse(x) = Documenter.Utilities.parseblock(x, nothing, nothing; linenumbernode=LineNumberNode(123, "testfile.jl") ) @@ -337,7 +333,7 @@ end @test exs[1][1].args[2] == Expr(:call, :+, 1, 1) end end - end end + end @testset "mdparse" begin mdparse = Documenter.Utilities.mdparse From c5199f19660a0e5b32cefcedffc01276f9aa637e Mon Sep 17 00:00:00 2001 From: Morten Piibeleht Date: Mon, 6 Jun 2022 11:27:53 +1200 Subject: [PATCH 2/2] Remove maintenance label from CHANGELOG entry --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e5ebd94845..3f726d4ce1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,8 +2,8 @@ ## Version `v0.28.0` (unreleased) +* The (minimum) required Julia version has been raised from 1.0 to 1.6. For older Julia versions the 0.27.X release can still be used. ([#1835][github-1835], [#1841][github-1841]) * ![Enhancement][badge-enhancement] The `ansicolor` keyword to `HTML()` now defaults to true, meaning that executed outputs from `@example`- and `@repl`-blocks are now by default colored (if they emit colored output). ([#1828][github-1828]) -* ![Maintenance][badge-maintenance] The (minimum) required Julia version has been raised from 1.0 to 1.6. For older Julia versions the 0.27.X release can still be used. ([#1835][github-1835], [#1841][github-1841]) ## Version `v0.27.19`