From 54a9a79e98ed9f3ca0020dc332d61c59706e4057 Mon Sep 17 00:00:00 2001 From: Matti Pastell Date: Wed, 20 Apr 2016 21:01:14 +0300 Subject: [PATCH] Changed readall to @compat readstring --- examples/gadfly_sample.mdw | 5 ++--- src/pandoc.jl | 2 +- src/readers.jl | 3 +-- src/run.jl | 2 +- test/cache_test.jl | 14 ++++++------- test/chunk_options.jl | 26 ++++++++++++------------- test/chunk_opts_gadfly.jl | 10 +++++----- test/gadfly_formats.jl | 40 +++++++++++++++++++------------------- test/pyplot_formats.jl | 14 ++++++------- test/winston_formats.jl | 18 ++++++++--------- 10 files changed, 66 insertions(+), 68 deletions(-) diff --git a/examples/gadfly_sample.mdw b/examples/gadfly_sample.mdw index bb96a40..64a447a 100644 --- a/examples/gadfly_sample.mdw +++ b/examples/gadfly_sample.mdw @@ -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 diff --git a/src/pandoc.jl b/src/pandoc.jl index a2d0616..3db7e7e 100644 --- a/src/pandoc.jl +++ b/src/pandoc.jl @@ -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 diff --git a/src/readers.jl b/src/readers.jl index c77cb29..9b6c2f0 100644 --- a/src/readers.jl +++ b/src/readers.jl @@ -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] diff --git a/src/run.jl b/src/run.jl index a7951e0..911bcb8 100644 --- a/src/run.jl +++ b/src/run.jl @@ -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) diff --git a/test/cache_test.jl b/test/cache_test.jl index 33b2410..def5584 100644 --- a/test/cache_test.jl +++ b/test/cache_test.jl @@ -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 diff --git a/test/chunk_options.jl b/test/chunk_options.jl index c6bd102..f06c4e4 100644 --- a/test/chunk_options.jl +++ b/test/chunk_options.jl @@ -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") diff --git a/test/chunk_opts_gadfly.jl b/test/chunk_opts_gadfly.jl index cad1757..bb7a06f 100644 --- a/test/chunk_opts_gadfly.jl +++ b/test/chunk_opts_gadfly.jl @@ -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") diff --git a/test/gadfly_formats.jl b/test/gadfly_formats.jl index a710077..c644f16 100644 --- a/test/gadfly_formats.jl +++ b/test/gadfly_formats.jl @@ -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 diff --git a/test/pyplot_formats.jl b/test/pyplot_formats.jl index 0375b78..1e06a6a 100644 --- a/test/pyplot_formats.jl +++ b/test/pyplot_formats.jl @@ -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 diff --git a/test/winston_formats.jl b/test/winston_formats.jl index 6920c06..2aeb61c 100644 --- a/test/winston_formats.jl +++ b/test/winston_formats.jl @@ -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