From f63f42513b52a09d12436a35c2be247a79619ccf Mon Sep 17 00:00:00 2001 From: Jeremie Knuesel Date: Tue, 26 Jan 2021 16:31:45 +0100 Subject: [PATCH 1/4] Fix crash in case of empty `# output` --- src/DocTests.jl | 4 +++- test/doctests/src/working.md | 9 ++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/DocTests.jl b/src/DocTests.jl index f3b0cea08a..9efe060403 100644 --- a/src/DocTests.jl +++ b/src/DocTests.jl @@ -239,7 +239,9 @@ 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) + + # Append "\n" before split in case of empty output + input, output = split(block.code*"\n", "# output\n", 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 +``` From baa193f176bbce146c6d42b8c5557665367293e6 Mon Sep 17 00:00:00 2001 From: Jeremie Knuesel Date: Wed, 27 Jan 2021 17:07:58 +0100 Subject: [PATCH 2/4] Use regex for input/output split Co-authored-by: Fredrik Ekre --- src/DocTests.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DocTests.jl b/src/DocTests.jl index 9efe060403..7c9ef679a7 100644 --- a/src/DocTests.jl +++ b/src/DocTests.jl @@ -241,7 +241,7 @@ function eval_script(block, sandbox, meta::Dict, doc::Documents.Document, page) # to mark `input`/`output` separation. # Append "\n" before split in case of empty output - input, output = split(block.code*"\n", "# 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]) From 96650174891a36eca96db9446824e5fb624ba868 Mon Sep 17 00:00:00 2001 From: Jeremie Knuesel Date: Wed, 27 Jan 2021 17:31:49 +0100 Subject: [PATCH 3/4] Remove leftover comment from previous version Co-authored-by: Fredrik Ekre --- src/DocTests.jl | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/DocTests.jl b/src/DocTests.jl index 7c9ef679a7..d9d6e82751 100644 --- a/src/DocTests.jl +++ b/src/DocTests.jl @@ -239,8 +239,6 @@ function eval_script(block, sandbox, meta::Dict, doc::Documents.Document, page) # # # to mark `input`/`output` separation. - - # Append "\n" before split in case of empty output input, output = split(block.code, r"^# output$"m, limit = 2) input = rstrip(input, '\n') output = lstrip(output, '\n') From c1d524f3cb8436cd25608f5b36f5ba0286991eb2 Mon Sep 17 00:00:00 2001 From: Morten Piibeleht Date: Wed, 3 Feb 2021 11:10:43 +1300 Subject: [PATCH 4/4] Update CHANGELOG.md --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7ac3b8cf99..d36a87cbc5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ - highlight.js has been updated to `v10.5.0`, which also brings various updates to the highlighting of Julia code. Due to the changes in highlight.js, code highlighting will not work on IE11. ([#1503][github-1503]) +## Version `v0.26.2` + +* ![Bugfix][badge-bugfix] Script-type doctests that have an empty output section no longer crash Documenter. ([#1510][github-1510]) + ## Version `v0.26.1` * ![Bugfix][badge-bugfix] HTML assets that are copied directly from Documenters source to the build output now has correct file permissions. ([#1497][github-1497]) @@ -729,6 +733,7 @@ [github-1493]: https://github.com/JuliaDocs/Documenter.jl/pull/1493 [github-1497]: https://github.com/JuliaDocs/Documenter.jl/pull/1497 [github-1503]: https://github.com/JuliaDocs/Documenter.jl/pull/1503 +[github-1510]: https://github.com/JuliaDocs/Documenter.jl/pull/1510 [julia-38079]: https://github.com/JuliaLang/julia/issues/38079