mirror of https://github.com/mpastell/Weave.jl
Load JLD2 and FileIO only when cache is used
parent
d19d6b6d81
commit
88d8665e03
|
@ -1,16 +1,16 @@
|
|||
import JLD2, FileIO
|
||||
#FileIO and JLD2 are imported only if cache is used
|
||||
|
||||
function write_cache(doc::WeaveDoc, cache_path)
|
||||
cache_dir = joinpath(doc.cwd, cache_path)
|
||||
isdir(cache_dir) || mkpath(cache_dir)
|
||||
FileIO.save(joinpath(cache_dir, doc.basename * ".jld2"), Dict("doc" => doc))
|
||||
Base.invokelatest(FileIO.save, joinpath(cache_dir, doc.basename * ".jld2"), Dict("doc" => doc))
|
||||
return nothing
|
||||
end
|
||||
|
||||
function read_cache(doc::WeaveDoc, cache_path)
|
||||
name = joinpath(doc.cwd, cache_path, doc.basename * ".jld2")
|
||||
isfile(name) || return nothing
|
||||
return FileIO.load(name, "doc")
|
||||
return Base.invokelatest(FileIO.load, name, "doc")
|
||||
end
|
||||
|
||||
function restore_chunk(chunk::CodeChunk, cached)
|
||||
|
|
|
@ -37,6 +37,8 @@ function Base.run(doc::WeaveDoc; doctype = :auto, plotlib=:auto,
|
|||
fig_path = mktempdir(abspath(doc.cwd))
|
||||
end
|
||||
|
||||
cache == :off || @eval import FileIO, JLD2
|
||||
|
||||
#This is needed for latex and should work on all output formats
|
||||
is_windows() && (fig_path = replace(fig_path, "\\", "/"))
|
||||
|
||||
|
|
Loading…
Reference in New Issue