Changed readall to @compat readstring

pull/35/head
Matti Pastell 2016-04-20 21:01:14 +03:00
parent f62a315dc0
commit 54a9a79e98
10 changed files with 66 additions and 68 deletions

View File

@ -1,10 +1,9 @@
% Weave.jl example document: Embedding Gadfly plots
% Intro to Weave.jl with Gadfly
% Matti Pastell
% 20th April 2016
If you have Weave.jl installed you can run this document with output
to your working directory using:
```julia
using Weave

View File

@ -21,7 +21,7 @@ function pandoc2html(formatted::AbstractString, doc::WeaveDoc)
html =""
try
#html = readall(
#html = @compat readstring(
run(pipeline(`echo $formatted` ,
`pandoc -R -s --mathjax --self-contained --highlight-style=tango
--template $html_template --include-in-header=$css_template

View File

@ -15,14 +15,13 @@ const input_formats = @compat Dict{AbstractString, Any}(
"""Read and parse input document"""
function read_doc(source::AbstractString, format="noweb"::AbstractString)
document = readall(source)
document = @compat readstring(source)
parsed = parse_doc(document, format)
doc = WeaveDoc(source, parsed)
end
"""Parse chunks from AbstractString"""
function parse_doc(document::AbstractString, format="noweb"::AbstractString)
#doctext = readall(open(document))
lines = split(document, "\n")
codestart = input_formats[format][:codestart]

View File

@ -130,7 +130,7 @@ function capture_output(expr::Expr, SandBox::Module, term, plotlib)
finally
redirect_stdout(oldSTDOUT)
close(wr)
out = readall(rw)
out = @compat readstring(rw)
close(rw)
end
return (obj, out)

View File

@ -1,23 +1,23 @@
using Weave
using Weave, Compat
using Base.Test
#Test if running document with and without cache works
isdir("documents/cache") && rm("documents/cache", recursive = true)
weave("documents/chunk_options.noweb", plotlib=nothing, cache=:all)
result = readall(open("documents/chunk_options.md"))
result = @compat readstring(open("documents/chunk_options.md"))
rm("documents/chunk_options.md")
weave("documents/chunk_options.noweb", plotlib=nothing, cache=:all)
cached_result = readall(open("documents/chunk_options.md"))
cached_result = @compat readstring(open("documents/chunk_options.md"))
@test result == cached_result
# cache = :user
isdir("documents/cache") && rm("documents/cache", recursive = true)
out = "documents/chunk_cache.md"
Weave.weave("documents/chunk_cache.noweb", plotlib=nothing, cache=:user);
result = readall(open(out))
result = @compat readstring(open(out))
rm(out)
Weave.weave("documents/chunk_cache.noweb", plotlib=nothing, cache=:user);
cached_result = readall(open(out))
cached_result = @compat readstring(open(out))
@test result == cached_result
if VERSION.minor == 3
@ -25,9 +25,9 @@ if VERSION.minor == 3
isdir("documents/cache") && rm("documents/cache", recursive = true)
#Caching with Gadfly
weave("documents/gadfly_formats_test.txt", doctype="tex", plotlib="gadfly", cache=:all)
result = readall(open("documents/gadfly_formats_test.tex"))
result = @compat readstring(open("documents/gadfly_formats_test.tex"))
rm("documents/gadfly_formats_test.tex")
weave("documents/gadfly_formats_test.txt", doctype="tex", plotlib="gadfly", cache=:all)
cached_result = readall(open("documents/gadfly_formats_test.tex"))
cached_result = @compat readstring(open("documents/gadfly_formats_test.tex"))
@test result == cached_result
end

View File

@ -1,42 +1,42 @@
using Weave
using Weave, Compat
using Base.Test
cleanup = true
#Test chunk options and output formats
weave("documents/chunk_options.noweb", plotlib=nothing)
result = readall(open("documents/chunk_options.md"))
ref = readall(open("documents/chunk_options_ref.md"))
result = @compat readstring(open("documents/chunk_options.md"))
ref = @compat readstring(open("documents/chunk_options_ref.md"))
@test result == ref
cleanup && rm("documents/chunk_options.md")
weave("documents/chunk_options.noweb", doctype="tex", plotlib=nothing)
result = readall(open("documents/chunk_options.tex"))
ref = readall(open("documents/chunk_options_ref.tex"))
result = @compat readstring(open("documents/chunk_options.tex"))
ref = @compat readstring(open("documents/chunk_options_ref.tex"))
@test result == ref
cleanup && rm("documents/chunk_options.tex")
weave("documents/chunk_options.noweb", doctype="texminted", plotlib=nothing)
result = readall(open("documents/chunk_options.tex"))
ref = readall(open("documents/chunk_options_ref.texminted"))
result = @compat readstring(open("documents/chunk_options.tex"))
ref = @compat readstring(open("documents/chunk_options_ref.texminted"))
@test result == ref
cleanup && rm("documents/chunk_options.tex")
weave("documents/chunk_options.noweb", doctype="rst", plotlib=nothing)
result = readall(open("documents/chunk_options.rst"))
ref = readall(open("documents/chunk_options_ref.rst"))
result = @compat readstring(open("documents/chunk_options.rst"))
ref = @compat readstring(open("documents/chunk_options_ref.rst"))
@test result == ref
cleanup && rm("documents/chunk_options.rst")
tangle("documents/chunk_options.noweb")
result = readall(open("documents/chunk_options.jl"))
ref = readall(open("documents/chunk_options_ref.jl"))
result = @compat readstring(open("documents/chunk_options.jl"))
ref = @compat readstring(open("documents/chunk_options_ref.jl"))
@test result == ref
cleanup && rm("documents/chunk_options.jl")
#Test functions and sandbox clearing
weave("documents/chunk_func.noweb", plotlib=nothing)
result = readall(open("documents/chunk_func.md"))
ref = readall(open("documents/chunk_func_ref.md"))
result = @compat readstring(open("documents/chunk_func.md"))
ref = @compat readstring(open("documents/chunk_func_ref.md"))
@test result == ref
cleanup && rm("documents/chunk_func.md")

View File

@ -1,18 +1,18 @@
using Weave
using Weave, Compat
using Base.Test
cleanup = true
#Test hold and term options
weave("documents/test_hold.mdw", doctype="pandoc", plotlib="Gadfly")
result = readall(open("documents/test_hold.md"))
ref = readall(open("documents/test_hold_ref.md"))
result = @compat readstring(open("documents/test_hold.md"))
ref = @compat readstring(open("documents/test_hold_ref.md"))
@test result == ref
cleanup && rm("documents/test_hold.md")
#Test setting and restoring chunk options
Weave.weave("documents/default_opts.noweb", doctype = "tex")
result = readall(open("documents/default_opts.tex"))
ref = readall(open("documents/default_opts_ref.tex"))
result = @compat readstring(open("documents/default_opts.tex"))
ref = @compat readstring(open("documents/default_opts_ref.tex"))
@test result == ref
cleanup && rm("documents/default_opts.tex")

View File

@ -1,51 +1,51 @@
#Test for Gadfly with different chunk options and figure formats
using Weave
#Test for Gadfly with different chunk options and figure formatsusing Weave
using Weave, Compat
using Base.Test
weave("documents/gadfly_formats_test.txt", "tex")
result = readall(open("documents/gadfly_formats_test.tex"))
ref = readall(open("documents/gadfly_formats_test_ref.tex"))
result = @compat readstring(open("documents/gadfly_formats_test.tex"))
ref = @compat readstring(open("documents/gadfly_formats_test_ref.tex"))
@test result == ref
weave("documents/gadfly_formats_test.txt", doctype="tex", fig_ext=".tex", plotlib="gadfly")
result = readall(open("documents/gadfly_formats_test.tex"))
ref = readall(open("documents/gadfly_formats_test_tikz_ref.tex"))
result = @compat readstring(open("documents/gadfly_formats_test.tex"))
ref = @compat readstring(open("documents/gadfly_formats_test_tikz_ref.tex"))
@test result == ref
weave("documents/gadfly_formats_test.txt", doctype="tex", fig_ext=".ps", plotlib="gadfly")
result = readall(open("documents/gadfly_formats_test.tex"))
ref = readall(open("documents/gadfly_formats_test_ps_ref.tex"))
result = @compat readstring(open("documents/gadfly_formats_test.tex"))
ref = @compat readstring(open("documents/gadfly_formats_test_ps_ref.tex"))
@test result == ref
weave("documents/gadfly_formats_test.txt", doctype="pandoc", plotlib="gadfly")
result = readall(open("documents/gadfly_formats_test.md"))
ref = readall(open("documents/gadfly_formats_test_pandoc_ref.md"))
result = @compat readstring(open("documents/gadfly_formats_test.md"))
ref = @compat readstring(open("documents/gadfly_formats_test_pandoc_ref.md"))
@test result == ref
weave("documents/gadfly_formats_test.txt", doctype="pandoc", plotlib="gadfly", fig_ext=".svg")
result = readall(open("documents/gadfly_formats_test.md"))
ref = readall(open("documents/gadfly_formats_test_svg_ref.md"))
result = @compat readstring(open("documents/gadfly_formats_test.md"))
ref = @compat readstring(open("documents/gadfly_formats_test_svg_ref.md"))
@test result == ref
weave("documents/gadfly_formats_test.txt", doctype="github", plotlib="gadfly", fig_ext=".js.svg")
result = readall(open("documents/gadfly_formats_test.md"))
ref = readall(open("documents/gadfly_formats_test_jssvg_ref.md"))
result = @compat readstring(open("documents/gadfly_formats_test.md"))
ref = @compat readstring(open("documents/gadfly_formats_test_jssvg_ref.md"))
@test result == ref
weave("documents/gadfly_formats_test.txt", doctype="rst", plotlib="gadfly")
result = readall(open("documents/gadfly_formats_test.rst"))
ref = readall(open("documents/gadfly_formats_test_ref.rst"))
result = @compat readstring(open("documents/gadfly_formats_test.rst"))
ref = @compat readstring(open("documents/gadfly_formats_test_ref.rst"))
@test result == ref
weave("documents/gadfly_formats_test.txt", doctype="asciidoc", plotlib="gadfly",
out_path="documents/output")
result = readall(open("documents/output/gadfly_formats_test.txt"))
ref = readall(open("documents/output/gadfly_formats_test_ref.txt"))
result = @compat readstring(open("documents/output/gadfly_formats_test.txt"))
ref = @compat readstring(open("documents/output/gadfly_formats_test_ref.txt"))
@test result == ref
weave("documents/gadfly_markdown_test.jmd", doctype="github",plotlib="gadfly", informat="markdown")
result = readall(open("documents/gadfly_markdown_test.md"))
ref = readall(open("documents/gadfly_markdown_test_ref.md"))
result = @compat readstring(open("documents/gadfly_markdown_test.md"))
ref = @compat readstring(open("documents/gadfly_markdown_test_ref.md"))
@test result == ref

View File

@ -1,26 +1,26 @@
using Weave
using Weave, Compat
using Base.Test
cleanup = true
weave("documents/pyplot_formats.txt", plotlib="pyplot", doctype="tex")
result = readall(open("documents/pyplot_formats.tex"))
ref = readall(open("documents/pyplot_formats_ref.tex"))
result = @compat readstring(open("documents/pyplot_formats.tex"))
ref = @compat readstring(open("documents/pyplot_formats_ref.tex"))
result = replace(result, r"\s*PyObject.*\n", "\n") #Remove PyObjects, because they change
ref = replace(ref, r"\s*PyObject.*\n", "\n")
@test result == ref
weave("documents/pyplot_formats.txt", plotlib="pyplot", doctype="github")
result = readall(open("documents/pyplot_formats.md"))
ref = readall(open("documents/pyplot_formats_ref.md"))
result = @compat readstring(open("documents/pyplot_formats.md"))
ref = @compat readstring(open("documents/pyplot_formats_ref.md"))
result = replace(result, r"\s*PyObject.*\n", "")
ref = replace(ref, r"\s*PyObject.*\n", "")
@test result == ref
weave("documents/pyplot_formats.txt", plotlib="pyplot", doctype="rst", fig_ext=".svg")
result = readall(open("documents/pyplot_formats.rst"))
ref = readall(open("documents/pyplot_formats_ref.rst"))
result = @compat readstring(open("documents/pyplot_formats.rst"))
ref = @compat readstring(open("documents/pyplot_formats_ref.rst"))
result = replace(result, r"\s*PyObject.*\n", "")
ref = replace(ref, r"\s*PyObject.*\n", "")
@test result == ref

View File

@ -1,23 +1,23 @@
using Weave
using Weave, Compat
using Base.Test
weave("documents/winston_formats.txt", plotlib="Winston", doctype="tex")
result = readall(open("documents/winston_formats.tex"))
ref = readall(open("documents/winston_formats_ref.tex"))
result = @compat readstring(open("documents/winston_formats.tex"))
ref = @compat readstring(open("documents/winston_formats_ref.tex"))
@test result == ref
weave("documents/winston_formats.txt", plotlib="Winston", doctype="github")
result = readall(open("documents/winston_formats.md"))
ref = readall(open("documents/winston_formats_ref.md"))
result = @compat readstring(open("documents/winston_formats.md"))
ref = @compat readstring(open("documents/winston_formats_ref.md"))
@test result == ref
weave("documents/winston_formats.txt", plotlib="Winston", doctype="pandoc", fig_ext=".svg")
result = readall(open("documents/winston_formats.md"))
ref = readall(open("documents/winston_formats_svg_ref.md"))
result = @compat readstring(open("documents/winston_formats.md"))
ref = @compat readstring(open("documents/winston_formats_svg_ref.md"))
@test result == ref
weave("documents/winston_formats.txt", plotlib="Winston", doctype="rst")
result = readall(open("documents/winston_formats.rst"))
ref = readall(open("documents/winston_formats_ref.rst"))
result = @compat readstring(open("documents/winston_formats.rst"))
ref = @compat readstring(open("documents/winston_formats_ref.rst"))
@test result == ref