First version of documentation with Documenter.jl and mkdocs. Remove Docile depency

pull/35/head
Matti Pastell 2016-04-19 15:23:48 +03:00
parent 3c1e0e87a9
commit f50c94d0ed
9 changed files with 86 additions and 40 deletions

4
.gitignore vendored
View File

@ -19,7 +19,9 @@ test/documents/*.pdf
test/documents/chunk_options.jl test/documents/chunk_options.jl
!test/documents/*ref.* !test/documents/*ref.*
doc/build
doc/site
stable/
tmp/ tmp/
.idea .idea

View File

@ -26,7 +26,9 @@ weave(Pkg.dir("Weave","examples","gadfly_sample.mdw"))
## Documentation ## Documentation
Lexicon.jl generated documentation for [v0.0.4](http://mpastell.github.io/Weave.jl/v0.0.4/) and [master](http://mpastell.github.io/Weave.jl/master/). Documenter.jl with MKdDocs generated documentation:
[![](https://img.shields.io/badge/docs-stable-blue.svg)](https://mpastell.github.io/Weave.jl/stable)
## Contributing ## Contributing

View File

@ -1,5 +1,4 @@
julia 0.4 julia 0.4
Compat Compat
ArgParse ArgParse
Docile
JSON JSON

3
doc/make.jl Normal file
View File

@ -0,0 +1,3 @@
using Documenter, Weave
makedocs(modules = Weave)

29
doc/mkdocs.yml Normal file
View File

@ -0,0 +1,29 @@
site_name: Weave.jl - Scientific Reports Using Julia
site_author: Matti Pastell
copyright: Matti Pastell 2016
repo_url: https://github.com/mpastell/Weave.jl
theme: material
extra:
palette:
primary: 'indigo'
accent: 'blue'
extra_css:
- assets/Documenter.css
extra_javascript:
- https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML
- assets/mathjaxhelper.js
markdown_extensions:
- extra
- tables
- fenced_code
- mdx_math
docs_dir: 'build'
pages:
- Home: index.md

View File

@ -1,4 +1,6 @@
# Intro
This is the documentation of [Weave.jl](http://github.com/mpastell/weave.jl). Weave is a scientific report generator/literate programming tool This is the documentation of [Weave.jl](http://github.com/mpastell/weave.jl). Weave is a scientific report generator/literate programming tool
for Julia. It resembles [Pweave](http://mpastell.com/pweave) and, Knitr for Julia. It resembles [Pweave](http://mpastell.com/pweave) and, Knitr
and Sweave. and Sweave.
@ -9,9 +11,13 @@ You can write your documentation and code in input document using Nowed or Markd
* Noweb or markdown syntax for input documents. * Noweb or markdown syntax for input documents.
* Execute code as terminal or "script" chunks. * Execute code as terminal or "script" chunks.
* Capture PyPlot, Gadfly or Winston figures. * Capture PyPlot or Gadfly figures.
* Supports LaTex, Pandoc and Github markdown and reStructuredText output * Supports LaTex, Pandoc and Github markdown and reStructuredText output
{contents}
# Document syntax # Document syntax
Weave uses noweb or markdown syntax for defining the code chunks and documentation chunks. Weave uses noweb or markdown syntax for defining the code chunks and documentation chunks.
@ -76,6 +82,8 @@ Weave currently supports the following chunk options with the following defaults
# Usage # Usage
## Weave
Run from julia using Gadfly for plots: Run from julia using Gadfly for plots:
```julia ```julia
@ -83,28 +91,38 @@ using Weave
weave(Pkg.dir("Weave","examples","gadfly_sample.mdw")) weave(Pkg.dir("Weave","examples","gadfly_sample.mdw"))
``` ```
Using Winston for plots (Julia 0.3 and Weave.jl 0.04 only):
```julia
weave(Pkg.dir("Weave","examples","winston_sample.mdw"),
plotlib="Winston", doctype="pandoc")
```
Using PyPlot: Using PyPlot:
```julia ```julia
weave(Pkg.dir("Weave","examples","julia_sample.mdw"), plotlib="PyPlot") weave(Pkg.dir("Weave","examples","julia_sample.mdw"), plotlib="PyPlot")
``` ```
## File formats {docs}
weave(source)
## Tangle
Tangling extracts the code from document:
{docs}
tangle(source)
## Supported formats
You can get a list of supported output formats: You can get a list of supported output formats:
```julia ```
julia> list_out_formats() julia> list_out_formats()
pandoc: Pandoc markdown pandoc: Pandoc markdown
rst: reStructuredText and Sphinx rst: reStructuredText and Sphinx
texminted: Latex using minted for highlighting texminted: Latex using minted for highlighting
github: Github markdown github: Github markdown
asciidoc: AsciiDoc
tex: Latex with custom code environments tex: Latex with custom code environments
``` ```
# Index
{index}

View File

@ -1,8 +1,5 @@
module Weave module Weave
using Compat using Compat
using Docile
@docstrings(manual = ["../doc/manual.md"])
#Contains report global properties #Contains report global properties
type Report <: Display type Report <: Display
@ -37,7 +34,11 @@ function Base.display(doc::Report, data)
end end
end end
@doc "List supported output formats" -> """
list_out_formats()
List supported output formats
"""
function list_out_formats() function list_out_formats()
for format = keys(formats) for format = keys(formats)
println(string(format,": ", formats[format].description)) println(string(format,": ", formats[format].description))
@ -45,18 +46,15 @@ function list_out_formats()
end end
@doc """ """
Tangle source code from input document to .jl file.
**parameters:**
```julia
tangle(source ; out_path=:doc, informat="noweb") tangle(source ; out_path=:doc, informat="noweb")
```
Tangle source code from input document to .jl file.
* `informat`: `"noweb"` of `"markdown"` * `informat`: `"noweb"` of `"markdown"`
* `out_path`: Path where the output is generated. Can be: `:doc`: Path of the source document, `:pwd`: Julia working directory, * `out_path`: Path where the output is generated. Can be: `:doc`: Path of the source document, `:pwd`: Julia working directory,
`"somepath"`: Path as a AbstractString e.g `"/home/mpastell/weaveout"` `"somepath"`: Path as a AbstractString e.g `"/home/mpastell/weaveout"`
"""-> """
function tangle(source ; out_path=:doc, informat="noweb") function tangle(source ; out_path=:doc, informat="noweb")
doc = read_doc(source, informat) doc = read_doc(source, informat)
cwd = get_cwd(doc, out_path) cwd = get_cwd(doc, out_path)
@ -74,14 +72,11 @@ function tangle(source ; out_path=:doc, informat="noweb")
info("Writing to file $(doc.basename).jl") info("Writing to file $(doc.basename).jl")
end end
@doc """ """
Weave an input document to output file.
**parameters:**
```julia
weave(source ; doctype = "pandoc", plotlib="Gadfly", weave(source ; doctype = "pandoc", plotlib="Gadfly",
informat="noweb", out_path=:doc, fig_path = "figures", fig_ext = nothing) informat="noweb", out_path=:doc, fig_path = "figures", fig_ext = nothing)
```
Weave an input document to output file.
* `doctype`: see `list_out_formats()` * `doctype`: see `list_out_formats()`
* `plotlib`: `"PyPlot"`, `"Gadfly"`, or `"Winston"` * `plotlib`: `"PyPlot"`, `"Gadfly"`, or `"Winston"`
@ -95,7 +90,7 @@ weave(source ; doctype = "pandoc", plotlib="Gadfly",
`:user` = cache based on chunk options, `:refresh`, run all code chunks and save new cache. `:user` = cache based on chunk options, `:refresh`, run all code chunks and save new cache.
**Note:** Run Weave from terminal and not using IJulia, Juno or ESS, they tend to mess with capturing output. **Note:** Run Weave from terminal and not using IJulia, Juno or ESS, they tend to mess with capturing output.
""" -> """
function weave(source ; doctype = "pandoc", plotlib="Gadfly", function weave(source ; doctype = "pandoc", plotlib="Gadfly",
informat="noweb", out_path=:doc, fig_path = "figures", fig_ext = nothing, informat="noweb", out_path=:doc, fig_path = "figures", fig_ext = nothing,
cache_path = "cache", cache=:off) cache_path = "cache", cache=:off)

View File

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

View File

@ -1,11 +1,9 @@
@doc """ """
Run code chunks and capture output from parsed document. run(doc::WeaveDoc; doctype = "pandoc", plotlib="Gadfly", informat="noweb",
```julia
function run(doc::WeaveDoc; doctype = "pandoc", plotlib="Gadfly", informat="noweb",
out_path=:doc, fig_path = "figures", fig_ext = nothing, out_path=:doc, fig_path = "figures", fig_ext = nothing,
cache_path = "cache", cache = :off) cache_path = "cache", cache = :off)
```
Run code chunks and capture output from parsed document.
* `doctype`: see `list_out_formats()` * `doctype`: see `list_out_formats()`
* `plotlib`: `"PyPlot"`, `"Gadfly"`, or `"Winston"` * `plotlib`: `"PyPlot"`, `"Gadfly"`, or `"Winston"`
@ -19,7 +17,7 @@ function run(doc::WeaveDoc; doctype = "pandoc", plotlib="Gadfly", informat="nowe
`:user` = cache based on chunk options, `:refresh`, run all code chunks and save new cache. `:user` = cache based on chunk options, `:refresh`, run all code chunks and save new cache.
**Note:** Run command from terminal and not using IJulia, Juno or ESS, they tend to mess with capturing output. **Note:** Run command from terminal and not using IJulia, Juno or ESS, they tend to mess with capturing output.
""" -> """
function Base.run(doc::WeaveDoc; doctype = "pandoc", plotlib="Gadfly", informat="noweb", function Base.run(doc::WeaveDoc; doctype = "pandoc", plotlib="Gadfly", informat="noweb",
out_path=:doc, fig_path = "figures", fig_ext = nothing, out_path=:doc, fig_path = "figures", fig_ext = nothing,
cache_path = "cache", cache = :off) cache_path = "cache", cache = :off)