Skip to content

Commit

Permalink
fix doctest = :fix with empty output
Browse files Browse the repository at this point in the history
  • Loading branch information
fredrikekre committed Aug 10, 2018
1 parent 08c5528 commit 5f470a0
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/DocChecks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions test/doctests/broken.jl
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ Int64[1, 2, 3, 4] * 2
julia> println(" foobar")
foobaz
```
```jldoctest
julia> 1 + 2
julia> 3 + 4
```
"""
foo() = 1

Expand Down
5 changes: 5 additions & 0 deletions test/doctests/broken.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,8 @@ Int64[1, 2, 3, 4] * 2
julia> println(" foobar")
foobaz
```
```jldoctest
julia> 1 + 2
julia> 3 + 4
```
7 changes: 7 additions & 0 deletions test/doctests/fixed.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
7 changes: 7 additions & 0 deletions test/doctests/fixed.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,10 @@ Int64[1, 2, 3, 4] * 2
julia> println(" foobar")
foobar
```
```jldoctest
julia> 1 + 2
3
julia> 3 + 4
7
```

0 comments on commit 5f470a0

Please sign in to comment.