mirror of https://github.com/mpastell/Weave.jl
Fixes to Winston support
parent
00f45832b3
commit
bd4af9c326
|
@ -1,6 +1,6 @@
|
|||
|
||||
test.jl
|
||||
examples/*/*.png
|
||||
examples/*.md
|
||||
|
||||
*.*~
|
||||
|
||||
test.jl
|
||||
examples/*/*.png
|
||||
examples/*.md
|
||||
|
||||
*.*~
|
||||
|
|
78
README.md
78
README.md
|
@ -1,39 +1,39 @@
|
|||
# JuliaReport
|
||||
|
||||
[![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
|
||||
for Julia. It is based on [Pweave](http://mpastell.com/pweave) and
|
||||
resembles Knitr and Sweave. Actually JuliaReport relies on Pweave for
|
||||
document parsing and formatting.
|
||||
|
||||
You'll need latest Pweave from Github: <https://github.com/mpastell/Pweave.>
|
||||
|
||||
**Current features**
|
||||
|
||||
* Noweb syntax for documents.
|
||||
* Execute code as terminal or "script" chunks.
|
||||
* Capture PyPlot figures.
|
||||
* All Pweave output formats supported. Including, Latex, Markdown, Sphinx etc.
|
||||
|
||||
**Not implemented**
|
||||
|
||||
* Script reader
|
||||
* Inline code
|
||||
* Caching
|
||||
|
||||
## Chunk options
|
||||
|
||||
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
|
||||
without the `{}`. e.g:
|
||||
|
||||
<<"term"=>true, "fig"=>false>>=
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
Run from julia:
|
||||
|
||||
using JuliaReport
|
||||
weave(Pkg.dir("JuliaReport","examples","julia_sample.mdw")
|
||||
# JuliaReport
|
||||
|
||||
[![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
|
||||
for Julia. It is based on [Pweave](http://mpastell.com/pweave) and
|
||||
resembles Knitr and Sweave. Actually JuliaReport relies on Pweave for
|
||||
document parsing and formatting.
|
||||
|
||||
You'll need latest Pweave from Github: <https://github.com/mpastell/Pweave.>
|
||||
|
||||
**Current features**
|
||||
|
||||
* Noweb syntax for documents.
|
||||
* Execute code as terminal or "script" chunks.
|
||||
* Capture PyPlot figures.
|
||||
* All Pweave output formats supported. Including, Latex, Markdown, Sphinx etc.
|
||||
|
||||
**Not implemented**
|
||||
|
||||
* Script reader
|
||||
* Inline code
|
||||
* Caching
|
||||
|
||||
## Chunk options
|
||||
|
||||
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
|
||||
without the `{}`. e.g:
|
||||
|
||||
<<"term"=>true, "fig"=>false>>=
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
Run from julia:
|
||||
|
||||
using JuliaReport
|
||||
weave(Pkg.dir("JuliaReport","examples","julia_sample.mdw")
|
||||
|
|
|
@ -1,26 +1,26 @@
|
|||
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 = {"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"=> ""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
130
src/readers.jl
130
src/readers.jl
|
@ -1,65 +1,65 @@
|
|||
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 = 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
|
||||
|
|
Loading…
Reference in New Issue