From fc38d330de7d7a02e168994dc79d30588e3e8113 Mon Sep 17 00:00:00 2001 From: Nathan Musoke Date: Tue, 11 Jul 2023 17:53:48 -0400 Subject: [PATCH 1/4] `@debug` the next REPL line before evaling it Add a `@debug` expression within DocTests.eval_repl to show which line is about to be evaluated. This was requested in https://github.com/JuliaDocs/Documenter.jl/issues/2013 --- src/DocTests.jl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/DocTests.jl b/src/DocTests.jl index f2bdd9291c..7639fc82b9 100644 --- a/src/DocTests.jl +++ b/src/DocTests.jl @@ -242,6 +242,8 @@ end function eval_repl(block, sandbox, meta::Dict, doc::Documenter.Document, page) for (input, output) in repl_splitter(block.code) result = Result(block, input, output, meta[:CurrentFile]) + src_lines = Documenter.find_block_in_file(result.block.code, result.file) + @debug "Evaluating doctest REPL line from $(Documenter.locrepr(result.file, src_lines))" input expected_output = output for (ex, str) in Documenter.parseblock(input, doc, page; keywords = false, raise=false) # Input containing a semi-colon gets suppressed in the final output. result.hide = REPL.ends_with_semicolon(str) From da22aab7528f6a830ecda96147728c61c41dcec5 Mon Sep 17 00:00:00 2001 From: Nathan Musoke Date: Tue, 11 Jul 2023 17:53:48 -0400 Subject: [PATCH 2/4] `@debug` REPL lines inside inner loop --- src/DocTests.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DocTests.jl b/src/DocTests.jl index 7639fc82b9..cd8bd5457b 100644 --- a/src/DocTests.jl +++ b/src/DocTests.jl @@ -243,9 +243,9 @@ function eval_repl(block, sandbox, meta::Dict, doc::Documenter.Document, page) for (input, output) in repl_splitter(block.code) result = Result(block, input, output, meta[:CurrentFile]) src_lines = Documenter.find_block_in_file(result.block.code, result.file) - @debug "Evaluating doctest REPL line from $(Documenter.locrepr(result.file, src_lines))" input expected_output = output for (ex, str) in Documenter.parseblock(input, doc, page; keywords = false, raise=false) # Input containing a semi-colon gets suppressed in the final output. + @debug "Evaluating doctest REPL line from $(Documenter.locrepr(result.file, src_lines))" unparsed_string = str parsed_expression = ex result.hide = REPL.ends_with_semicolon(str) # Use the REPL softscope for REPL jldoctests, # see https://github.com/JuliaLang/julia/pull/33864 From 76f454dc3c2b411b04e61fc05cff2ab0d71b7dd3 Mon Sep 17 00:00:00 2001 From: nathan musoke Date: Thu, 13 Jul 2023 11:36:24 -0400 Subject: [PATCH 3/4] clarify when line came from Co-authored-by: Morten Piibeleht --- src/DocTests.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DocTests.jl b/src/DocTests.jl index cd8bd5457b..9be751f0e6 100644 --- a/src/DocTests.jl +++ b/src/DocTests.jl @@ -245,7 +245,7 @@ function eval_repl(block, sandbox, meta::Dict, doc::Documenter.Document, page) src_lines = Documenter.find_block_in_file(result.block.code, result.file) for (ex, str) in Documenter.parseblock(input, doc, page; keywords = false, raise=false) # Input containing a semi-colon gets suppressed in the final output. - @debug "Evaluating doctest REPL line from $(Documenter.locrepr(result.file, src_lines))" unparsed_string = str parsed_expression = ex + @debug "Evaluating REPL line from doctest at $(Documenter.locrepr(result.file, src_lines))" unparsed_string = str parsed_expression = ex result.hide = REPL.ends_with_semicolon(str) # Use the REPL softscope for REPL jldoctests, # see https://github.com/JuliaLang/julia/pull/33864 From 8326ae21e5c418dcb8dd718fe22f024ad8ab6545 Mon Sep 17 00:00:00 2001 From: Nathan Musoke Date: Thu, 13 Jul 2023 11:57:52 -0400 Subject: [PATCH 4/4] move definition of scr_lines outside loop --- src/DocTests.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DocTests.jl b/src/DocTests.jl index 9be751f0e6..cd33647fbd 100644 --- a/src/DocTests.jl +++ b/src/DocTests.jl @@ -240,9 +240,9 @@ mutable struct Result end function eval_repl(block, sandbox, meta::Dict, doc::Documenter.Document, page) + src_lines = Documenter.find_block_in_file(block.code, meta[:CurrentFile]) for (input, output) in repl_splitter(block.code) result = Result(block, input, output, meta[:CurrentFile]) - src_lines = Documenter.find_block_in_file(result.block.code, result.file) for (ex, str) in Documenter.parseblock(input, doc, page; keywords = false, raise=false) # Input containing a semi-colon gets suppressed in the final output. @debug "Evaluating REPL line from doctest at $(Documenter.locrepr(result.file, src_lines))" unparsed_string = str parsed_expression = ex