diff --git a/src/writers.jl b/src/writers.jl index dc90d18..35257bb 100644 --- a/src/writers.jl +++ b/src/writers.jl @@ -51,6 +51,8 @@ function convert_doc(infile::AbstractString, outfile::AbstractString; format = n open(outfile, "w") do f write(f, converted) end + + return nothing end """Convert Weave document to Jupyter notebook format""" diff --git a/test/chunk_options.jl b/test/chunk_options.jl index 5a3d05c..02287a5 100644 --- a/test/chunk_options.jl +++ b/test/chunk_options.jl @@ -3,64 +3,8 @@ using Base.Test cleanup = true -#Test chunk options and output formats weave("documents/chunk_options.noweb", plotlib=nothing) result = readstring(open("documents/chunk_options.md")) ref = 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 = readstring(open("documents/chunk_options.tex")) -ref = 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 = readstring(open("documents/chunk_options.tex")) -ref = 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 = readstring(open("documents/chunk_options.rst")) -ref = readstring(open("documents/chunk_options_ref.rst")) -@test result == ref -cleanup && rm("documents/chunk_options.rst") - -#Test out_path -weave("documents/chunk_options.noweb", doctype="rst", - out_path="documents/outpath_options.rst" , plotlib=nothing) -result = readstring(open("documents/outpath_options.rst")) -ref = readstring(open("documents/chunk_options_ref.rst")) -@test result == ref -cleanup && rm("documents/outpath_options.rst") - -#Test tangle -tangle("documents/chunk_options.noweb") -result = readstring(open("documents/chunk_options.jl")) -ref = readstring(open("documents/chunk_options_ref.jl")) -@test result == ref -cleanup && rm("documents/chunk_options.jl") - - -tangle("documents/chunk_options.noweb", out_path = "documents/outoptions.jl") -result = readstring(open("documents/outoptions.jl")) -ref = readstring(open("documents/chunk_options_ref.jl")) -@test result == ref -cleanup && rm("documents/outoptions.jl") - - -#Test functions and sandbox clearing -weave("documents/chunk_func.noweb", plotlib=nothing) -result = readstring(open("documents/chunk_func.md")) -ref = readstring(open("documents/chunk_func_ref.md")) -@test result == ref -cleanup && rm("documents/chunk_func.md") - -#Test term=true -weave("documents/test_term.jmd", doctype = "pandoc") -result = readstring(open("documents/test_term.md")) -ref = readstring(open("documents/test_term_ref.md")) -@test result == ref -cleanup && rm("documents/test_term.md") diff --git a/test/convert_test.jl b/test/convert_test.jl new file mode 100644 index 0000000..48504e1 --- /dev/null +++ b/test/convert_test.jl @@ -0,0 +1,17 @@ +using Weave +using Base.Test + +function convert_test(outfile) + outfile = joinpath("documents/convert", outfile) + infile = "documents/chunk_options.noweb" + convert_doc(infile, outfile) + result = readstring(open(outfile)) + ref = readstring(open(outfile * ".ref")) + rm(outfile) + @test result == ref +end + +convert_test("chunk_options.jmd") +convert_test("chunk_options.jl") +convert_test("chunk_options.mdw") +convert_test("chunk_options.ipynb") diff --git a/test/documents/convert/chunk_options.ipynb.ref b/test/documents/convert/chunk_options.ipynb.ref new file mode 100644 index 0000000..177dcbd --- /dev/null +++ b/test/documents/convert/chunk_options.ipynb.ref @@ -0,0 +1,179 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "source": [ + "" + ], + "metadata": {} + }, + { + "outputs": [], + "cell_type": "code", + "source": [ + "y= [2, 5, 12]" + ], + "metadata": {}, + "execution_count": null + }, + { + "cell_type": "markdown", + "source": [ + "" + ], + "metadata": {} + }, + { + "outputs": [], + "cell_type": "code", + "source": [ + "x = [12, 10]\nprintln(y)\nprintln(x)" + ], + "metadata": {}, + "execution_count": null + }, + { + "cell_type": "markdown", + "source": [ + "" + ], + "metadata": {} + }, + { + "outputs": [], + "cell_type": "code", + "source": [ + "println(\"Results without code\")\nprintln(x)" + ], + "metadata": {}, + "execution_count": null + }, + { + "cell_type": "markdown", + "source": [ + "" + ], + "metadata": {} + }, + { + "outputs": [], + "cell_type": "code", + "source": [ + "y = randn(5)\nprintln(\"Don't eval, but show code\")" + ], + "metadata": {}, + "execution_count": null + }, + { + "cell_type": "markdown", + "source": [ + "" + ], + "metadata": {} + }, + { + "outputs": [], + "cell_type": "code", + "source": [ + "y = 1:5\nprintln(y)" + ], + "metadata": {}, + "execution_count": null + }, + { + "cell_type": "markdown", + "source": [ + "" + ], + "metadata": {} + }, + { + "outputs": [], + "cell_type": "code", + "source": [ + "a = \"Don't print me\"\nprintln(a)" + ], + "metadata": {}, + "execution_count": null + }, + { + "cell_type": "markdown", + "source": [ + "" + ], + "metadata": {} + }, + { + "outputs": [], + "cell_type": "code", + "source": [ + "println(\"No markup for results.\")" + ], + "metadata": {}, + "execution_count": null + }, + { + "cell_type": "markdown", + "source": [ + "Test wrapping:" + ], + "metadata": {} + }, + { + "outputs": [], + "cell_type": "code", + "source": [ + "println(collect(0:10:1000))" + ], + "metadata": {}, + "execution_count": null + }, + { + "cell_type": "markdown", + "source": [ + "" + ], + "metadata": {} + }, + { + "outputs": [], + "cell_type": "code", + "source": [ + "println(collect(0:10:1000))" + ], + "metadata": {}, + "execution_count": null + }, + { + "cell_type": "markdown", + "source": [ + "" + ], + "metadata": {} + }, + { + "outputs": [], + "cell_type": "code", + "source": [ + "println(collect(0:10:1000))" + ], + "metadata": {}, + "execution_count": null + } + ], + "nbformat_minor": 2, + "metadata": { + "language_info": { + "file_extension": ".jl", + "mimetype": "application/julia", + "name": "julia", + "version": "0.5.0" + }, + "kernelspec": { + "name": "julia-0.5", + "display_name": "Julia 0.5.0", + "language": "julia" + } + }, + "nbformat": 4 +} diff --git a/test/documents/convert/chunk_options.jl.ref b/test/documents/convert/chunk_options.jl.ref new file mode 100644 index 0000000..81cefd4 --- /dev/null +++ b/test/documents/convert/chunk_options.jl.ref @@ -0,0 +1,70 @@ +#' +#+ term=true + +y= [2, 5, 12] + +#' +#' +#+ + +x = [12, 10] +println(y) +println(x) + +#' +#' +#' +#+ echo=false + +println("Results without code") +println(x) + +#' +#' +#' +#+ eval=false; tangle=false + +y = randn(5) +println("Don't eval, but show code") + +#' +#' +#' +#+ + +y = 1:5 +println(y) + +#' +#' +#+ results="hidden" + +a = "Don't print me" +println(a) + +#' +#' +#+ results="as_is" + +println("No markup for results.") + +#' +#' +#' Test wrapping: +#' +#+ + +println(collect(0:10:1000)) + +#' +#' +#+ wrap=false + +println(collect(0:10:1000)) + +#' +#' +#+ line_width=60 + +println(collect(0:10:1000)) + diff --git a/test/documents/convert/chunk_options.jmd.ref b/test/documents/convert/chunk_options.jmd.ref new file mode 100644 index 0000000..19098a4 --- /dev/null +++ b/test/documents/convert/chunk_options.jmd.ref @@ -0,0 +1,60 @@ + +```julia;term=true +y= [2, 5, 12] +``` + + +```julia +x = [12, 10] +println(y) +println(x) +``` + + + +```julia;echo=false +println("Results without code") +println(x) +``` + + + +```julia;eval=false; tangle=false +y = randn(5) +println("Don't eval, but show code") +``` + + + +```julia +y = 1:5 +println(y) +``` + + +```julia;results="hidden" +a = "Don't print me" +println(a) +``` + + +```julia;results="as_is" +println("No markup for results.") +``` + + +Test wrapping: + +```julia +println(collect(0:10:1000)) +``` + + +```julia;wrap=false +println(collect(0:10:1000)) +``` + + +```julia;line_width=60 +println(collect(0:10:1000)) +``` diff --git a/test/documents/convert/chunk_options.mdw.ref b/test/documents/convert/chunk_options.mdw.ref new file mode 100644 index 0000000..e281d0f --- /dev/null +++ b/test/documents/convert/chunk_options.mdw.ref @@ -0,0 +1,60 @@ + +<>= +y= [2, 5, 12] +@ + + +<<>>= +x = [12, 10] +println(y) +println(x) +@ + + + +<>= +println("Results without code") +println(x) +@ + + + +<>= +y = randn(5) +println("Don't eval, but show code") +@ + + + +<<>>= +y = 1:5 +println(y) +@ + + +<>= +a = "Don't print me" +println(a) +@ + + +<>= +println("No markup for results.") +@ + + +Test wrapping: + +<<>>= +println(collect(0:10:1000)) +@ + + +<>= +println(collect(0:10:1000)) +@ + + +<>= +println(collect(0:10:1000)) +@ diff --git a/test/runtests.jl b/test/runtests.jl index 19f07d9..3572d16 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -9,6 +9,9 @@ using Base.Test info("Test: Chunk options") include("chunk_options.jl") +info("Test: Converting") +include("convert_test.jl") + info("Test: Caching") include("cache_test.jl")