From 5f470a0a2a2175f46ea8e486fa1b5e9de2db3192 Mon Sep 17 00:00:00 2001 From: Fredrik Ekre Date: Fri, 10 Aug 2018 17:38:51 +0200 Subject: [PATCH] fix doctest = :fix with empty output --- src/DocChecks.jl | 1 + test/doctests/broken.jl | 5 +++++ test/doctests/broken.md | 5 +++++ test/doctests/fixed.jl | 7 +++++++ test/doctests/fixed.md | 7 +++++++ 5 files changed, 25 insertions(+) diff --git a/src/DocChecks.jl b/src/DocChecks.jl index 25f43cb6ce9..9d74b376769 100644 --- a/src/DocChecks.jl +++ b/src/DocChecks.jl @@ -431,6 +431,7 @@ function fix_doctest(result::Result, str, doc::Documents.Document) # construct the new code-snippet (without indent) # first part: everything up until the last index of the input string newcode = code[1:last(inputidx)] + isempty(result.output) && (newcode *= '\n') # issue #772 # second part: the rest, with the old output replaced with the new one newcode *= replace(code[nextind(code, last(inputidx)):end], result.output => str, count = 1) # replace internal code block with the non-indented new code, needed if we come back diff --git a/test/doctests/broken.jl b/test/doctests/broken.jl index b74d141e6c2..9d4e264da56 100644 --- a/test/doctests/broken.jl +++ b/test/doctests/broken.jl @@ -70,6 +70,11 @@ Int64[1, 2, 3, 4] * 2 julia> println(" foobar") foobaz ``` +```jldoctest +julia> 1 + 2 + +julia> 3 + 4 +``` """ foo() = 1 diff --git a/test/doctests/broken.md b/test/doctests/broken.md index bff92a71853..aa0ee7d0aa7 100644 --- a/test/doctests/broken.md +++ b/test/doctests/broken.md @@ -72,3 +72,8 @@ Int64[1, 2, 3, 4] * 2 julia> println(" foobar") foobaz ``` +```jldoctest +julia> 1 + 2 + +julia> 3 + 4 +``` \ No newline at end of file diff --git a/test/doctests/fixed.jl b/test/doctests/fixed.jl index bb3bac54050..c6852bf8a5c 100644 --- a/test/doctests/fixed.jl +++ b/test/doctests/fixed.jl @@ -70,6 +70,13 @@ Int64[1, 2, 3, 4] * 2 julia> println(" foobar") foobar ``` +```jldoctest +julia> 1 + 2 +3 + +julia> 3 + 4 +7 +``` """ foo() = 1 diff --git a/test/doctests/fixed.md b/test/doctests/fixed.md index 85f497e8fe0..c7a87e8be51 100644 --- a/test/doctests/fixed.md +++ b/test/doctests/fixed.md @@ -72,3 +72,10 @@ Int64[1, 2, 3, 4] * 2 julia> println(" foobar") foobar ``` +```jldoctest +julia> 1 + 2 +3 + +julia> 3 + 4 +7 +``` \ No newline at end of file