Documenter.jl
Documenter.jl copied to clipboard
An empty line breaks REPL-style doctest
An empty line inside a for loop does not work
```jldoctest
julia> for i in 1:1
@show i
end
i = 1
```
although
```jldoctest
julia> for i in 1:1
@show i
end
i = 1
```
does.
Not sure if we can do anything about this. We use the fact that source lines have a bunch of whitespace before them as a heuristic to determine if it is a source line or an output line. See SOURCE_REGEX and how it's used in repl_splitter.
How about using Meta.parse?
code = """
julia> for i in 1:1
@show i
end
i = 1
"""
expr, i = Meta.parse(code, length("julia> "))
output = code[i:end]
@assert output == "i = 1\n"
I guess you need to combine Meta.parse with the whitespace-based heuristic to treat multiple expressions like
julia> println(1)
println(2)
1
2