From d352a01adbee816586ed374de9c44bb69edb9848 Mon Sep 17 00:00:00 2001 From: Jeremie Knuesel Date: Wed, 3 Feb 2021 07:03:57 +0100 Subject: [PATCH] Fix crash in case of empty `# output` (#1510) (cherry picked from commit dffba5fcdb314b227f65c0164a2f78c68d1d3ece) --- CHANGELOG.md | 3 +++ src/DocTests.jl | 2 +- test/doctests/src/working.md | 9 ++++++++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d270187201..a46a4f0e63 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Version `v0.26.2` +* ![Bugfix][badge-bugfix] Script-type doctests that have an empty output section no longer crash Documenter. ([#1510][github-1510]) + * ![Bugfix][badge-bugfix] When checking for authentication keys when deploying, Documenter now more appropriately checks if the environment variables are non-empty, rather than just whether they are defined. ([#1511][github-1511]) ## Version `v0.26.1` @@ -726,6 +728,7 @@ [github-1491]: https://github.com/JuliaDocs/Documenter.jl/pull/1491 [github-1493]: https://github.com/JuliaDocs/Documenter.jl/pull/1493 [github-1497]: https://github.com/JuliaDocs/Documenter.jl/pull/1497 +[github-1510]: https://github.com/JuliaDocs/Documenter.jl/pull/1510 [github-1511]: https://github.com/JuliaDocs/Documenter.jl/pull/1511 [julia-38079]: https://github.com/JuliaLang/julia/issues/38079 diff --git a/src/DocTests.jl b/src/DocTests.jl index f3b0cea08a..d9d6e82751 100644 --- a/src/DocTests.jl +++ b/src/DocTests.jl @@ -239,7 +239,7 @@ function eval_script(block, sandbox, meta::Dict, doc::Documents.Document, page) # # # to mark `input`/`output` separation. - input, output = split(block.code, "# output\n", limit = 2) + input, output = split(block.code, r"^# output$"m, limit = 2) input = rstrip(input, '\n') output = lstrip(output, '\n') result = Result(block, input, output, meta[:CurrentFile]) diff --git a/test/doctests/src/working.md b/test/doctests/src/working.md index 677180caa4..0f743069da 100644 --- a/test/doctests/src/working.md +++ b/test/doctests/src/working.md @@ -52,4 +52,11 @@ Comments at the start: # .. should be ignored. julia> 2 + 2 4 -``` \ No newline at end of file +``` + +Empty output: + +```jldoctest +nothing +# output +```