mirror of https://github.com/mpastell/Weave.jl
Fixes to Winston support
parent
00f45832b3
commit
bd4af9c326
|
@ -1,6 +1,6 @@
|
||||||
|
|
||||||
test.jl
|
test.jl
|
||||||
examples/*/*.png
|
examples/*/*.png
|
||||||
examples/*.md
|
examples/*.md
|
||||||
|
|
||||||
*.*~
|
*.*~
|
||||||
|
|
78
README.md
78
README.md
|
@ -1,39 +1,39 @@
|
||||||
# JuliaReport
|
# JuliaReport
|
||||||
|
|
||||||
[![Build Status](https://travis-ci.org/mpastell/JuliaReport.jl.svg?branch=master)](https://travis-ci.org/mpastell/JuliaReport.jl)
|
[![Build Status](https://travis-ci.org/mpastell/JuliaReport.jl.svg?branch=master)](https://travis-ci.org/mpastell/JuliaReport.jl)
|
||||||
|
|
||||||
JuliaReport is a scientific report generator/literate programming tool
|
JuliaReport is a scientific report generator/literate programming tool
|
||||||
for Julia. It is based on [Pweave](http://mpastell.com/pweave) and
|
for Julia. It is based on [Pweave](http://mpastell.com/pweave) and
|
||||||
resembles Knitr and Sweave. Actually JuliaReport relies on Pweave for
|
resembles Knitr and Sweave. Actually JuliaReport relies on Pweave for
|
||||||
document parsing and formatting.
|
document parsing and formatting.
|
||||||
|
|
||||||
You'll need latest Pweave from Github: <https://github.com/mpastell/Pweave.>
|
You'll need latest Pweave from Github: <https://github.com/mpastell/Pweave.>
|
||||||
|
|
||||||
**Current features**
|
**Current features**
|
||||||
|
|
||||||
* Noweb syntax for documents.
|
* Noweb syntax for documents.
|
||||||
* Execute code as terminal or "script" chunks.
|
* Execute code as terminal or "script" chunks.
|
||||||
* Capture PyPlot figures.
|
* Capture PyPlot figures.
|
||||||
* All Pweave output formats supported. Including, Latex, Markdown, Sphinx etc.
|
* All Pweave output formats supported. Including, Latex, Markdown, Sphinx etc.
|
||||||
|
|
||||||
**Not implemented**
|
**Not implemented**
|
||||||
|
|
||||||
* Script reader
|
* Script reader
|
||||||
* Inline code
|
* Inline code
|
||||||
* Caching
|
* Caching
|
||||||
|
|
||||||
## Chunk options
|
## Chunk options
|
||||||
|
|
||||||
You can use the same chunk options as for Pweave, but the format is different.
|
You can use the same chunk options as for Pweave, but the format is different.
|
||||||
The syntax needs to be valid for creating a dictionary in Julia
|
The syntax needs to be valid for creating a dictionary in Julia
|
||||||
without the `{}`. e.g:
|
without the `{}`. e.g:
|
||||||
|
|
||||||
<<"term"=>true, "fig"=>false>>=
|
<<"term"=>true, "fig"=>false>>=
|
||||||
|
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
Run from julia:
|
Run from julia:
|
||||||
|
|
||||||
using JuliaReport
|
using JuliaReport
|
||||||
weave(Pkg.dir("JuliaReport","examples","julia_sample.mdw")
|
weave(Pkg.dir("JuliaReport","examples","julia_sample.mdw")
|
||||||
|
|
|
@ -1,26 +1,26 @@
|
||||||
const rcParams = {"figdir"=> "figures",
|
const rcParams = {"figdir"=> "figures",
|
||||||
"plotlib" => "Winston",
|
"plotlib" => "Winston",
|
||||||
"storeresults"=> false,
|
"storeresults"=> false,
|
||||||
"cachedir"=> "cache",
|
"cachedir"=> "cache",
|
||||||
"chunk"=>
|
"chunk"=>
|
||||||
{"defaultoptions"=>
|
{"defaultoptions"=>
|
||||||
{
|
{
|
||||||
"echo"=> true,
|
"echo"=> true,
|
||||||
"results"=> "verbatim",
|
"results"=> "verbatim",
|
||||||
"fig"=> true,
|
"fig"=> true,
|
||||||
"include"=> true,
|
"include"=> true,
|
||||||
"evaluate"=> true,
|
"evaluate"=> true,
|
||||||
"caption"=> false,
|
"caption"=> false,
|
||||||
"term"=> false,
|
"term"=> false,
|
||||||
"name"=> nothing,
|
"name"=> nothing,
|
||||||
"wrap"=> true,
|
"wrap"=> true,
|
||||||
"f_pos"=> "htpb",
|
"f_pos"=> "htpb",
|
||||||
"f_size"=> (8, 6),
|
"f_size"=> (8, 6),
|
||||||
"f_env"=> nothing,
|
"f_env"=> nothing,
|
||||||
"f_spines"=> true,
|
"f_spines"=> true,
|
||||||
"complete"=> true,
|
"complete"=> true,
|
||||||
"engine"=> "julia",
|
"engine"=> "julia",
|
||||||
"option_string"=> ""
|
"option_string"=> ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
130
src/readers.jl
130
src/readers.jl
|
@ -1,65 +1,65 @@
|
||||||
function read_noweb(document)
|
function read_noweb(document)
|
||||||
doctext = readall(open(document))
|
doctext = readall(open(document))
|
||||||
#doctext = document #Replace with file...
|
#doctext = document #Replace with file...
|
||||||
codestart = r"^<<(.*?)>>="
|
codestart = r"^<<(.*?)>>="
|
||||||
codeend = r"^@(\s*)$"
|
codeend = r"^@(\s*)$"
|
||||||
state = "doc"
|
state = "doc"
|
||||||
|
|
||||||
docno = 1
|
docno = 1
|
||||||
codeno = 1
|
codeno = 1
|
||||||
content = ""
|
content = ""
|
||||||
lineno = 0
|
lineno = 0
|
||||||
start_line = 0
|
start_line = 0
|
||||||
|
|
||||||
options = Dict()
|
options = Dict()
|
||||||
optionstring = ""
|
optionstring = ""
|
||||||
parsed = Dict[]
|
parsed = Dict[]
|
||||||
for (lineno, line) in enumerate(split(doctext, "\n"))
|
for (lineno, line) in enumerate(split(doctext, "\n"))
|
||||||
|
|
||||||
if ismatch(codestart, line) && state=="doc"
|
if ismatch(codestart, line) && state=="doc"
|
||||||
state = "code"
|
state = "code"
|
||||||
m = match(codestart, line)
|
m = match(codestart, line)
|
||||||
optionstring=m.captures[1]
|
optionstring=m.captures[1]
|
||||||
#println(m.captures[1])
|
#println(m.captures[1])
|
||||||
if strip(optionstring)==""
|
if strip(optionstring)==""
|
||||||
options = Dict()
|
options = Dict()
|
||||||
else
|
else
|
||||||
try
|
try
|
||||||
options = eval(parse("{" * optionstring * "}"))
|
options = eval(parse("{" * optionstring * "}"))
|
||||||
catch
|
catch
|
||||||
options = Dict()
|
options = Dict()
|
||||||
warn(string("Invalid format for chunk options line: ", lineno))
|
warn(string("Invalid format for chunk options line: ", lineno))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
haskey(options, "label") && (options["name"] = options["label"])
|
haskey(options, "label") && (options["name"] = options["label"])
|
||||||
haskey(options, "name") || (options["name"] = nothing)
|
haskey(options, "name") || (options["name"] = nothing)
|
||||||
|
|
||||||
chunk = {"type" => "doc", "content"=> content, "number" => docno, "start_line"=>start_line}
|
chunk = {"type" => "doc", "content"=> content, "number" => docno, "start_line"=>start_line}
|
||||||
docno += 1
|
docno += 1
|
||||||
start_line = lineno
|
start_line = lineno
|
||||||
push!(parsed, chunk)
|
push!(parsed, chunk)
|
||||||
content = ""
|
content = ""
|
||||||
continue
|
continue
|
||||||
end
|
end
|
||||||
if ismatch(codeend, line) && state=="code"
|
if ismatch(codeend, line) && state=="code"
|
||||||
chunk = {"type" => "code", "content" => content, "number" => codeno,
|
chunk = {"type" => "code", "content" => content, "number" => codeno,
|
||||||
"options"=>options,"optionstring"=>optionstring, "start_line"=>start_line}
|
"options"=>options,"optionstring"=>optionstring, "start_line"=>start_line}
|
||||||
codeno+=1
|
codeno+=1
|
||||||
start_line = lineno
|
start_line = lineno
|
||||||
content = ""
|
content = ""
|
||||||
state = "doc"
|
state = "doc"
|
||||||
push!(parsed, chunk)
|
push!(parsed, chunk)
|
||||||
continue
|
continue
|
||||||
end
|
end
|
||||||
|
|
||||||
content *= "\n" * line
|
content *= "\n" * line
|
||||||
end
|
end
|
||||||
|
|
||||||
#Remember the last chunk
|
#Remember the last chunk
|
||||||
if content != ""
|
if content != ""
|
||||||
chunk = {"type" => "doc", "content"=> content, "number" => docno, "start_line"=>lineno}
|
chunk = {"type" => "doc", "content"=> content, "number" => docno, "start_line"=>lineno}
|
||||||
push!(parsed, chunk)
|
push!(parsed, chunk)
|
||||||
end
|
end
|
||||||
|
|
||||||
return parsed
|
return parsed
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue