mirror of https://github.com/mpastell/Weave.jl
clean up:
- unused `:display` chunk option - rm `displayed` chunk field - rm `cur_result`, `pendind_code`, `term_state` `Report` field - rm `:skip` config optionpull/369/head
parent
8d95e159e2
commit
c0e7e66ec3
|
@ -14,7 +14,6 @@ const _DEFAULT_PARAMS = Dict{Symbol,Any}(
|
|||
:fig_path => DEFAULT_FIG_PATH,
|
||||
:dpi => 96,
|
||||
:term => false,
|
||||
:display => false,
|
||||
:prompt => "\njulia> ",
|
||||
:label => nothing,
|
||||
:wrap => true,
|
||||
|
@ -25,7 +24,6 @@ const _DEFAULT_PARAMS = Dict{Symbol,Any}(
|
|||
:fig_env => nothing,
|
||||
:out_width => nothing,
|
||||
:out_height => nothing,
|
||||
:skip => false,
|
||||
)
|
||||
const DEFAULT_PARAMS = deepcopy(_DEFAULT_PARAMS) # might be changed at runtime
|
||||
|
||||
|
|
|
@ -102,8 +102,6 @@ function convert_to_notebook(doc)
|
|||
"source" => [strip(join([repr(c) for c in chunk.content], ""))],
|
||||
),
|
||||
)
|
||||
elseif haskey(chunk.options, :skip) && chunk.options[:skip] == "notebook"
|
||||
continue
|
||||
else
|
||||
push!(
|
||||
cells,
|
||||
|
|
|
@ -5,12 +5,9 @@ mutable struct Report <: AbstractDisplay
|
|||
cwd::AbstractString
|
||||
basename::AbstractString
|
||||
format::WeaveFormat
|
||||
pending_code::AbstractString
|
||||
cur_result::AbstractString
|
||||
rich_output::AbstractString
|
||||
fignum::Int
|
||||
figures::Array{AbstractString}
|
||||
term_state::Symbol
|
||||
figures::Vector{String}
|
||||
cur_chunk::Any
|
||||
mimetypes::Array{AbstractString}
|
||||
first_plot::Bool
|
||||
|
@ -24,11 +21,8 @@ function Report(cwd, basename, format, mimetypes, throw_errors)
|
|||
basename,
|
||||
format,
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
1,
|
||||
AbstractString[],
|
||||
:text,
|
||||
String[],
|
||||
nothing,
|
||||
mimetypes,
|
||||
true,
|
||||
|
|
18
src/run.jl
18
src/run.jl
|
@ -193,11 +193,7 @@ function run_inline(inline::InlineCode, doc::WeaveDoc, report::Report, mod::Modu
|
|||
return inline
|
||||
end
|
||||
|
||||
function reset_report(report::Report)
|
||||
report.cur_result = ""
|
||||
report.figures = AbstractString[]
|
||||
report.term_state = :text
|
||||
end
|
||||
reset_report(report::Report) = report.figures = String[]
|
||||
|
||||
function run_code(doc::WeaveDoc, chunk::CodeChunk, report::Report, mod::Module)
|
||||
ss = parse_input(chunk.content)
|
||||
|
@ -210,12 +206,11 @@ function run_code(doc::WeaveDoc, chunk::CodeChunk, report::Report, mod::Module)
|
|||
s,
|
||||
doc.path,
|
||||
chunk.options[:term],
|
||||
chunk.options[:display],
|
||||
i == n,
|
||||
report.throw_errors,
|
||||
)
|
||||
figures = report.figures # Captured figures
|
||||
result = ChunkOutput(s, out, report.cur_result, report.rich_output, figures)
|
||||
result = ChunkOutput(s, out, report.rich_output, figures)
|
||||
report.rich_output = ""
|
||||
push!(results, result)
|
||||
end
|
||||
|
@ -235,7 +230,7 @@ function parse_input(s)
|
|||
return res
|
||||
end
|
||||
|
||||
function capture_output(mod, s, path, term, disp, lastline, throw_errors = false)
|
||||
function capture_output(mod, s, path, term, lastline, throw_errors = false)
|
||||
local out = nothing
|
||||
local obj = nothing
|
||||
|
||||
|
@ -246,7 +241,7 @@ function capture_output(mod, s, path, term, disp, lastline, throw_errors = false
|
|||
task_local_storage(:SOURCE_PATH, path) do
|
||||
try
|
||||
obj = include_string(mod, s, path) # TODO: fix line number
|
||||
!isnothing(obj) && ((term || disp) || lastline) && display(obj)
|
||||
!isnothing(obj) && (term || lastline) && display(obj)
|
||||
catch _err
|
||||
err = unwrap_load_err(_err)
|
||||
throw_errors && throw(err)
|
||||
|
@ -388,7 +383,7 @@ function collect_results(chunk::CodeChunk)
|
|||
)
|
||||
content = ""
|
||||
rchunk.figures = r.figures
|
||||
rchunk.output = r.stdout * r.displayed
|
||||
rchunk.output = r.stdout
|
||||
rchunk.rich_output = r.rich_output
|
||||
push!(result_chunks, rchunk)
|
||||
end
|
||||
|
@ -413,8 +408,7 @@ function collect_term_results(chunk::CodeChunk)
|
|||
prompt = chunk.options[:prompt]
|
||||
result_chunks = CodeChunk[]
|
||||
for r in chunk.result
|
||||
output *= prompt * r.code
|
||||
output *= r.displayed * r.stdout
|
||||
output *= string(prompt, r.code, r.stdout)
|
||||
if !isempty(r.figures)
|
||||
rchunk = CodeChunk(
|
||||
"",
|
||||
|
|
|
@ -18,11 +18,10 @@ mutable struct WeaveDoc
|
|||
end
|
||||
|
||||
struct ChunkOutput
|
||||
code::AbstractString
|
||||
stdout::AbstractString
|
||||
displayed::AbstractString
|
||||
rich_output::AbstractString
|
||||
figures::Vector{AbstractString}
|
||||
code::String
|
||||
stdout::String
|
||||
rich_output::String
|
||||
figures::Vector{String}
|
||||
end
|
||||
|
||||
mutable struct CodeChunk <: WeaveChunk
|
||||
|
|
Loading…
Reference in New Issue