Browse Source

Apply suggestions from code review

pull/150/head
Fredrik Ekre 5 years ago committed by GitHub
parent
commit
d6d1aa8065
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 12
      src/Literate.jl

12
src/Literate.jl

@ -458,7 +458,7 @@ function markdown(inputfile, outputdir=pwd(); config::Dict=Dict(), kwargs...) @@ -458,7 +458,7 @@ function markdown(inputfile, outputdir=pwd(); config::Dict=Dict(), kwargs...)
write_code = !(all(l -> endswith(l, "#hide"), chunk.lines) && !(config["documenter"]::Bool))
write_code && write(iomd, seekstart(iocode))
if config["execute"]::Bool
execute_markdown!(iomd, sb, join(chunk.lines, '\n'), outputdir; inputfile)
execute_markdown!(iomd, sb, join(chunk.lines, '\n'), outputdir; inputfile=inputfile)
end
end
write(iomd, '\n') # add a newline between each chunk
@ -474,7 +474,7 @@ end @@ -474,7 +474,7 @@ end
function execute_markdown!(io::IO, sb::Module, block::String, outputdir; inputfile::String="")
# TODO: Deal with explicit display(...) calls
r, str, _ = execute_block(sb, block; inputfile)
r, str, _ = execute_block(sb, block; inputfile=inputfile)
plain_fence = "\n```\n" => "\n```" # issue #101: consecutive codefenced blocks need newline
if r !== nothing && !REPL.ends_with_semicolon(block)
for (mime, ext) in [(MIME("image/png"), ".png"), (MIME("image/jpeg"), ".jpeg")]
@ -537,7 +537,7 @@ function notebook(inputfile, outputdir=pwd(); config::Dict=Dict(), kwargs...) @@ -537,7 +537,7 @@ function notebook(inputfile, outputdir=pwd(); config::Dict=Dict(), kwargs...)
preprocessor(inputfile, outputdir; user_config=config, user_kwargs=kwargs, type=:nb)
# create the notebook
nb = jupyter_notebook(chunks, config; inputfile)
nb = jupyter_notebook(chunks, config; inputfile=inputfile)
# write to file
outputfile = write_result(nb, config; print = (io, c)->JSON.print(io, c, 1))
@ -601,7 +601,7 @@ function jupyter_notebook(chunks, config; inputfile::String="") @@ -601,7 +601,7 @@ function jupyter_notebook(chunks, config; inputfile::String="")
@info "executing notebook `$(config["name"] * ".ipynb")`"
try
cd(config["literate_outputdir"]) do
nb = execute_notebook(nb; inputfile)
nb = execute_notebook(nb; inputfile=inputfile)
end
catch err
@error "error when executing notebook based on input file: " *
@ -620,7 +620,7 @@ function execute_notebook(nb; inputfile::String="") @@ -620,7 +620,7 @@ function execute_notebook(nb; inputfile::String="")
execution_count += 1
cell["execution_count"] = execution_count
block = join(cell["source"])
r, str, display_dicts = execute_block(sb, block; inputfile)
r, str, display_dicts = execute_block(sb, block; inputfile=inputfile)
# str should go into stream
if !isempty(str)
@ -724,7 +724,7 @@ function execute_block(sb::Module, block::String; inputfile::String="") @@ -724,7 +724,7 @@ function execute_block(sb::Module, block::String; inputfile::String="")
if c.error
error("""
$(sprint(showerror, c.value))
when executing the following code block in $inputfile
when executing the following code block in file $(repr(inputfile))
```julia
$block

Loading…
Cancel
Save