From 0c847f2378f1a7e8342fd60265a1ae3412694c0f Mon Sep 17 00:00:00 2001 From: Matti Pastell Date: Fri, 22 Apr 2016 09:26:27 +0300 Subject: [PATCH] Added tangle option to code chunks, closes #33 --- src/Weave.jl | 15 +++++++++------ src/config.jl | 1 + test/documents/chunk_options.noweb | 2 +- test/documents/chunk_options_ref.jl | 3 --- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/Weave.jl b/src/Weave.jl index 4725704..5dc6cc3 100644 --- a/src/Weave.jl +++ b/src/Weave.jl @@ -60,13 +60,16 @@ function tangle(source ; out_path=:doc, informat="noweb") cwd = get_cwd(doc, out_path) outname = "$(cwd)/$(doc.basename).jl" - open(outname, "w") do io - for chunk in doc.chunks - if typeof(chunk) == CodeChunk - write(io, chunk.content*"\n") - end - end + open(outname, "w") do io + for chunk in doc.chunks + if typeof(chunk) == CodeChunk + options = merge(rcParams[:chunk_defaults], chunk.options) + if options[:tangle] + write(io, chunk.content*"\n") + end + end end + end info("Writing to file $(doc.basename).jl") end diff --git a/src/config.jl b/src/config.jl index 9cb8f0b..7f6acb3 100644 --- a/src/config.jl +++ b/src/config.jl @@ -13,6 +13,7 @@ const defaultParams = :fig=> true, :include=> true, :eval => true, + :tangle => true, :cache => false, :fig_cap=> nothing, #Size in inches diff --git a/test/documents/chunk_options.noweb b/test/documents/chunk_options.noweb index 884a7ff..0dc98c7 100644 --- a/test/documents/chunk_options.noweb +++ b/test/documents/chunk_options.noweb @@ -16,7 +16,7 @@ println(x) @ -<>= +<>= y = randn(5) println("Don't eval, but show code") @ diff --git a/test/documents/chunk_options_ref.jl b/test/documents/chunk_options_ref.jl index 445d940..efc2dff 100644 --- a/test/documents/chunk_options_ref.jl +++ b/test/documents/chunk_options_ref.jl @@ -8,9 +8,6 @@ println(x) println("Results without code") println(x) -y = randn(5) -println("Don't eval, but show code") - y = 1:5 println(y)