mirror of https://github.com/mpastell/Weave.jl
Merge branch 'master' of https://github.com/mpastell/Weave.jl
commit
f8978eb560
|
@ -54,7 +54,7 @@ elseif args["out_path"] == ":pwd"
|
||||||
end
|
end
|
||||||
|
|
||||||
for (key, val) in args
|
for (key, val) in args
|
||||||
push!(args_col, (parse(key), val))
|
push!(args_col, (Meta.parse(key), val))
|
||||||
end
|
end
|
||||||
|
|
||||||
for s=source
|
for s=source
|
||||||
|
|
|
@ -10,12 +10,12 @@ weave("../examples/gadfly_md_sample.jmd",
|
||||||
informat="markdown", out_path = "build/examples", doctype = "md2pdf")
|
informat="markdown", out_path = "build/examples", doctype = "md2pdf")
|
||||||
|
|
||||||
cp("../examples/gadfly_md_sample.jmd",
|
cp("../examples/gadfly_md_sample.jmd",
|
||||||
"build/examples/gadfly_md_sample.jmd", remove_destination = true)
|
"build/examples/gadfly_md_sample.jmd", force = true)
|
||||||
|
|
||||||
cp("build/examples/gadfly_md_sample.md",
|
cp("build/examples/gadfly_md_sample.md",
|
||||||
"build/examples/gadfly_md_sample.txt", remove_destination = true)
|
"build/examples/gadfly_md_sample.txt", force = true)
|
||||||
|
|
||||||
weave("../examples/FIR_design.jl", out_path = "build/examples")
|
weave("../examples/FIR_design.jl", out_path = "build/examples")
|
||||||
weave("../examples/FIR_design.jl", doctype = "md2pdf", out_path = "build/examples")
|
weave("../examples/FIR_design.jl", doctype = "md2pdf", out_path = "build/examples")
|
||||||
cp("../examples/FIR_design.jl",
|
cp("../examples/FIR_design.jl",
|
||||||
"build/examples/FIR_design.jl", remove_destination = true)
|
"build/examples/FIR_design.jl", force = true)
|
||||||
|
|
|
@ -34,9 +34,9 @@
|
||||||
|
|
||||||
using Gadfly, DSP
|
using Gadfly, DSP
|
||||||
|
|
||||||
function FIRfreqz(b::Array, w = linspace(0, π, 1024))
|
function FIRfreqz(b::Array, w = range(0, stop=π, length=1024))
|
||||||
n = length(w)
|
n = length(w)
|
||||||
h = Array{Complex64}(n)
|
h = Array{ComplexF32}(n)
|
||||||
sw = 0
|
sw = 0
|
||||||
for i = 1:n
|
for i = 1:n
|
||||||
for j = 1:length(b)
|
for j = 1:length(b)
|
||||||
|
@ -60,7 +60,7 @@ end
|
||||||
|
|
||||||
fs = 20
|
fs = 20
|
||||||
f = digitalfilter(Lowpass(5, fs = fs), FIRWindow(hamming(61)))
|
f = digitalfilter(Lowpass(5, fs = fs), FIRWindow(hamming(61)))
|
||||||
w = linspace(0, pi, 1024)
|
w = range(0, stop=pi, length=1024)
|
||||||
h = FIRfreqz(f, w)
|
h = FIRfreqz(f, w)
|
||||||
|
|
||||||
#' ## Plot the frequency and impulse response
|
#' ## Plot the frequency and impulse response
|
||||||
|
@ -78,6 +78,6 @@ plot(y = h_db, x = ws, Geom.line,
|
||||||
|
|
||||||
#' And again with default options
|
#' And again with default options
|
||||||
|
|
||||||
h_phase = unwrap(-atan2(imag(h),real(h)))
|
h_phase = unwrap(-atan(imag(h),real(h)))
|
||||||
plot(y = h_phase, x = ws, Geom.line,
|
plot(y = h_phase, x = ws, Geom.line,
|
||||||
Guide.xlabel("Frequency (Hz)"), Guide.ylabel("Phase (radians)"))
|
Guide.xlabel("Frequency (Hz)"), Guide.ylabel("Phase (radians)"))
|
||||||
|
|
|
@ -33,9 +33,9 @@
|
||||||
using Plots, DSP
|
using Plots, DSP
|
||||||
plotly()
|
plotly()
|
||||||
|
|
||||||
function FIRfreqz(b::Array, w = linspace(0, π, 1024))
|
function FIRfreqz(b::Array, w = range(0, stop=π, length=1024))
|
||||||
n = length(w)
|
n = length(w)
|
||||||
h = Array{Complex64}(n)
|
h = Array{ComplexF32}(n)
|
||||||
sw = 0
|
sw = 0
|
||||||
for i = 1:n
|
for i = 1:n
|
||||||
for j = 1:length(b)
|
for j = 1:length(b)
|
||||||
|
@ -60,7 +60,7 @@ end
|
||||||
|
|
||||||
fs = 20
|
fs = 20
|
||||||
f = digitalfilter(Lowpass(5, fs = fs), FIRWindow(hamming(61)))
|
f = digitalfilter(Lowpass(5, fs = fs), FIRWindow(hamming(61)))
|
||||||
w = linspace(0, pi, 1024)
|
w = range(0, stop=pi, length=1024)
|
||||||
h = FIRfreqz(f, w)
|
h = FIRfreqz(f, w)
|
||||||
|
|
||||||
#' ## Plot the frequency and impulse response
|
#' ## Plot the frequency and impulse response
|
||||||
|
@ -78,6 +78,6 @@ plot(ws, h_db,
|
||||||
|
|
||||||
#' And again with default options
|
#' And again with default options
|
||||||
|
|
||||||
h_phase = unwrap(-atan2(imag(h),real(h)))
|
h_phase = unwrap(-atan(imag(h),real(h)))
|
||||||
plot(ws, h_phase,
|
plot(ws, h_phase,
|
||||||
xlabel = "Frequency (Hz)", ylabel = "Phase (radians)")
|
xlabel = "Frequency (Hz)", ylabel = "Phase (radians)")
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
module Markdown2HTML
|
module Markdown2HTML
|
||||||
# Markdown to HTML writer, Modified from Julia Base.Markdown html writer
|
# Markdown to HTML writer, Modified from Julia Base.Markdown html writer
|
||||||
using Base.Markdown: MD, Header, Code, Paragraph, BlockQuote, Footnote,
|
using Markdown: MD, Header, Code, Paragraph, BlockQuote, Footnote,
|
||||||
Admonition, List, HorizontalRule, Bold, Italic, Image, Link, LineBreak,
|
Admonition, List, HorizontalRule, Bold, Italic, Image, Link, LineBreak,
|
||||||
LaTeX, isordered
|
LaTeX, isordered
|
||||||
|
|
||||||
|
|
|
@ -125,7 +125,7 @@ function weave(source ; doctype = :auto, plotlib=:auto,
|
||||||
doc.cwd == pwd() && (outname = basename(outname))
|
doc.cwd == pwd() && (outname = basename(outname))
|
||||||
info("Report weaved to $outname")
|
info("Report weaved to $outname")
|
||||||
catch e
|
catch e
|
||||||
warn("Something went wrong during weaving")
|
@warn("Something went wrong during weaving")
|
||||||
println(e)
|
println(e)
|
||||||
finally
|
finally
|
||||||
doctype == :auto && (doctype = detect_doctype(doc.source))
|
doctype == :auto && (doctype = detect_doctype(doc.source))
|
||||||
|
@ -162,9 +162,9 @@ function notebook(source::String, out_path=:pwd, timeout=-1)
|
||||||
write(f, converted)
|
write(f, converted)
|
||||||
end
|
end
|
||||||
|
|
||||||
info("Running nbconvert")
|
@info("Running nbconvert")
|
||||||
eval(parse("using IJulia"))
|
eval(Meta.parse("using IJulia"))
|
||||||
out = readstring(`$(IJulia.jupyter)-nbconvert --ExecutePreprocessor.timeout=$timeout --to notebook --execute $outfile --output $outfile`)
|
out = read(`$(IJulia.jupyter)-nbconvert --ExecutePreprocessor.timeout=$timeout --to notebook --execute $outfile --output $outfile`, String)
|
||||||
end
|
end
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
using Compat
|
using Compat
|
||||||
|
|
||||||
#Contains report global properties
|
#Contains report global properties
|
||||||
mutable struct Report <: Display
|
mutable struct Report <: AbstractDisplay
|
||||||
cwd::AbstractString
|
cwd::AbstractString
|
||||||
basename::AbstractString
|
basename::AbstractString
|
||||||
formatdict::Dict{Symbol,Any}
|
formatdict::Dict{Symbol,Any}
|
||||||
|
@ -69,7 +69,7 @@ function Base.display(report::Report, m::MIME"text/plain", data)
|
||||||
io = PipeBuffer()
|
io = PipeBuffer()
|
||||||
show(IOContext(io, :limit => true), m, data)
|
show(IOContext(io, :limit => true), m, data)
|
||||||
flush(io)
|
flush(io)
|
||||||
s = readstring(io)
|
s = read(io, String)
|
||||||
close(io)
|
close(io)
|
||||||
println(s)
|
println(s)
|
||||||
end
|
end
|
||||||
|
@ -90,18 +90,18 @@ end
|
||||||
|
|
||||||
#Catch "rich_output"
|
#Catch "rich_output"
|
||||||
function Base.display(report::Report, m::MIME"text/html", data)
|
function Base.display(report::Report, m::MIME"text/html", data)
|
||||||
s = reprmime(m, data)
|
s = repr(m, data)
|
||||||
report.rich_output *= "\n" * s
|
report.rich_output *= "\n" * s
|
||||||
end
|
end
|
||||||
|
|
||||||
#Catch "rich_output"
|
#Catch "rich_output"
|
||||||
function Base.display(report::Report, m::MIME"text/markdown", data)
|
function Base.display(report::Report, m::MIME"text/markdown", data)
|
||||||
s = reprmime(m, data)
|
s = repr(m, data)
|
||||||
report.rich_output *= "\n" * s
|
report.rich_output *= "\n" * s
|
||||||
end
|
end
|
||||||
|
|
||||||
function Base.display(report::Report, m::MIME"text/latex", data)
|
function Base.display(report::Report, m::MIME"text/latex", data)
|
||||||
s = reprmime(m, data)
|
s = repr(m, data)
|
||||||
report.rich_output *= "\n" * s
|
report.rich_output *= "\n" * s
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import Mustache, Highlights
|
import Mustache, Highlights
|
||||||
import .Markdown2HTML
|
import .Markdown2HTML
|
||||||
using Compat
|
using Compat
|
||||||
|
using Dates
|
||||||
|
|
||||||
function format(doc::WeaveDoc)
|
function format(doc::WeaveDoc)
|
||||||
formatted = AbstractString[]
|
formatted = AbstractString[]
|
||||||
|
@ -50,7 +51,7 @@ function stylesheet(m::MIME, theme)
|
||||||
buf = PipeBuffer()
|
buf = PipeBuffer()
|
||||||
Highlights.stylesheet(buf, m, theme)
|
Highlights.stylesheet(buf, m, theme)
|
||||||
flush(buf)
|
flush(buf)
|
||||||
style = readstring(buf)
|
style = read(buf, String)
|
||||||
close(buf)
|
close(buf)
|
||||||
return style
|
return style
|
||||||
end
|
end
|
||||||
|
@ -59,13 +60,14 @@ function render_doc(formatted, doc::WeaveDoc, format::JMarkdown2HTML)
|
||||||
css = stylesheet(MIME("text/html"), doc.highlight_theme)
|
css = stylesheet(MIME("text/html"), doc.highlight_theme)
|
||||||
title, author, date = get_titleblock(doc)
|
title, author, date = get_titleblock(doc)
|
||||||
path, wsource = splitdir(abspath(doc.source))
|
path, wsource = splitdir(abspath(doc.source))
|
||||||
wversion = string(Pkg.installed("Weave"))
|
#wversion = string(Pkg.installed("Weave"))
|
||||||
|
wversion = ""
|
||||||
wtime = string(Date(now()))
|
wtime = string(Date(now()))
|
||||||
|
|
||||||
if isempty(doc.css)
|
if isempty(doc.css)
|
||||||
theme_css = readstring(joinpath(dirname(@__FILE__), "../templates/skeleton_css.css"))
|
theme_css = read(joinpath(dirname(@__FILE__), "../templates/skeleton_css.css"), String)
|
||||||
else
|
else
|
||||||
theme_css = readstring(doc.css)
|
theme_css = read(doc.css, String)
|
||||||
end
|
end
|
||||||
|
|
||||||
if isempty(doc.template)
|
if isempty(doc.template)
|
||||||
|
@ -86,7 +88,8 @@ function render_doc(formatted, doc::WeaveDoc, format::JMarkdown2tex)
|
||||||
title, author, date = get_titleblock(doc)
|
title, author, date = get_titleblock(doc)
|
||||||
|
|
||||||
path, wsource = splitdir(abspath(doc.source))
|
path, wsource = splitdir(abspath(doc.source))
|
||||||
wversion = string(Pkg.installed("Weave"))
|
#wversion = string(Pkg.installed("Weave"))
|
||||||
|
wversion = ""
|
||||||
wtime = string(Date(now()))
|
wtime = string(Date(now()))
|
||||||
|
|
||||||
if isempty(doc.template)
|
if isempty(doc.template)
|
||||||
|
@ -108,7 +111,7 @@ function get_titleblock(doc::WeaveDoc)
|
||||||
end
|
end
|
||||||
|
|
||||||
function strip_header(chunk::DocChunk)
|
function strip_header(chunk::DocChunk)
|
||||||
if ismatch(r"^---$(?<header>.+)^---$"ms, chunk.content[1].content)
|
if occursin(r"^---$(?<header>.+)^---$"ms, chunk.content[1].content)
|
||||||
chunk.content[1].content = lstrip(replace(chunk.content[1].content, r"^---$(?<header>.+)^---$"ms, ""))
|
chunk.content[1].content = lstrip(replace(chunk.content[1].content, r"^---$(?<header>.+)^---$"ms, ""))
|
||||||
end
|
end
|
||||||
return chunk
|
return chunk
|
||||||
|
@ -247,7 +250,7 @@ function format_code(result::AbstractString, docformat::JMarkdown2HTML)
|
||||||
Highlights.highlight(buf, MIME("text/html"), strip(result),
|
Highlights.highlight(buf, MIME("text/html"), strip(result),
|
||||||
Highlights.Lexers.JuliaLexer, docformat.formatdict[:theme])
|
Highlights.Lexers.JuliaLexer, docformat.formatdict[:theme])
|
||||||
flush(buf)
|
flush(buf)
|
||||||
highlighted = readstring(buf)
|
highlighted = read(buf, String)
|
||||||
close(buf)
|
close(buf)
|
||||||
return highlighted
|
return highlighted
|
||||||
end
|
end
|
||||||
|
@ -257,7 +260,7 @@ function format_code(result::AbstractString, docformat::Pandoc2HTML)
|
||||||
Highlights.highlight(buf, MIME("text/html"), strip(result),
|
Highlights.highlight(buf, MIME("text/html"), strip(result),
|
||||||
Highlights.Lexers.JuliaLexer, docformat.formatdict[:theme])
|
Highlights.Lexers.JuliaLexer, docformat.formatdict[:theme])
|
||||||
flush(buf)
|
flush(buf)
|
||||||
highlighted = readstring(buf)
|
highlighted = read(buf, String)
|
||||||
close(buf)
|
close(buf)
|
||||||
return highlighted
|
return highlighted
|
||||||
end
|
end
|
||||||
|
@ -277,7 +280,7 @@ function format_termchunk(chunk, formatdict, docformat::JMarkdown2HTML)
|
||||||
buf = PipeBuffer()
|
buf = PipeBuffer()
|
||||||
Highlights.highlight(buf, MIME("text/html"), strip(chunk.output), Highlights.Lexers.JuliaConsoleLexer)
|
Highlights.highlight(buf, MIME("text/html"), strip(chunk.output), Highlights.Lexers.JuliaConsoleLexer)
|
||||||
flush(buf)
|
flush(buf)
|
||||||
result = readstring(buf)
|
result = read(buf, String)
|
||||||
close(buf)
|
close(buf)
|
||||||
else
|
else
|
||||||
result = ""
|
result = ""
|
||||||
|
@ -290,7 +293,7 @@ function format_termchunk(chunk, formatdict, docformat::Pandoc2HTML)
|
||||||
buf = PipeBuffer()
|
buf = PipeBuffer()
|
||||||
Highlights.highlight(buf, MIME("text/html"), strip(chunk.output), Highlights.Lexers.JuliaConsoleLexer)
|
Highlights.highlight(buf, MIME("text/html"), strip(chunk.output), Highlights.Lexers.JuliaConsoleLexer)
|
||||||
flush(buf)
|
flush(buf)
|
||||||
result = readstring(buf)
|
result = read(buf, String)
|
||||||
close(buf)
|
close(buf)
|
||||||
else
|
else
|
||||||
result = ""
|
result = ""
|
||||||
|
|
|
@ -424,7 +424,7 @@ function formatfigures(chunk, docformat::Hugo)
|
||||||
function format_shortcode(index_and_fig)
|
function format_shortcode(index_and_fig)
|
||||||
index, fig = index_and_fig
|
index, fig = index_and_fig
|
||||||
if index > 1
|
if index > 1
|
||||||
warn("Only the first figure gets a caption.")
|
@warn("Only the first figure gets a caption.")
|
||||||
title_spec = ""
|
title_spec = ""
|
||||||
else
|
else
|
||||||
caption = chunk.options[:fig_cap]
|
caption = chunk.options[:fig_cap]
|
||||||
|
|
|
@ -41,6 +41,6 @@ function Base.display(report::Report, m::MIME"image/svg+xml", p::Gadfly.Plot)
|
||||||
elseif format == ".tex"
|
elseif format == ".tex"
|
||||||
Gadfly.draw(Gadfly.PGF(full_name, w, h, true ), p)
|
Gadfly.draw(Gadfly.PGF(full_name, w, h, true ), p)
|
||||||
else
|
else
|
||||||
warn("Can't save figure. Unsupported format")
|
@warn("Can't save figure. Unsupported format")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -48,11 +48,11 @@ function pandoc2html(formatted::AbstractString, doc::WeaveDoc, outname::Abstract
|
||||||
-o $outname`)
|
-o $outname`)
|
||||||
println(pandoc_in, formatted)
|
println(pandoc_in, formatted)
|
||||||
close(pandoc_in)
|
close(pandoc_in)
|
||||||
proc_output = readstring(pandoc_out)
|
proc_output = read(pandoc_out, String)
|
||||||
cd(old_wd)
|
cd(old_wd)
|
||||||
catch e
|
catch e
|
||||||
cd(old_wd)
|
cd(old_wd)
|
||||||
warn("Error converting document to HTML")
|
@warn("Error converting document to HTML")
|
||||||
throw(e)
|
throw(e)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -84,7 +84,7 @@ function pandoc2pdf(formatted::AbstractString, doc::WeaveDoc, outname::AbstractS
|
||||||
citeproc = []
|
citeproc = []
|
||||||
end
|
end
|
||||||
|
|
||||||
info("Done executing code. Running xelatex")
|
@info("Done executing code. Running xelatex")
|
||||||
try
|
try
|
||||||
pandoc_out, pandoc_in, proc = readandwrite(`pandoc -R -s --latex-engine=xelatex --highlight-style=tango
|
pandoc_out, pandoc_in, proc = readandwrite(`pandoc -R -s --latex-engine=xelatex --highlight-style=tango
|
||||||
$filt $citeproc
|
$filt $citeproc
|
||||||
|
@ -93,11 +93,11 @@ function pandoc2pdf(formatted::AbstractString, doc::WeaveDoc, outname::AbstractS
|
||||||
println(pandoc_in, formatted)
|
println(pandoc_in, formatted)
|
||||||
|
|
||||||
close(pandoc_in)
|
close(pandoc_in)
|
||||||
proc_output = readstring(pandoc_out)
|
proc_output = read(pandoc_out, String)
|
||||||
cd(old_wd)
|
cd(old_wd)
|
||||||
catch e
|
catch e
|
||||||
cd(old_wd)
|
cd(old_wd)
|
||||||
warn("Error converting document to pdf")
|
@warn("Error converting document to pdf")
|
||||||
throw(e)
|
throw(e)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -110,7 +110,7 @@ function run_latex(doc::WeaveDoc, outname, latex_cmd = "xelatex")
|
||||||
try
|
try
|
||||||
textmp = mktempdir(".")
|
textmp = mktempdir(".")
|
||||||
#out = readstring(`$latex_cmd -shell-escape --output-directory=$textmp $xname`)
|
#out = readstring(`$latex_cmd -shell-escape --output-directory=$textmp $xname`)
|
||||||
out = readstring(`$latex_cmd -shell-escape $xname`)
|
out = read(`$latex_cmd -shell-escape $xname`, String)
|
||||||
#info(out)
|
#info(out)
|
||||||
#pdf = joinpath(textmp, "$(doc.basename).pdf")
|
#pdf = joinpath(textmp, "$(doc.basename).pdf")
|
||||||
#cp(pdf, "$(doc.basename).pdf", remove_destination=true)
|
#cp(pdf, "$(doc.basename).pdf", remove_destination=true)
|
||||||
|
@ -120,7 +120,7 @@ function run_latex(doc::WeaveDoc, outname, latex_cmd = "xelatex")
|
||||||
return true
|
return true
|
||||||
catch e
|
catch e
|
||||||
cd(old_wd)
|
cd(old_wd)
|
||||||
warn("Error converting document to pdf. Try running latex manually")
|
@warn("Error converting document to pdf. Try running latex manually")
|
||||||
return false
|
return false
|
||||||
#throw(e)
|
#throw(e)
|
||||||
end
|
end
|
||||||
|
|
|
@ -14,7 +14,7 @@ push_preexecute_hook(plots_set_size)
|
||||||
#PNG or SVG is not working, output html
|
#PNG or SVG is not working, output html
|
||||||
function Base.display(report::Report, m::MIME"image/svg+xml", data::Plots.Plot{Plots.PlotlyBackend})#
|
function Base.display(report::Report, m::MIME"image/svg+xml", data::Plots.Plot{Plots.PlotlyBackend})#
|
||||||
#Remove extra spaces from start of line for pandoc
|
#Remove extra spaces from start of line for pandoc
|
||||||
s = reprmime(MIME("text/html"), data)
|
s = repr(MIME("text/html"), data)
|
||||||
splitted = split(s, "\n")
|
splitted = split(s, "\n")
|
||||||
start = split(splitted[1], r"(?=<div)")
|
start = split(splitted[1], r"(?=<div)")
|
||||||
#script = lstrip(start[1]) #local
|
#script = lstrip(start[1]) #local
|
||||||
|
|
|
@ -53,7 +53,7 @@ end
|
||||||
"""Read and parse input document"""
|
"""Read and parse input document"""
|
||||||
function read_doc(source::AbstractString, format=:auto)
|
function read_doc(source::AbstractString, format=:auto)
|
||||||
format == :auto && (format = detect_informat(source))
|
format == :auto && (format = detect_informat(source))
|
||||||
document = readstring(source)
|
document = read(source, String)
|
||||||
document = replace(document, "\r\n", "\n")
|
document = replace(document, "\r\n", "\n")
|
||||||
parsed = parse_doc(document, format)
|
parsed = parse_doc(document, format)
|
||||||
header = parse_header(parsed[1])
|
header = parse_header(parsed[1])
|
||||||
|
@ -108,7 +108,7 @@ function parse_doc(document::AbstractString, format::MarkupInput)
|
||||||
|
|
||||||
options = Dict{Symbol,Any}()
|
options = Dict{Symbol,Any}()
|
||||||
if length(optionString) > 0
|
if length(optionString) > 0
|
||||||
expr = parse(optionString)
|
expr = Meta.parse(optionString)
|
||||||
Base.Meta.isexpr(expr,:(=)) && (options[expr.args[1]] = expr.args[2])
|
Base.Meta.isexpr(expr,:(=)) && (options[expr.args[1]] = expr.args[2])
|
||||||
Base.Meta.isexpr(expr,:toplevel) && map(pushopt,fill(options,length(expr.args)),expr.args)
|
Base.Meta.isexpr(expr,:toplevel) && map(pushopt,fill(options,length(expr.args)),expr.args)
|
||||||
end
|
end
|
||||||
|
@ -127,7 +127,7 @@ function parse_doc(document::AbstractString, format::MarkupInput)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
end
|
end
|
||||||
if ismatch(codeend, line) && state=="code"
|
if occursin(codeend, line) && state=="code"
|
||||||
|
|
||||||
chunk = CodeChunk(content, codeno, start_line, optionString, options)
|
chunk = CodeChunk(content, codeno, start_line, optionString, options)
|
||||||
|
|
||||||
|
@ -216,7 +216,7 @@ function parse_doc(document::AbstractString, format::ScriptInput)
|
||||||
#Get options
|
#Get options
|
||||||
options = Dict{Symbol,Any}()
|
options = Dict{Symbol,Any}()
|
||||||
if length(optionString) > 0
|
if length(optionString) > 0
|
||||||
expr = parse(optionString)
|
expr = Meta.parse(optionString)
|
||||||
Base.Meta.isexpr(expr,:(=)) && (options[expr.args[1]] = expr.args[2])
|
Base.Meta.isexpr(expr,:(=)) && (options[expr.args[1]] = expr.args[2])
|
||||||
Base.Meta.isexpr(expr,:toplevel) && map(pushopt,fill(options,length(expr.args)),expr.args)
|
Base.Meta.isexpr(expr,:toplevel) && map(pushopt,fill(options,length(expr.args)),expr.args)
|
||||||
end
|
end
|
||||||
|
@ -289,7 +289,7 @@ function parse_inline(text, noex)
|
||||||
end
|
end
|
||||||
|
|
||||||
function parse_inline(text::AbstractString, inline_ex::Regex)
|
function parse_inline(text::AbstractString, inline_ex::Regex)
|
||||||
ismatch(inline_ex, text) || return Inline[InlineText(text, 1, length(text), 1)]
|
occursin(inline_ex, text) || return Inline[InlineText(text, 1, length(text), 1)]
|
||||||
|
|
||||||
inline_chunks = eachmatch(inline_ex, text)
|
inline_chunks = eachmatch(inline_ex, text)
|
||||||
s = 1
|
s = 1
|
||||||
|
|
18
src/run.jl
18
src/run.jl
|
@ -40,15 +40,15 @@ function Base.run(doc::WeaveDoc; doctype = :auto, plotlib=:auto,
|
||||||
cache == :off || @eval import FileIO, JLD2
|
cache == :off || @eval import FileIO, JLD2
|
||||||
|
|
||||||
#This is needed for latex and should work on all output formats
|
#This is needed for latex and should work on all output formats
|
||||||
is_windows() && (fig_path = replace(fig_path, "\\", "/"))
|
Sys.iswindows() && (fig_path = replace(fig_path, "\\", "/"))
|
||||||
|
|
||||||
doc.fig_path = fig_path
|
doc.fig_path = fig_path
|
||||||
set_rc_params(doc.format.formatdict, fig_path, fig_ext)
|
set_rc_params(doc.format.formatdict, fig_path, fig_ext)
|
||||||
|
|
||||||
#New sandbox for each document with args exposed
|
#New sandbox for each document with args exposed
|
||||||
sandbox = "ReportSandBox$(rcParams[:doc_number])"
|
sandbox = "ReportSandBox$(rcParams[:doc_number])"
|
||||||
eval(parse("module $sandbox\nWEAVE_ARGS=Dict()\nend"))
|
eval(Meta.parse("module $sandbox\nWEAVE_ARGS=Dict()\nend"))
|
||||||
SandBox = eval(parse(sandbox))
|
SandBox = eval(Meta.parse(sandbox))
|
||||||
merge!(SandBox.WEAVE_ARGS, args)
|
merge!(SandBox.WEAVE_ARGS, args)
|
||||||
rcParams[:doc_number] += 1
|
rcParams[:doc_number] += 1
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ function Base.run(doc::WeaveDoc; doctype = :auto, plotlib=:auto,
|
||||||
|
|
||||||
if cache != :off && cache != :refresh
|
if cache != :off && cache != :refresh
|
||||||
cached = read_cache(doc, cache_path)
|
cached = read_cache(doc, cache_path)
|
||||||
cached == nothing && info("No cached results found, running code")
|
cached == nothing && @info("No cached results found, running code")
|
||||||
else
|
else
|
||||||
cached = nothing
|
cached = nothing
|
||||||
end
|
end
|
||||||
|
@ -324,9 +324,9 @@ end
|
||||||
|
|
||||||
#Set all variables to nothing
|
#Set all variables to nothing
|
||||||
function clear_sandbox(SandBox::Module)
|
function clear_sandbox(SandBox::Module)
|
||||||
for name = names(SandBox, true)
|
for name = names(SandBox, all=true)
|
||||||
if name != :eval && name != names(SandBox)[1]
|
if name != :eval && name != names(SandBox)[1]
|
||||||
try eval(SandBox, parse(AbstractString(AbstractString(name), "=nothing"))) end
|
try eval(SandBox, Meta.parse(AbstractString(AbstractString(name), "=nothing"))) catch; end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -356,13 +356,13 @@ function init_plotting(plotlib)
|
||||||
rcParams[:chunk_defaults][:fig] = true
|
rcParams[:chunk_defaults][:fig] = true
|
||||||
|
|
||||||
if l_plotlib == "pyplot"
|
if l_plotlib == "pyplot"
|
||||||
eval(parse("""include("$srcdir/pyplot.jl")"""))
|
eval(Meta.parse("""include("$srcdir/pyplot.jl")"""))
|
||||||
rcParams[:plotlib] = "PyPlot"
|
rcParams[:plotlib] = "PyPlot"
|
||||||
elseif l_plotlib == "plots"
|
elseif l_plotlib == "plots"
|
||||||
eval(parse("""include("$srcdir/plots.jl")"""))
|
eval(Meta.parse("""include("$srcdir/plots.jl")"""))
|
||||||
rcParams[:plotlib] = "Plots"
|
rcParams[:plotlib] = "Plots"
|
||||||
elseif l_plotlib == "gadfly"
|
elseif l_plotlib == "gadfly"
|
||||||
eval(parse("""include("$srcdir/gadfly.jl")"""))
|
eval(Meta.parse("""include("$srcdir/gadfly.jl")"""))
|
||||||
rcParams[:plotlib] = "Gadfly"
|
rcParams[:plotlib] = "Gadfly"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,33 +1,33 @@
|
||||||
using Weave
|
using Weave
|
||||||
using Base.Test
|
using Test
|
||||||
|
|
||||||
#Test if running document with and without cache works
|
#Test if running document with and without cache works
|
||||||
isdir("documents/cache") && rm("documents/cache", recursive = true)
|
isdir("documents/cache") && rm("documents/cache", recursive = true)
|
||||||
weave("documents/chunk_options.noweb", plotlib=nothing, cache=:all)
|
weave("documents/chunk_options.noweb", plotlib=nothing, cache=:all)
|
||||||
result = readstring("documents/chunk_options.md")
|
result = read("documents/chunk_options.md", String)
|
||||||
rm("documents/chunk_options.md")
|
rm("documents/chunk_options.md")
|
||||||
weave("documents/chunk_options.noweb", plotlib=nothing, cache=:all)
|
weave("documents/chunk_options.noweb", plotlib=nothing, cache=:all)
|
||||||
cached_result = readstring("documents/chunk_options.md")
|
cached_result = read("documents/chunk_options.md", String)
|
||||||
@test result == cached_result
|
@test result == cached_result
|
||||||
|
|
||||||
# cache = :user
|
# cache = :user
|
||||||
isdir("documents/cache") && rm("documents/cache", recursive = true)
|
isdir("documents/cache") && rm("documents/cache", recursive = true)
|
||||||
out = "documents/chunk_cache.md"
|
out = "documents/chunk_cache.md"
|
||||||
Weave.weave("documents/chunk_cache.noweb", plotlib=nothing, cache=:user);
|
Weave.weave("documents/chunk_cache.noweb", plotlib=nothing, cache=:user);
|
||||||
result = readstring(out)
|
result = read(out, String)
|
||||||
rm(out)
|
rm(out)
|
||||||
Weave.weave("documents/chunk_cache.noweb", plotlib=nothing, cache=:user);
|
Weave.weave("documents/chunk_cache.noweb", plotlib=nothing, cache=:user);
|
||||||
cached_result = readstring(out)
|
cached_result = read(out, String)
|
||||||
@test result == cached_result
|
@test result == cached_result
|
||||||
|
|
||||||
# cache = :all
|
# cache = :all
|
||||||
isdir("documents/cache") && rm("documents/cache", recursive = true)
|
isdir("documents/cache") && rm("documents/cache", recursive = true)
|
||||||
out = "documents/chunk_cache.md"
|
out = "documents/chunk_cache.md"
|
||||||
Weave.weave("documents/chunk_cache.noweb", cache=:all);
|
Weave.weave("documents/chunk_cache.noweb", cache=:all);
|
||||||
result = readstring(out)
|
result = read(out, String)
|
||||||
rm(out)
|
rm(out)
|
||||||
Weave.weave("documents/chunk_cache.noweb", cache=:all);
|
Weave.weave("documents/chunk_cache.noweb", cache=:all);
|
||||||
cached_result = readstring(out)
|
cached_result = read(out, String)
|
||||||
@test result == cached_result
|
@test result == cached_result
|
||||||
|
|
||||||
|
|
||||||
|
@ -37,9 +37,9 @@ if VERSION.minor == 5
|
||||||
isdir("documents/cache") && rm("documents/cache", recursive = true)
|
isdir("documents/cache") && rm("documents/cache", recursive = true)
|
||||||
#Caching with Gadfly
|
#Caching with Gadfly
|
||||||
weave("documents/gadfly_formats_test.txt", doctype="tex", plotlib="gadfly", cache=:all)
|
weave("documents/gadfly_formats_test.txt", doctype="tex", plotlib="gadfly", cache=:all)
|
||||||
result = readstring("documents/gadfly_formats_test.tex")
|
result = read("documents/gadfly_formats_test.tex", String)
|
||||||
rm("documents/gadfly_formats_test.tex")
|
rm("documents/gadfly_formats_test.tex")
|
||||||
weave("documents/gadfly_formats_test.txt", doctype="tex", plotlib="gadfly", cache=:all)
|
weave("documents/gadfly_formats_test.txt", doctype="tex", plotlib="gadfly", cache=:all)
|
||||||
cached_result = readstring("documents/gadfly_formats_test.tex")
|
cached_result = read("documents/gadfly_formats_test.tex", String)
|
||||||
@test result == cached_result
|
@test result == cached_result
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,19 +1,19 @@
|
||||||
using Weave
|
using Weave
|
||||||
using Base.Test
|
using Test
|
||||||
|
|
||||||
cleanup = true
|
cleanup = true
|
||||||
|
|
||||||
VER = "$(VERSION.major).$(VERSION.minor)"
|
VER = "$(VERSION.major).$(VERSION.minor)"
|
||||||
|
|
||||||
weave("documents/chunk_options.noweb", plotlib=nothing)
|
weave("documents/chunk_options.noweb", plotlib=nothing)
|
||||||
result = readstring("documents/chunk_options.md")
|
result = read("documents/chunk_options.md", String)
|
||||||
ref = readstring("documents/$VER/chunk_options_ref.md")
|
ref = read("documents/$VER/chunk_options_ref.md", String)
|
||||||
@test result == ref
|
@test result == ref
|
||||||
cleanup && rm("documents/chunk_options.md")
|
cleanup && rm("documents/chunk_options.md")
|
||||||
|
|
||||||
|
|
||||||
tangle("documents/chunk_options.noweb", out_path = "documents/tangle")
|
tangle("documents/chunk_options.noweb", out_path = "documents/tangle")
|
||||||
result = readstring("documents/tangle/chunk_options.jl")
|
result = read("documents/tangle/chunk_options.jl", String)
|
||||||
ref = readstring("documents/tangle/chunk_options.jl.ref")
|
ref = read("documents/tangle/chunk_options.jl.ref", String)
|
||||||
@test ref == result
|
@test ref == result
|
||||||
cleanup && rm("documents/tangle/chunk_options.jl")
|
cleanup && rm("documents/tangle/chunk_options.jl")
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
using Weave
|
using Weave
|
||||||
using Base.Test
|
using Test
|
||||||
|
|
||||||
cleanup = true
|
cleanup = true
|
||||||
|
|
||||||
#Test hold and term options
|
#Test hold and term options
|
||||||
weave("documents/test_hold.mdw", doctype="pandoc", plotlib="Gadfly")
|
weave("documents/test_hold.mdw", doctype="pandoc", plotlib="Gadfly")
|
||||||
result = readstring("documents/test_hold.md")
|
result = read("documents/test_hold.md", String)
|
||||||
ref = readstring("documents/test_hold_ref.md")
|
ref = read("documents/test_hold_ref.md", String)
|
||||||
@test result == ref
|
@test result == ref
|
||||||
cleanup && rm("documents/test_hold.md")
|
cleanup && rm("documents/test_hold.md")
|
||||||
|
|
||||||
#Test setting and restoring chunk options
|
#Test setting and restoring chunk options
|
||||||
Weave.weave("documents/default_opts.noweb", doctype = "tex")
|
Weave.weave("documents/default_opts.noweb", doctype = "tex")
|
||||||
result = readstring("documents/default_opts.tex")
|
result = read("documents/default_opts.tex", String)
|
||||||
ref = readstring("documents/default_opts_ref.tex")
|
ref = read("documents/default_opts_ref.tex", String)
|
||||||
@test result == ref
|
@test result == ref
|
||||||
cleanup && rm("documents/default_opts.tex")
|
cleanup && rm("documents/default_opts.tex")
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
using Weave
|
using Weave
|
||||||
using Base.Test
|
using Test
|
||||||
|
|
||||||
function convert_test(outfile, infile="documents/chunk_options.noweb")
|
function convert_test(outfile, infile="documents/chunk_options.noweb")
|
||||||
outfile = joinpath("documents/convert", outfile)
|
outfile = joinpath("documents/convert", outfile)
|
||||||
convert_doc(infile, outfile)
|
convert_doc(infile, outfile)
|
||||||
result = readstring(outfile)
|
result = read(outfile, String)
|
||||||
ref = readstring(outfile * ".ref")
|
ref = read(outfile * ".ref", String)
|
||||||
@test result == ref
|
@test result == ref
|
||||||
rm(outfile)
|
rm(outfile)
|
||||||
end
|
end
|
||||||
|
|
|
@ -32,9 +32,9 @@
|
||||||
|
|
||||||
using Gadfly, DSP
|
using Gadfly, DSP
|
||||||
|
|
||||||
function FIRfreqz(b::Array, w = linspace(0, π, 1024))
|
function FIRfreqz(b::Array, w = range(0, stop=π, length=1024))
|
||||||
n = length(w)
|
n = length(w)
|
||||||
h = Array{Complex64}(n)
|
h = Array{ComplexF32}(n)
|
||||||
sw = 0
|
sw = 0
|
||||||
for i = 1:n
|
for i = 1:n
|
||||||
for j = 1:length(b)
|
for j = 1:length(b)
|
||||||
|
@ -59,7 +59,7 @@ end
|
||||||
|
|
||||||
fs = 20
|
fs = 20
|
||||||
f = digitalfilter(Lowpass(5, fs = fs), FIRWindow(hamming(61)))
|
f = digitalfilter(Lowpass(5, fs = fs), FIRWindow(hamming(61)))
|
||||||
w = linspace(0, pi, 1024)
|
w = range(0, stop=pi, length=1024)
|
||||||
h = FIRfreqz(f, w)
|
h = FIRfreqz(f, w)
|
||||||
|
|
||||||
#' ## Plot the frequency and impulse response
|
#' ## Plot the frequency and impulse response
|
||||||
|
@ -75,6 +75,6 @@ plot(y = h_db, x = ws, Geom.line,
|
||||||
|
|
||||||
#' And again with default options
|
#' And again with default options
|
||||||
|
|
||||||
h_phase = unwrap(-atan2(imag(h),real(h)))
|
h_phase = unwrap(-atan(imag(h),real(h)))
|
||||||
plot(y = h_phase, x = ws, Geom.line,
|
plot(y = h_phase, x = ws, Geom.line,
|
||||||
Guide.xlabel("Frequency (Hz)"), Guide.ylabel("Phase (radians)"))
|
Guide.xlabel("Frequency (Hz)"), Guide.ylabel("Phase (radians)"))
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
````julia
|
````julia
|
||||||
using Gadfly
|
using Gadfly
|
||||||
x = linspace(0, 2π, 200)
|
x = range(0, stop=2π, length=200)
|
||||||
plot(x=x, y = sin(x), Geom.line)
|
plot(x=x, y = sin(x), Geom.line)
|
||||||
````
|
````
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ plot(x=x, y = sin(x), Geom.line)
|
||||||
![](figures/gadfly_formats_test_cos2_fun_1.js.svg)
|
![](figures/gadfly_formats_test_cos2_fun_1.js.svg)
|
||||||
|
|
||||||
````julia
|
````julia
|
||||||
julia> x = linspace(0, 2π, 200)
|
julia> x = range(0, stop=2π, length=200)
|
||||||
200-element LinSpace{Float64}:
|
200-element LinSpace{Float64}:
|
||||||
0.0,0.0315738,0.0631476,0.0947214,0.126295,…,6.18846,6.22004,6.25161,6.28319
|
0.0,0.0315738,0.0631476,0.0947214,0.126295,…,6.18846,6.22004,6.25161,6.28319
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ Plot(...)
|
||||||
![](figures/gadfly_formats_test_4_2.js.svg)
|
![](figures/gadfly_formats_test_4_2.js.svg)
|
||||||
|
|
||||||
````julia
|
````julia
|
||||||
x = linspace(0, 2π, 200)
|
x = range(0, stop=2π, length=200)
|
||||||
plot(x=x, y = sin(x), Geom.line)
|
plot(x=x, y = sin(x), Geom.line)
|
||||||
````
|
````
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
````julia
|
````julia
|
||||||
using Gadfly
|
using Gadfly
|
||||||
x = linspace(0, 2π, 200)
|
x = range(0, stop=2π, length=200)
|
||||||
plot(x=x, y = sin(x), Geom.line)
|
plot(x=x, y = sin(x), Geom.line)
|
||||||
````
|
````
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ plot(x=x, y = sin(x), Geom.line)
|
||||||
[figures/gadfly_formats_test_cos2_fun_1.png]: figures/gadfly_formats_test_cos2_fun_1.png
|
[figures/gadfly_formats_test_cos2_fun_1.png]: figures/gadfly_formats_test_cos2_fun_1.png
|
||||||
|
|
||||||
````julia
|
````julia
|
||||||
julia> x = linspace(0, 2π, 200)
|
julia> x = range(0, stop=2π, length=200)
|
||||||
200-element LinSpace{Float64}:
|
200-element LinSpace{Float64}:
|
||||||
0.0,0.0315738,0.0631476,0.0947214,0.126295,…,6.18846,6.22004,6.25161,6.28319
|
0.0,0.0315738,0.0631476,0.0947214,0.126295,…,6.18846,6.22004,6.25161,6.28319
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ Plot(...)
|
||||||
[figures/gadfly_formats_test_4_2.png]: figures/gadfly_formats_test_4_2.png
|
[figures/gadfly_formats_test_4_2.png]: figures/gadfly_formats_test_4_2.png
|
||||||
|
|
||||||
````julia
|
````julia
|
||||||
x = linspace(0, 2π, 200)
|
x = range(0, stop=2π, length=200)
|
||||||
plot(x=x, y = sin(x), Geom.line)
|
plot(x=x, y = sin(x), Geom.line)
|
||||||
````
|
````
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
````julia
|
````julia
|
||||||
julia> using Gadfly
|
julia> using Gadfly
|
||||||
|
|
||||||
julia> x = linspace(0, 2π, 200)
|
julia> x = range(0, stop=2π, length=200)
|
||||||
200-element LinSpace{Float64}:
|
200-element LinSpace{Float64}:
|
||||||
0.0,0.0315738,0.0631476,0.0947214,0.126295,…,6.18846,6.22004,6.25161,6.28319
|
0.0,0.0315738,0.0631476,0.0947214,0.126295,…,6.18846,6.22004,6.25161,6.28319
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ Plot(...)
|
||||||
![](figures/gadfly_markdown_test_1_2.png)
|
![](figures/gadfly_markdown_test_1_2.png)
|
||||||
|
|
||||||
````julia
|
````julia
|
||||||
x = linspace(0, 200)
|
x = range(0, stop=200, length=50)
|
||||||
println(x)
|
println(x)
|
||||||
````
|
````
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ linspace(0.0,200.0,50)
|
||||||
````julia
|
````julia
|
||||||
julia> using Gadfly
|
julia> using Gadfly
|
||||||
|
|
||||||
julia> x = linspace(0, 2π, 200)
|
julia> x = range(0, stop=2π, length=200)
|
||||||
200-element LinSpace{Float64}:
|
200-element LinSpace{Float64}:
|
||||||
0.0,0.0315738,0.0631476,0.0947214,0.126295,…,6.18846,6.22004,6.25161,6.28319
|
0.0,0.0315738,0.0631476,0.0947214,0.126295,…,6.18846,6.22004,6.25161,6.28319
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ Plot(...)
|
||||||
![](figures/gadfly_markdown_test_3_2.png)
|
![](figures/gadfly_markdown_test_3_2.png)
|
||||||
|
|
||||||
````julia
|
````julia
|
||||||
x = linspace(0, 200)
|
x = range(0, stop=200, length=50)
|
||||||
println(x)
|
println(x)
|
||||||
````
|
````
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
using Plots
|
using Plots
|
||||||
pyplot()
|
pyplot()
|
||||||
x = linspace(0, 2*pi)
|
x = range(0, stop=2*pi, length=50)
|
||||||
println(x)
|
println(x)
|
||||||
p = plot(x = x, y = sin(x), size =(900,300))
|
p = plot(x = x, y = sin(x), size =(900,300))
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
````julia
|
````julia
|
||||||
using PyPlot
|
using PyPlot
|
||||||
x = linspace(0, 2π, 200)
|
x = range(0, stop=2π, length=200)
|
||||||
plot(x, sin(x))
|
plot(x, sin(x))
|
||||||
````
|
````
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ plot(x, sin(x))
|
||||||
![](figures/pyplot_formats_cos2_fun_1.png)
|
![](figures/pyplot_formats_cos2_fun_1.png)
|
||||||
|
|
||||||
````julia
|
````julia
|
||||||
julia> x = linspace(0, 2π, 200)
|
julia> x = range(0, stop=2π, length=200)
|
||||||
200-element LinSpace{Float64}:
|
200-element LinSpace{Float64}:
|
||||||
0.0,0.0315738,0.0631476,0.0947214,0.126295,…,6.18846,6.22004,6.25161,6.28319
|
0.0,0.0315738,0.0631476,0.0947214,0.126295,…,6.18846,6.22004,6.25161,6.28319
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
using Weave
|
using Weave
|
||||||
using Base.Test
|
using Test
|
||||||
|
|
||||||
s1= """
|
s1= """
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
using Weave
|
using Weave
|
||||||
using Base.Test
|
using Test
|
||||||
|
|
||||||
# Make a dummy codehunk with figure
|
# Make a dummy codehunk with figure
|
||||||
chunk = Weave.CodeChunk("plot(x)", 1, 1, "", Dict())
|
chunk = Weave.CodeChunk("plot(x)", 1, 1, "", Dict())
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
using Weave
|
using Weave
|
||||||
using Base.Test
|
using Test
|
||||||
|
|
||||||
# Test rendering of doc chunks
|
# Test rendering of doc chunks
|
||||||
content = """
|
content = """
|
||||||
|
|
|
@ -1,60 +1,60 @@
|
||||||
#Test for Gadfly with different chunk options and figure formatsusing Weave
|
#Test for Gadfly with different chunk options and figure formatsusing Weave
|
||||||
using Weave
|
using Weave
|
||||||
using Base.Test
|
using Test
|
||||||
|
|
||||||
|
|
||||||
weave("documents/gadfly_formats_test.txt", doctype = "tex", plotlib="gadfly")
|
weave("documents/gadfly_formats_test.txt", doctype = "tex", plotlib="gadfly")
|
||||||
result = readstring("documents/gadfly_formats_test.tex")
|
result = read("documents/gadfly_formats_test.tex", String)
|
||||||
ref = readstring("documents/gadfly_formats_test_ref.tex")
|
ref = read("documents/gadfly_formats_test_ref.tex", String)
|
||||||
@test result == ref
|
@test result == ref
|
||||||
|
|
||||||
weave("documents/gadfly_formats_test.txt", doctype="tex", fig_ext=".tex", plotlib="gadfly")
|
weave("documents/gadfly_formats_test.txt", doctype="tex", fig_ext=".tex", plotlib="gadfly")
|
||||||
result = readstring("documents/gadfly_formats_test.tex")
|
result = read("documents/gadfly_formats_test.tex", String)
|
||||||
ref = readstring("documents/gadfly_formats_test_tikz_ref.tex")
|
ref = read("documents/gadfly_formats_test_tikz_ref.tex", String)
|
||||||
@test result == ref
|
@test result == ref
|
||||||
|
|
||||||
weave("documents/gadfly_formats_test.txt", doctype="tex", fig_ext=".ps", plotlib="gadfly")
|
weave("documents/gadfly_formats_test.txt", doctype="tex", fig_ext=".ps", plotlib="gadfly")
|
||||||
result = readstring("documents/gadfly_formats_test.tex")
|
result = read("documents/gadfly_formats_test.tex", String)
|
||||||
ref = readstring("documents/gadfly_formats_test_ps_ref.tex")
|
ref = read("documents/gadfly_formats_test_ps_ref.tex", String)
|
||||||
@test result == ref
|
@test result == ref
|
||||||
|
|
||||||
weave("documents/gadfly_formats_test.txt", doctype="pandoc", plotlib="gadfly")
|
weave("documents/gadfly_formats_test.txt", doctype="pandoc", plotlib="gadfly")
|
||||||
result = readstring("documents/gadfly_formats_test.md")
|
result = read("documents/gadfly_formats_test.md", String)
|
||||||
ref = readstring("documents/gadfly_formats_test_pandoc_ref.md")
|
ref = read("documents/gadfly_formats_test_pandoc_ref.md", String)
|
||||||
@test result == ref
|
@test result == ref
|
||||||
|
|
||||||
weave("documents/gadfly_formats_test.txt", doctype="pandoc", plotlib="gadfly", fig_ext=".svg")
|
weave("documents/gadfly_formats_test.txt", doctype="pandoc", plotlib="gadfly", fig_ext=".svg")
|
||||||
result = readstring("documents/gadfly_formats_test.md")
|
result = read("documents/gadfly_formats_test.md", String)
|
||||||
ref = readstring("documents/gadfly_formats_test_svg_ref.md")
|
ref = read("documents/gadfly_formats_test_svg_ref.md", String)
|
||||||
@test result == ref
|
@test result == ref
|
||||||
|
|
||||||
weave("documents/gadfly_formats_test.txt", doctype="github", plotlib="gadfly", fig_ext=".js.svg")
|
weave("documents/gadfly_formats_test.txt", doctype="github", plotlib="gadfly", fig_ext=".js.svg")
|
||||||
result = readstring("documents/gadfly_formats_test.md")
|
result = read("documents/gadfly_formats_test.md", String)
|
||||||
ref = readstring("documents/gadfly_formats_test_jssvg_ref.md")
|
ref = read("documents/gadfly_formats_test_jssvg_ref.md", String)
|
||||||
@test result == ref
|
@test result == ref
|
||||||
|
|
||||||
weave("documents/gadfly_formats_test.txt", doctype="rst", plotlib="gadfly")
|
weave("documents/gadfly_formats_test.txt", doctype="rst", plotlib="gadfly")
|
||||||
result = readstring("documents/gadfly_formats_test.rst")
|
result = read("documents/gadfly_formats_test.rst", String)
|
||||||
ref = readstring("documents/gadfly_formats_test_ref.rst")
|
ref = read("documents/gadfly_formats_test_ref.rst", String)
|
||||||
@test result == ref
|
@test result == ref
|
||||||
|
|
||||||
weave("documents/gadfly_formats_test.txt", doctype="multimarkdown", plotlib="gadfly")
|
weave("documents/gadfly_formats_test.txt", doctype="multimarkdown", plotlib="gadfly")
|
||||||
result = readstring("documents/gadfly_formats_test.md")
|
result = read("documents/gadfly_formats_test.md", String)
|
||||||
ref = readstring("documents/gadfly_formats_test_mmd_ref.md")
|
ref = read("documents/gadfly_formats_test_mmd_ref.md", String)
|
||||||
@test result == ref
|
@test result == ref
|
||||||
|
|
||||||
weave("documents/gadfly_formats_test.txt", doctype="asciidoc", plotlib="gadfly",
|
weave("documents/gadfly_formats_test.txt", doctype="asciidoc", plotlib="gadfly",
|
||||||
out_path="documents/output")
|
out_path="documents/output")
|
||||||
result = readstring("documents/output/gadfly_formats_test.txt")
|
result = read("documents/output/gadfly_formats_test.txt", String)
|
||||||
ref = readstring("documents/output/gadfly_formats_test_ref.txt")
|
ref = read("documents/output/gadfly_formats_test_ref.txt", String)
|
||||||
@test result == ref
|
@test result == ref
|
||||||
|
|
||||||
weave("documents/gadfly_markdown_test.jmd", doctype="github",plotlib="gadfly", informat="markdown")
|
weave("documents/gadfly_markdown_test.jmd", doctype="github",plotlib="gadfly", informat="markdown")
|
||||||
result = readstring("documents/gadfly_markdown_test.md")
|
result = read("documents/gadfly_markdown_test.md", String)
|
||||||
ref = readstring("documents/gadfly_markdown_test_ref.md")
|
ref = read("documents/gadfly_markdown_test_ref.md", String)
|
||||||
@test result == ref
|
@test result == ref
|
||||||
|
|
||||||
weave("documents/FIR_design.jl", doctype="pandoc", plotlib="gadfly", informat="script")
|
weave("documents/FIR_design.jl", doctype="pandoc", plotlib="gadfly", informat="script")
|
||||||
result = readstring("documents/FIR_design.md")
|
result = read("documents/FIR_design.md", String)
|
||||||
ref = readstring("documents/FIR_design_ref.md")
|
ref = read("documents/FIR_design_ref.md", String)
|
||||||
@test result == ref
|
@test result == ref
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
using Base.Test
|
using Test
|
||||||
import Weave: Markdown2HTML
|
import Weave: Markdown2HTML
|
||||||
|
|
||||||
# Test markdown2html writer
|
# Test markdown2html writer
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
using Weave
|
using Weave
|
||||||
using Base.Test
|
using Test
|
||||||
|
|
||||||
function pljtest(source, resfile, doctype)
|
function pljtest(source, resfile, doctype)
|
||||||
weave("documents/$source", out_path = "documents/plotsjl/$resfile", doctype=doctype)
|
weave("documents/$source", out_path = "documents/plotsjl/$resfile", doctype=doctype)
|
||||||
result = readstring("documents/plotsjl/$resfile")
|
result = read("documents/plotsjl/$resfile", String)
|
||||||
ref = readstring("documents/plotsjl/$resfile.ref")
|
ref = read("documents/plotsjl/$resfile.ref", String)
|
||||||
@test result == ref
|
@test result == ref
|
||||||
rm("documents/plotsjl/$resfile")
|
rm("documents/plotsjl/$resfile")
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
using Weave
|
using Weave
|
||||||
using Base.Test
|
using Test
|
||||||
import Plots
|
import Plots
|
||||||
|
|
||||||
function publish_test(outfile, format)
|
function publish_test(outfile, format)
|
||||||
outfile = joinpath("documents/publish", outfile)
|
outfile = joinpath("documents/publish", outfile)
|
||||||
infile = "documents/publish_test.jmd"
|
infile = "documents/publish_test.jmd"
|
||||||
weave(infile, doctype = format, out_path = outfile, template = "templates/mini.tpl")
|
weave(infile, doctype = format, out_path = outfile, template = "templates/mini.tpl")
|
||||||
result = readstring(outfile)
|
result = read(outfile, String)
|
||||||
ref = readstring(outfile * ".ref")
|
ref = read(outfile * ".ref", String)
|
||||||
@test result == ref
|
@test result == ref
|
||||||
rm(outfile)
|
rm(outfile)
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,26 +1,26 @@
|
||||||
using Weave
|
using Weave
|
||||||
using Base.Test
|
using Test
|
||||||
|
|
||||||
cleanup = true
|
cleanup = true
|
||||||
|
|
||||||
weave("documents/pyplot_formats.txt", plotlib="pyplot", doctype="tex")
|
weave("documents/pyplot_formats.txt", plotlib="pyplot", doctype="tex")
|
||||||
result = readstring("documents/pyplot_formats.tex")
|
result = read("documents/pyplot_formats.tex", String)
|
||||||
ref = readstring("documents/pyplot_formats_ref.tex")
|
ref = read("documents/pyplot_formats_ref.tex", String)
|
||||||
result = replace(result, r"\s*PyObject.*\n", "\n") #Remove PyObjects, because they change
|
result = replace(result, r"\s*PyObject.*\n", "\n") #Remove PyObjects, because they change
|
||||||
ref = replace(ref, r"\s*PyObject.*\n", "\n")
|
ref = replace(ref, r"\s*PyObject.*\n", "\n")
|
||||||
@test result == ref
|
@test result == ref
|
||||||
|
|
||||||
weave("documents/pyplot_formats.txt", plotlib="pyplot", doctype="github")
|
weave("documents/pyplot_formats.txt", plotlib="pyplot", doctype="github")
|
||||||
result = readstring("documents/pyplot_formats.md")
|
result = read("documents/pyplot_formats.md", String)
|
||||||
ref = readstring("documents/pyplot_formats_ref.md")
|
ref = read("documents/pyplot_formats_ref.md", String)
|
||||||
result = replace(result, r"\s*PyObject.*\n", "")
|
result = replace(result, r"\s*PyObject.*\n", "")
|
||||||
ref = replace(ref, r"\s*PyObject.*\n", "")
|
ref = replace(ref, r"\s*PyObject.*\n", "")
|
||||||
@test result == ref
|
@test result == ref
|
||||||
|
|
||||||
|
|
||||||
weave("documents/pyplot_formats.txt", plotlib="pyplot", doctype="rst", fig_ext=".svg")
|
weave("documents/pyplot_formats.txt", plotlib="pyplot", doctype="rst", fig_ext=".svg")
|
||||||
result = readstring("documents/pyplot_formats.rst")
|
result = read("documents/pyplot_formats.rst", String)
|
||||||
ref = readstring("documents/pyplot_formats_ref.rst")
|
ref = read("documents/pyplot_formats_ref.rst", String)
|
||||||
result = replace(result, r"\s*PyObject.*\n", "")
|
result = replace(result, r"\s*PyObject.*\n", "")
|
||||||
ref = replace(ref, r"\s*PyObject.*\n", "")
|
ref = replace(ref, r"\s*PyObject.*\n", "")
|
||||||
@test result == ref
|
@test result == ref
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
using Weave
|
using Weave
|
||||||
using Base.Test
|
using Test
|
||||||
|
|
||||||
function mmtest(source, resfile, doctype)
|
function mmtest(source, resfile, doctype)
|
||||||
weave("documents/$source", out_path = "documents/multimedia/$resfile",
|
weave("documents/$source", out_path = "documents/multimedia/$resfile",
|
||||||
doctype=doctype, plotlib=nothing, template = "templates/mini.tpl")
|
doctype=doctype, plotlib=nothing, template = "templates/mini.tpl")
|
||||||
result = readstring("documents/multimedia/$resfile")
|
result = read("documents/multimedia/$resfile", String)
|
||||||
ref = readstring("documents/multimedia/$resfile.ref")
|
ref = read("documents/multimedia/$resfile.ref", String)
|
||||||
@test result == ref
|
@test result == ref
|
||||||
rm("documents/multimedia/$resfile")
|
rm("documents/multimedia/$resfile")
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,30 +1,30 @@
|
||||||
using Weave
|
using Weave
|
||||||
using Base.Test
|
using Test
|
||||||
|
|
||||||
info("Test: Chunk options")
|
@info("Test: Chunk options")
|
||||||
include("chunk_options.jl")
|
include("chunk_options.jl")
|
||||||
|
|
||||||
info("Testing error handling")
|
@info("Testing error handling")
|
||||||
include("errors_test.jl")
|
include("errors_test.jl")
|
||||||
|
|
||||||
info("Test: Converting")
|
@info("Test: Converting")
|
||||||
include("convert_test.jl")
|
include("convert_test.jl")
|
||||||
|
|
||||||
info("Testing formatters")
|
@info("Testing formatters")
|
||||||
include("formatter_test.jl")
|
include("formatter_test.jl")
|
||||||
include("markdown_test.jl")
|
include("markdown_test.jl")
|
||||||
|
|
||||||
info("Testing figure formatters")
|
@info("Testing figure formatters")
|
||||||
include("figureformatter_test.jl")
|
include("figureformatter_test.jl")
|
||||||
|
|
||||||
info("Testing rich output")
|
@info("Testing rich output")
|
||||||
include("rich_output.jl")
|
include("rich_output.jl")
|
||||||
|
|
||||||
|
|
||||||
info("Test: Caching")
|
@info("Test: Caching")
|
||||||
include("cache_test.jl")
|
include("cache_test.jl")
|
||||||
|
|
||||||
info("Test: Chunk options with Gadfly")
|
@info("Test: Chunk options with Gadfly")
|
||||||
include("chunk_opts_gadfly.jl")
|
include("chunk_opts_gadfly.jl")
|
||||||
|
|
||||||
#info("Test: Weaving with Gadfly")
|
#info("Test: Weaving with Gadfly")
|
||||||
|
@ -33,6 +33,6 @@ include("chunk_opts_gadfly.jl")
|
||||||
#info("Test: Weaving with PyPlot")
|
#info("Test: Weaving with PyPlot")
|
||||||
#include("pyplot_formats.jl")
|
#include("pyplot_formats.jl")
|
||||||
|
|
||||||
info("Test: Weaving with Plots.jl")
|
@info("Test: Weaving with Plots.jl")
|
||||||
include("plotsjl_test.jl")
|
include("plotsjl_test.jl")
|
||||||
include("publish_test.jl")
|
include("publish_test.jl")
|
||||||
|
|
Loading…
Reference in New Issue