diff --git a/src/DocTests.jl b/src/DocTests.jl index df89c0c05ed..f27118eaa06 100644 --- a/src/DocTests.jl +++ b/src/DocTests.jl @@ -103,7 +103,15 @@ function doctest(block::Markdown.Code, meta::Dict, doc::Documents.Document, page meta[:LocalDocTestArguments] = d for expr in [get(meta, :DocTestSetup, []); get(meta[:LocalDocTestArguments], :setup, [])] - Meta.isexpr(expr, :block) && (expr.head = :toplevel) + @show expr + if Meta.isexpr(expr, :block) + # @show expr.head + (expr.head = :toplevel) + end + @eval sandbox begin + @show LOAD_PATH + @show Base.active_project() + end Core.eval(sandbox, expr) end if occursin(r"^julia> "m, block.code) diff --git a/src/Utilities/Utilities.jl b/src/Utilities/Utilities.jl index f7becebd7a8..bd96d33fa3f 100644 --- a/src/Utilities/Utilities.jl +++ b/src/Utilities/Utilities.jl @@ -114,11 +114,11 @@ parsed from. The keyword argument `skip = N` drops the leading `N` lines from the input string. """ function parseblock(code::AbstractString, doc, page; skip = 0, keywords = true) + # work only with LF line endings internally + code = replace(code, "\r\n" => "\n") # Drop `skip` leading lines from the code block. Needed for deprecated `{docs}` syntax. code = string(code, '\n') code = last(split(code, '\n', limit = skip + 1)) - # Check whether we have windows-style line endings. - offset = occursin("\n\r", code) ? 2 : 1 endofstr = lastindex(code) results = [] cursor = 1 @@ -128,8 +128,7 @@ function parseblock(code::AbstractString, doc, page; skip = 0, keywords = true) keyword = Symbol(strip(line)) (ex, ncursor) = if keywords && haskey(Docs.keywords, keyword) - # adding offset below should be OK, as `\n` and `\r` are single byte - (QuoteNode(keyword), cursor + lastindex(line) + offset) + (QuoteNode(keyword), cursor + lastindex(line) + 1) # +1 for single byte '\n' else try Meta.parse(code, cursor)