mirror of https://github.com/mpastell/Weave.jl
commit
fa1691b511
24
src/Weave.jl
24
src/Weave.jl
|
@ -47,6 +47,28 @@ end
|
|||
#module ReportSandBox
|
||||
#end
|
||||
|
||||
function tangle(source ; out_path=:doc, informat="noweb")
|
||||
cwd, fname = splitdir(abspath(source))
|
||||
basename = splitext(fname)[1]
|
||||
|
||||
#Set the output directory
|
||||
if out_path == :pwd
|
||||
cwd = pwd()
|
||||
elseif out_path != :doc
|
||||
cwd = out_path
|
||||
end
|
||||
|
||||
outname = "$(cwd)/$(basename).jl"
|
||||
open(outname, "w") do io
|
||||
for chunk in read_document(source, informat)
|
||||
if chunk[:type] == "code"
|
||||
write(io, chunk[:content]*"\n")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
info("Writing to file $(basename).jl")
|
||||
end
|
||||
|
||||
function weave(source ; doctype = "pandoc", plotlib="Gadfly", informat="noweb", out_path=:doc, fig_path = "figures", fig_ext = nothing)
|
||||
|
||||
|
@ -275,7 +297,7 @@ function get_figname(report::Report, chunk; fignum = nothing)
|
|||
return full_name, rel_name
|
||||
end
|
||||
|
||||
export weave, list_out_formats
|
||||
export weave, list_out_formats, tangle
|
||||
|
||||
include("config.jl")
|
||||
include("readers.jl")
|
||||
|
|
|
@ -21,3 +21,8 @@ weave("documents/chunk_options.noweb", doctype="rst", plotlib=nothing)
|
|||
result = readall(open("documents/chunk_options.rst"))
|
||||
ref = readall(open("documents/chunk_options_ref.rst"))
|
||||
@test result == ref
|
||||
|
||||
tangle("documents/chunk_options.noweb")
|
||||
result = readall(open("documents/chunk_options.jl"))
|
||||
ref = readall(open("documents/chunk_options_ref.jl"))
|
||||
@test result == ref
|
|
@ -0,0 +1,20 @@
|
|||
|
||||
y= [2, 5, 12]
|
||||
|
||||
x = [12, 10]
|
||||
println(y)
|
||||
println(x)
|
||||
|
||||
println("Results without code")
|
||||
println(x)
|
||||
|
||||
y = randn(5)
|
||||
println("Don't eval, but show code")
|
||||
|
||||
y = 1:5
|
||||
println(y)
|
||||
|
||||
a = "Don't print me"
|
||||
println(a)
|
||||
|
||||
println("No markup for results.")
|
Loading…
Reference in New Issue