diff --git a/.gitignore b/.gitignore index c8ab49e..3768f0d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,33 +1,33 @@ - -src/*.cov -test.jl -examples/figures/ -examples/*.md -examples/*.pdf -examples/*.html -examples/*.rst -examples/*.tex -test/**/cache -test/**/figures -test/documents/output/gadfly_formats_test.txt -test/**/*.tex -test/**/*.md -test/**/*.rst -test/**/*.html -test/**/*.pdf -test/**/*.png -test/**/chunk_options.jl -!test/**/*ref.* - -doc/build -doc/site -stable/ - -tmp/ -.idea -*.*~ -*.aux -*.log -*.out + +src/*.cov +test.jl +examples/figures/ +examples/*.md +examples/*.pdf +examples/*.html +examples/*.rst +examples/*.tex +test/**/cache +test/**/figures +test/documents/output/gadfly_formats_test.txt +test/**/*.tex +test/**/*.md +test/**/*.rst +test/**/*.html +test/**/*.pdf +test/**/*.png +test/**/chunk_options.jl +!test/**/*ref.* + +doc/build +doc/site +stable/ + +tmp/ +.idea +*.*~ +*.aux +*.log +*.out \#*\# .juliahistory diff --git a/README.md b/README.md index 4ae88f7..b63b46d 100644 --- a/README.md +++ b/README.md @@ -1,76 +1,76 @@ -# Weave - -[![Build Status](https://travis-ci.org/mpastell/Weave.jl.svg?branch=master)](https://travis-ci.org/mpastell/Weave.jl) -[![Build status](https://ci.appveyor.com/api/projects/status/r97pwi9x8ard6xk6/branch/master?svg=true)](https://ci.appveyor.com/project/mpastell/weave-jl/branch/master) -[![Coverage Status](https://img.shields.io/coveralls/mpastell/Weave.jl.svg)](https://coveralls.io/r/mpastell/Weave.jl?branch=master) - - -Weave is a scientific report generator/literate programming tool -for Julia. It resembles [Pweave](http://mpastell.com/pweave), Knitr, rmarkdown -and Sweave. - -You can write your documentation and code in input document using Noweb, -Markdown, Script syntax and use `weave` function to execute to document to capture results -and figures. - -**Current features** - +# Weave + +[![Build Status](https://travis-ci.org/mpastell/Weave.jl.svg?branch=master)](https://travis-ci.org/mpastell/Weave.jl) +[![Build status](https://ci.appveyor.com/api/projects/status/r97pwi9x8ard6xk6/branch/master?svg=true)](https://ci.appveyor.com/project/mpastell/weave-jl/branch/master) +[![Coverage Status](https://img.shields.io/coveralls/mpastell/Weave.jl.svg)](https://coveralls.io/r/mpastell/Weave.jl?branch=master) + + +Weave is a scientific report generator/literate programming tool +for Julia. It resembles [Pweave](http://mpastell.com/pweave), Knitr, rmarkdown +and Sweave. + +You can write your documentation and code in input document using Noweb, +Markdown, Script syntax and use `weave` function to execute to document to capture results +and figures. + +**Current features** + * Noweb, markdown or script syntax for input documents. -* Execute code as terminal or "script" chunks. -* Capture Plots, Gadfly, PyPlot and Winston figures. +* Execute code as terminal or "script" chunks. +* Capture Plots, Gadfly, PyPlot and Winston figures. * Supports LaTex, Pandoc, Github markdown, MultiMarkdown, Asciidoc and reStructuredText output * Publish markdown directly to html and pdf using Julia or Pandoc markdown. * Simple caching of results * Convert to and from IJulia notebooks -## Usage - -Run from julia using Gadfly for plots: - -```julia -using Weave -weave(Pkg.dir("Weave","examples","gadfly_sample.mdw")) -``` - -If you have Pandoc installed you can also weave directly to html and pdf. - -```julia -weave(Pkg.dir("Weave","examples","gadfly_md_sample.jmd"), informat="markdown", - out_path = :pwd, doctype = "md2html") -``` - -![Weave code and output](http://mpastell.com/images/weave_demo.png) - -## Documentation - -Documenter.jl with MKDocs generated documentation: - -[![](https://img.shields.io/badge/docs-stable-blue.svg)](https://mpastell.github.io/Weave.jl/stable) -[![](https://img.shields.io/badge/docs-latest-blue.svg)](https://mpastell.github.io/Weave.jl/latest) - -## Editor support - -I have made [language-weave](https://atom.io/packages/language-weave) package -for Atom to do the syntax highlighting correctly. - -Noweb documents work well with ESS as well, to set doc-mode for .mdw files to markdown -and code to Julia you can do: - -```clojure -(defun mdw-mode () - (ess-noweb-mode) - (setq ess-noweb-default-code-mode 'ess-julia-mode) - (setq ess-noweb-doc-mode 'markdown-mode)) - -(setq auto-mode-alist (append (list (cons "\\.mdw$" 'mdw-mode)) - auto-mode-alist)) -``` - - -## Contributing - -I will probably add new features to Weave when I need them myself or if they are requested and not too difficult to implement. You can contribute by opening issues on Github or implementing things yourself and making a pull request. I'd also appreciate example documents written using Weave to add to examples. - -## Contributors - -You can see the list of contributors on Github: https://github.com/mpastell/Weave.jl/graphs/contributors. Thanks for the important additions, fixes and comments. +## Usage + +Run from julia using Gadfly for plots: + +```julia +using Weave +weave(Pkg.dir("Weave","examples","gadfly_sample.mdw")) +``` + +If you have Pandoc installed you can also weave directly to html and pdf. + +```julia +weave(Pkg.dir("Weave","examples","gadfly_md_sample.jmd"), informat="markdown", + out_path = :pwd, doctype = "md2html") +``` + +![Weave code and output](http://mpastell.com/images/weave_demo.png) + +## Documentation + +Documenter.jl with MKDocs generated documentation: + +[![](https://img.shields.io/badge/docs-stable-blue.svg)](https://mpastell.github.io/Weave.jl/stable) +[![](https://img.shields.io/badge/docs-latest-blue.svg)](https://mpastell.github.io/Weave.jl/latest) + +## Editor support + +I have made [language-weave](https://atom.io/packages/language-weave) package +for Atom to do the syntax highlighting correctly. + +Noweb documents work well with ESS as well, to set doc-mode for .mdw files to markdown +and code to Julia you can do: + +```clojure +(defun mdw-mode () + (ess-noweb-mode) + (setq ess-noweb-default-code-mode 'ess-julia-mode) + (setq ess-noweb-doc-mode 'markdown-mode)) + +(setq auto-mode-alist (append (list (cons "\\.mdw$" 'mdw-mode)) + auto-mode-alist)) +``` + + +## Contributing + +I will probably add new features to Weave when I need them myself or if they are requested and not too difficult to implement. You can contribute by opening issues on Github or implementing things yourself and making a pull request. I'd also appreciate example documents written using Weave to add to examples. + +## Contributors + +You can see the list of contributors on Github: https://github.com/mpastell/Weave.jl/graphs/contributors. Thanks for the important additions, fixes and comments. diff --git a/REQUIRE b/REQUIRE index 26112bf..b57f9a7 100644 --- a/REQUIRE +++ b/REQUIRE @@ -1,8 +1,8 @@ -julia 0.5 -ArgParse -JLD -JSON -Highlights -Mustache -Documenter -YAML +julia 0.5 +ArgParse +JLD +JSON +Highlights +Mustache +Documenter +YAML diff --git a/examples/julia_sample.pdf b/examples/julia_sample.pdf deleted file mode 100644 index 39e11f7..0000000 Binary files a/examples/julia_sample.pdf and /dev/null differ diff --git a/src/config.jl b/src/config.jl index ae79368..d9cee06 100644 --- a/src/config.jl +++ b/src/config.jl @@ -1,88 +1,88 @@ - - -#Default options -const defaultParams = - Dict{Symbol,Any}(:plotlib => nothing, - :plotlib_set => false, - :storeresults => false, - :doc_number => 0, - :chunk_defaults => - Dict{Symbol,Any}( - :echo=> true, - :results=> "markup", - :hold => false, - :fig=> true, - :include=> true, - :eval => true, - :tangle => true, - :cache => false, - :fig_cap=> nothing, - #Size in inches - :fig_width => 6, - :fig_height => 4, - :fig_path=> "figures", - :dpi => 96, - :term=> false, - :display => false, - :prompt => "\njulia> ", - :name=> nothing, - :wrap=> true, - :line_width => 75, - :engine=> "julia", - #:option_AbstractString=> "", - #Defined in formats - :fig_ext => nothing, - :fig_pos=> nothing, - :fig_env=> nothing, - :out_width=> nothing, - :out_height=> nothing, - ) - ) -#This one can be changed at runtime, initially a copy of defaults -const rcParams = deepcopy(defaultParams) - -#Parameters set per document -const docParams =Dict{Symbol,Any}( - :fig_path=> nothing, - :fig_ext => nothing, - ) - - - - -""" -`set_chunk_defaults(opts::Dict{Symbol, Any})` - -Set default options for code chunks, use get_chunk_defaults -to see the current values. - -e.g. set default dpi to 200 and fig_width to 8 - -``` -julia> set_chunk_defaults(Dict{Symbol, Any}(:dpi => 200, fig_width => 8)) -``` -""" -function set_chunk_defaults(opts::Dict{Symbol, Any}) - merge!(rcParams[:chunk_defaults], opts) - return nothing -end - -""" -`get_chunk_defaults()` - -Get default options used for code chunks. -""" -function get_chunk_defaults() - return(rcParams[:chunk_defaults]) -end - -""" -`restore_chunk_defaults()` - -Restore Weave.jl default chunk options -""" -function restore_chunk_defaults() - rcParams[:chunk_defaults] = defaultParams[:chunk_defaults] - merge!(rcParams[:chunk_defaults], docParams) - return nothing -end + + +#Default options +const defaultParams = + Dict{Symbol,Any}(:plotlib => nothing, + :plotlib_set => false, + :storeresults => false, + :doc_number => 0, + :chunk_defaults => + Dict{Symbol,Any}( + :echo=> true, + :results=> "markup", + :hold => false, + :fig=> true, + :include=> true, + :eval => true, + :tangle => true, + :cache => false, + :fig_cap=> nothing, + #Size in inches + :fig_width => 6, + :fig_height => 4, + :fig_path=> "figures", + :dpi => 96, + :term=> false, + :display => false, + :prompt => "\njulia> ", + :name=> nothing, + :wrap=> true, + :line_width => 75, + :engine=> "julia", + #:option_AbstractString=> "", + #Defined in formats + :fig_ext => nothing, + :fig_pos=> nothing, + :fig_env=> nothing, + :out_width=> nothing, + :out_height=> nothing, + ) + ) +#This one can be changed at runtime, initially a copy of defaults +const rcParams = deepcopy(defaultParams) + +#Parameters set per document +const docParams =Dict{Symbol,Any}( + :fig_path=> nothing, + :fig_ext => nothing, + ) + + + + +""" +`set_chunk_defaults(opts::Dict{Symbol, Any})` + +Set default options for code chunks, use get_chunk_defaults +to see the current values. + +e.g. set default dpi to 200 and fig_width to 8 + +``` +julia> set_chunk_defaults(Dict{Symbol, Any}(:dpi => 200, fig_width => 8)) +``` +""" +function set_chunk_defaults(opts::Dict{Symbol, Any}) + merge!(rcParams[:chunk_defaults], opts) + return nothing +end + +""" +`get_chunk_defaults()` + +Get default options used for code chunks. +""" +function get_chunk_defaults() + return(rcParams[:chunk_defaults]) +end + +""" +`restore_chunk_defaults()` + +Restore Weave.jl default chunk options +""" +function restore_chunk_defaults() + rcParams[:chunk_defaults] = defaultParams[:chunk_defaults] + merge!(rcParams[:chunk_defaults], docParams) + return nothing +end