diff --git a/src/Weave.jl b/src/Weave.jl index 592ff41..1653044 100644 --- a/src/Weave.jl +++ b/src/Weave.jl @@ -15,13 +15,13 @@ type Report <: Display figures::Array{String} term_state::Symbol cur_chunk - - function Report(cwd, basename, formatdict) - new(cwd, basename, formatdict, "", "", 1, String[], :text, nothing) - end - end +function Report(cwd, basename, formatdict) + Report(cwd, basename, formatdict, "", "", 1, String[], :text, nothing) +end + + #const report = Report() const supported_mime_types = diff --git a/src/cache.jl b/src/cache.jl index be35a8c..a629c2d 100644 --- a/src/cache.jl +++ b/src/cache.jl @@ -1,6 +1,5 @@ import JSON - function write_cache(doc::WeaveDoc, cache_path) cache_dir = "$(doc.cwd)/$cache_path" isdir(cache_dir) || mkpath(cache_dir) @@ -33,6 +32,7 @@ function restore_chunk(chunk::CodeChunk, cached, idx) return chunk end -function restore_chunk(chunk::DocChunk, cached, idx) - chunk -end +#Could be used to restore inline code in future +#function restore_chunk(chunk::DocChunk, cached, idx) +# chunk +#end diff --git a/src/chunks.jl b/src/chunks.jl index 711f1ed..6bb2318 100644 --- a/src/chunks.jl +++ b/src/chunks.jl @@ -12,13 +12,6 @@ type WeaveDoc basename = splitext(fname)[1] new(source, basename, path, chunks, "", nothing, "") end - - function WeaveDoc(source, chunks, cwd, doctype) - path, fname = splitdir(abspath(source)) - basename = splitext(fname)[1] - format = formats[doctype] - new(source, basename, path, chunks, cwd, format, doctype) - end end diff --git a/src/run.jl b/src/run.jl index 4dff12c..dab9d14 100644 --- a/src/run.jl +++ b/src/run.jl @@ -42,7 +42,7 @@ function Base.run(doc::WeaveDoc; doctype = "pandoc", plotlib="Gadfly", informat= report = Report(doc.cwd, doc.basename, doc.format.formatdict) pushdisplay(report) - if cache != :off || cache != :refresh + if cache != :off || cache != :refresh cached = read_cache(doc, cache_path) cached == nothing && info("No cached results found, running code") else @@ -186,12 +186,9 @@ function eval_chunk(chunk::CodeChunk, report::Report, SandBox::Module) chunk end -function eval_chunk(chunk::DocChunk, report::Report, SandBox) - chunk -end - - - +#function eval_chunk(chunk::DocChunk, report::Report, SandBox) +# chunk +#end #Set all variables to nothing function clear_sandbox(SandBox::Module) diff --git a/test/cache_test.jl b/test/cache_test.jl index 6971a01..aad82bf 100644 --- a/test/cache_test.jl +++ b/test/cache_test.jl @@ -4,34 +4,28 @@ using Base.Test #Test if running document with and without cache works isdir("documents/cache") && rm("documents/cache", recursive = true) weave("documents/chunk_options.noweb", plotlib=nothing, cache=:all) -ctime1 = ctime("documents/chunk_options.md") result = readall(open("documents/chunk_options.md")) +rm("documents/chunk_options.md") weave("documents/chunk_options.noweb", plotlib=nothing, cache=:all) -ctime2 = ctime("documents/chunk_options.md") cached_result = readall(open("documents/chunk_options.md")) @test result == cached_result -@test ctime1 != ctime2 # cache = :user isdir("documents/cache") && rm("documents/cache", recursive = true) out = "documents/chunk_cache.md" Weave.weave("documents/chunk_cache.noweb", plotlib=nothing, cache=:user); result = readall(open(out)) -ctime1 = ctime(out) +rm(out) Weave.weave("documents/chunk_cache.noweb", plotlib=nothing, cache=:user); cached_result = readall(open(out)) -ctime2 = ctime(out) @test result == cached_result -@test ctime1 != ctime2 using Gadfly isdir("documents/cache") && rm("documents/cache", recursive = true) #Caching with Gadfly weave("documents/gadfly_formats_test.txt", doctype="tex", plotlib="gadfly", cache=:all) result = readall(open("documents/gadfly_formats_test.tex")) -ctime1 = ctime("documents/gadfly_formats_test.tex") +rm("documents/gadfly_formats_test.tex") weave("documents/gadfly_formats_test.txt", doctype="tex", plotlib="gadfly", cache=:all) -ctime2 = ctime("documents/gadfly_formats_test.tex") cached_result = readall(open("documents/gadfly_formats_test.tex")) @test result == cached_result -@test ctime1 != ctime2