Added command line script for weaving: bin/weave.jl. Closes #19

pull/22/head
Matti Pastell 2014-12-20 16:41:37 +02:00
parent cb60eee6f8
commit 9b620e4a67
3 changed files with 60 additions and 2 deletions

View File

@ -1,3 +1,4 @@
julia 0.3
Compat
TextWrap
ArgParse

59
bin/weave.jl Executable file
View File

@ -0,0 +1,59 @@
#!/usr/bin/env julia
using Weave
using ArgParse
ap = ArgParseSettings("Weave Julia documents using Weave.jl",
version = string(Pkg.installed("Weave")),
add_version = true)
@add_arg_table ap begin
"source"
nargs = '+'
help = "source document"
required = true
"--doctype"
arg_type = String
default = "pandoc"
help = "output format"
"--plotlib"
arg_type = String
default = "Gadfly"
help = "output format"
"--informat"
arg_type = String
default = "noweb"
help = "output format"
"--out_path"
arg_type = String
default = ":doc"
help = "output directory"
"--fig_path"
arg_type = String
default = "figures"
help = "figure output directory"
"--fig_ext"
default = nothing
help = "figure file format"
end
args = ArgParse.parse_args(ap)
source = args["source"]
delete!(args, "source")
args_col = {}
#Check for special values of out_path
if args["out_path"] == ":doc"
args["out_path"] = :doc
elseif args["out_path"] == ":pwd"
args["out_path"] = :pwd
end
for (key, val) in args
push!(args_col, (parse(key), val))
end
for s=source
weave(s; args_col...)
end

View File

@ -50,8 +50,6 @@ end
function weave(source ; doctype = "pandoc", plotlib="Gadfly", informat="noweb", out_path=:doc, fig_path = "figures", fig_ext = nothing)
cwd, fname = splitdir(abspath(source))
basename = splitext(fname)[1]
formatdict = formats[doctype].formatdict