Conflicts:
	REQUIRE
	src/config.jl
	src/readers.jl
pull/8/head
Matti Pastell 2014-12-01 22:53:13 +02:00
commit 5d95c806d5
4 changed files with 100 additions and 93 deletions

View File

@ -1 +1,2 @@
PyPlot
PyPlot
Compat

View File

@ -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

View File

@ -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"=> "")
)
)

View File

@ -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