mirror of https://github.com/mpastell/Weave.jl
Merge branch 'master' of https://github.com/dmbates/JuliaReport.jl
Conflicts: REQUIRE src/config.jl src/readers.jlpull/8/head
commit
5d95c806d5
|
@ -1,4 +1,5 @@
|
|||
module JuliaReport
|
||||
using Compat
|
||||
using PyCall
|
||||
#using PyPlot
|
||||
@pyimport pweave #Output formatting uses Pweave
|
||||
|
@ -17,7 +18,7 @@ type Report
|
|||
end
|
||||
|
||||
|
||||
const report = Report("", false, "", "", {}, "", "")
|
||||
const report = Report("", false, "", "", Any[], "", "")
|
||||
|
||||
function listformats()
|
||||
pweave.listformats()
|
||||
|
@ -200,6 +201,8 @@ end
|
|||
|
||||
export weave
|
||||
|
||||
typealias StrD Dict{ASCIIString,Any}
|
||||
|
||||
include("config.jl")
|
||||
include("readers.jl")
|
||||
end
|
||||
|
|
|
@ -1,26 +1,25 @@
|
|||
const rcParams = {"figdir"=> "figures",
|
||||
"plotlib" => "Winston",
|
||||
"storeresults"=> false,
|
||||
"cachedir"=> "cache",
|
||||
"chunk"=>
|
||||
{"defaultoptions"=>
|
||||
{
|
||||
"echo"=> true,
|
||||
"results"=> "verbatim",
|
||||
"fig"=> true,
|
||||
"include"=> true,
|
||||
"evaluate"=> true,
|
||||
"caption"=> false,
|
||||
"term"=> false,
|
||||
"name"=> nothing,
|
||||
"wrap"=> true,
|
||||
"f_pos"=> "htpb",
|
||||
"f_size"=> (8, 6),
|
||||
"f_env"=> nothing,
|
||||
"f_spines"=> true,
|
||||
"complete"=> true,
|
||||
"engine"=> "julia",
|
||||
"option_string"=> ""
|
||||
}
|
||||
}
|
||||
}
|
||||
const rcParams =
|
||||
@compat Dict{ASCIIString,Any}("figdir"=> "figures",
|
||||
"plotlib" => "PyPlot",
|
||||
"storeresults"=> false,
|
||||
"cachedir"=> "cache",
|
||||
"chunk"=>
|
||||
Dict{ASCIIString,Any}("defaultoptions"=>
|
||||
Dict{ASCIIString,Any}("echo"=> true,
|
||||
"results"=> "verbatim",
|
||||
"fig"=> true,
|
||||
"include"=> true,
|
||||
"evaluate"=> true,
|
||||
"caption"=> false,
|
||||
"term"=> false,
|
||||
"name"=> nothing,
|
||||
"wrap"=> true,
|
||||
"f_pos"=> "htpb",
|
||||
"f_size"=> (8, 6),
|
||||
"f_env"=> nothing,
|
||||
"f_spines"=> true,
|
||||
"complete"=> true,
|
||||
"engine"=> "julia",
|
||||
"option_string"=> "")
|
||||
)
|
||||
)
|
||||
|
|
134
src/readers.jl
134
src/readers.jl
|
@ -1,65 +1,69 @@
|
|||
function read_noweb(document)
|
||||
doctext = readall(open(document))
|
||||
#doctext = document #Replace with file...
|
||||
codestart = r"^<<(.*?)>>="
|
||||
codeend = r"^@(\s*)$"
|
||||
state = "doc"
|
||||
|
||||
docno = 1
|
||||
codeno = 1
|
||||
content = ""
|
||||
lineno = 0
|
||||
start_line = 0
|
||||
|
||||
options = Dict()
|
||||
optionstring = ""
|
||||
parsed = Dict[]
|
||||
for (lineno, line) in enumerate(split(doctext, "\n"))
|
||||
|
||||
if ismatch(codestart, line) && state=="doc"
|
||||
state = "code"
|
||||
m = match(codestart, line)
|
||||
optionstring=m.captures[1]
|
||||
#println(m.captures[1])
|
||||
if strip(optionstring)==""
|
||||
options = Dict()
|
||||
else
|
||||
try
|
||||
options = eval(parse("{" * optionstring * "}"))
|
||||
catch
|
||||
options = Dict()
|
||||
warn(string("Invalid format for chunk options line: ", lineno))
|
||||
end
|
||||
end
|
||||
haskey(options, "label") && (options["name"] = options["label"])
|
||||
haskey(options, "name") || (options["name"] = nothing)
|
||||
|
||||
chunk = {"type" => "doc", "content"=> content, "number" => docno, "start_line"=>start_line}
|
||||
docno += 1
|
||||
start_line = lineno
|
||||
push!(parsed, chunk)
|
||||
content = ""
|
||||
continue
|
||||
end
|
||||
if ismatch(codeend, line) && state=="code"
|
||||
chunk = {"type" => "code", "content" => content, "number" => codeno,
|
||||
"options"=>options,"optionstring"=>optionstring, "start_line"=>start_line}
|
||||
codeno+=1
|
||||
start_line = lineno
|
||||
content = ""
|
||||
state = "doc"
|
||||
push!(parsed, chunk)
|
||||
continue
|
||||
end
|
||||
|
||||
content *= "\n" * line
|
||||
end
|
||||
|
||||
#Remember the last chunk
|
||||
if content != ""
|
||||
chunk = {"type" => "doc", "content"=> content, "number" => docno, "start_line"=>lineno}
|
||||
push!(parsed, chunk)
|
||||
end
|
||||
|
||||
return parsed
|
||||
end
|
||||
function read_noweb(document)
|
||||
doctext = readall(open(document))
|
||||
#doctext = document #Replace with file...
|
||||
codestart = r"^<<(.*?)>>="
|
||||
codeend = r"^@(\s*)$"
|
||||
state = "doc"
|
||||
|
||||
docno = 1
|
||||
codeno = 1
|
||||
content = ""
|
||||
lineno = 0
|
||||
start_line = 0
|
||||
|
||||
options = Dict()
|
||||
optionstring = ""
|
||||
parsed = Dict[]
|
||||
for (lineno, line) in enumerate(split(doctext, "\n"))
|
||||
|
||||
if ismatch(codestart, line) && state=="doc"
|
||||
state = "code"
|
||||
m = match(codestart, line)
|
||||
optionstring=m.captures[1]
|
||||
#println(m.captures[1])
|
||||
if strip(optionstring)==""
|
||||
options = StrD()
|
||||
else
|
||||
try
|
||||
options = eval(parse("{" * optionstring * "}"))
|
||||
catch
|
||||
options = StrD()
|
||||
warn(string("Invalid format for chunk options line: ", lineno))
|
||||
end
|
||||
end
|
||||
haskey(options, "label") && (options["name"] = options["label"])
|
||||
haskey(options, "name") || (options["name"] = nothing)
|
||||
|
||||
chunk = @compat Dict{ASCIIString,Any}("type" => "doc", "content"=> content,
|
||||
"number" => docno, "start_line"=>start_line)
|
||||
docno += 1
|
||||
start_line = lineno
|
||||
push!(parsed, chunk)
|
||||
content = ""
|
||||
continue
|
||||
end
|
||||
if ismatch(codeend, line) && state=="code"
|
||||
chunk = @compat Dict{ASCIIString,Any}("type" => "code", "content" => content,
|
||||
"number" => codeno, "options" => options,
|
||||
"optionstring" => optionstring,
|
||||
"start_line" => start_line)
|
||||
codeno+=1
|
||||
start_line = lineno
|
||||
content = ""
|
||||
state = "doc"
|
||||
push!(parsed, chunk)
|
||||
continue
|
||||
end
|
||||
|
||||
content *= "\n" * line
|
||||
end
|
||||
|
||||
#Remember the last chunk
|
||||
if content != ""
|
||||
chunk = @compat Dict{ASCIIString,Any}("type" => "doc", "content" => content,
|
||||
"number" => docno, "start_line" => lineno)
|
||||
push!(parsed, chunk)
|
||||
end
|
||||
|
||||
return parsed
|
||||
end
|
Loading…
Reference in New Issue