From 1f9802037bb0ae3ce5c3a9f0fb758090d5235dc8 Mon Sep 17 00:00:00 2001 From: zeptodoctor <44736852+zeptodoctor@users.noreply.github.com> Date: Sat, 9 May 2020 12:39:33 +0000 Subject: [PATCH] build based on 637075d --- previews/PR313/chunk_options/index.html | 2 +- .../FIR_design_plots_4_1.png | Bin .../FIR_design_plots_5_1.png | Bin .../{jl_DLk7ca => jl_yiq8BG}/FIR_design_4_1.png | Bin .../{jl_DLk7ca => jl_yiq8BG}/FIR_design_5_1.png | Bin previews/PR313/function_index/index.html | 2 +- previews/PR313/getting_started/index.html | 2 +- previews/PR313/index.html | 2 +- previews/PR313/notebooks/index.html | 2 +- previews/PR313/publish/index.html | 2 +- previews/PR313/search/index.html | 2 +- previews/PR313/usage/index.html | 2 +- 12 files changed, 8 insertions(+), 8 deletions(-) rename previews/PR313/examples/{jl_O5uNM3 => jl_8F3h5h}/FIR_design_plots_4_1.png (100%) rename previews/PR313/examples/{jl_O5uNM3 => jl_8F3h5h}/FIR_design_plots_5_1.png (100%) rename previews/PR313/examples/{jl_DLk7ca => jl_yiq8BG}/FIR_design_4_1.png (100%) rename previews/PR313/examples/{jl_DLk7ca => jl_yiq8BG}/FIR_design_5_1.png (100%) diff --git a/previews/PR313/chunk_options/index.html b/previews/PR313/chunk_options/index.html index 16670a4..b5dba1d 100644 --- a/previews/PR313/chunk_options/index.html +++ b/previews/PR313/chunk_options/index.html @@ -2,4 +2,4 @@ Chunk options · Weave.jl

Chunk options

I've mostly followed Knitr's naming for chunk options, but not all options are implemented.

Options are separated using ";" and need to be valid Julia expressions. Example: markdown code chunk that saves and displays a 12 cm wide image and hides the source code:

julia; out_width="12cm"; echo=false

Weave currently supports the following chunk options with the following defaults:

Options for code

  • echo = true: Echo the code in the output document. If false the source code will be hidden.
  • results = "markup": The output format of the printed results. "markup" for literal block, "hidden" for hidden results, or anything else for raw output (I tend to use "tex" for Latex and "rst" for rest). Raw output is useful if you want to e.g. create tables from code chunks.
  • eval = true: Evaluate the code chunk. If false the chunk won’t be executed.
  • term = false: If true the output emulates a REPL session. Otherwise only stdout and figures will be included in output.
  • label = nothing: Chunk label, will be used for figure labels in Latex as fig:label.
  • wrap = true: Wrap long lines from output.
  • line_width = 75: Line width for wrapped lines.
  • cache = false: Cache results, depending on cache parameter on weave function.
  • hold = false: Hold all results until the end of the chunk.
  • tangle = true: Set tangle to false to exclude chunk from tangled code.

Options for figures

  • fig_width = 6: Figure width passed to plotting library.
  • fig_height = 4: Figure height passed to plotting library.
  • out_width: Width of saved figure in output markup e.g. "50%", "12cm", 0.5\linewidth
  • out_height: Height of saved figure in output markup
  • dpi = 96: Resolution of saved figures.
  • fig_cap: Figure caption.
  • label: Chunk label, will be used for figure labels in Latex as fig:label
  • fig_ext: File extension (format) of saved figures.
  • fig_pos = "!h": Figure position in Latex, e.g.: "ht".
  • fig_env = "figure": Figure environment in Latex.

Set default chunk options

You can set the default chunk options (and weave arguments) for a document using the YAML header options field. E.g. to set the default out_width of all figures you can use:

---
 options:
       out_width : 50%
----

You can also set or change the default chunk options for a document either before weave using the set_chunk_defaults function.

Weave.set_chunk_defaultsFunction
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))
source
+---

You can also set or change the default chunk options for a document either before weave using the set_chunk_defaults function.

Weave.set_chunk_defaultsFunction
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))
source
Weave.get_chunk_defaultsFunction
get_chunk_defaults()

Get default options used for code chunks.

source
Weave.restore_chunk_defaultsFunction
restore_chunk_defaults()

Restore Weave.jl default chunk options.

source
diff --git a/previews/PR313/examples/jl_O5uNM3/FIR_design_plots_4_1.png b/previews/PR313/examples/jl_8F3h5h/FIR_design_plots_4_1.png similarity index 100% rename from previews/PR313/examples/jl_O5uNM3/FIR_design_plots_4_1.png rename to previews/PR313/examples/jl_8F3h5h/FIR_design_plots_4_1.png diff --git a/previews/PR313/examples/jl_O5uNM3/FIR_design_plots_5_1.png b/previews/PR313/examples/jl_8F3h5h/FIR_design_plots_5_1.png similarity index 100% rename from previews/PR313/examples/jl_O5uNM3/FIR_design_plots_5_1.png rename to previews/PR313/examples/jl_8F3h5h/FIR_design_plots_5_1.png diff --git a/previews/PR313/examples/jl_DLk7ca/FIR_design_4_1.png b/previews/PR313/examples/jl_yiq8BG/FIR_design_4_1.png similarity index 100% rename from previews/PR313/examples/jl_DLk7ca/FIR_design_4_1.png rename to previews/PR313/examples/jl_yiq8BG/FIR_design_4_1.png diff --git a/previews/PR313/examples/jl_DLk7ca/FIR_design_5_1.png b/previews/PR313/examples/jl_yiq8BG/FIR_design_5_1.png similarity index 100% rename from previews/PR313/examples/jl_DLk7ca/FIR_design_5_1.png rename to previews/PR313/examples/jl_yiq8BG/FIR_design_5_1.png diff --git a/previews/PR313/function_index/index.html b/previews/PR313/function_index/index.html index ccfffd5..1338541 100644 --- a/previews/PR313/function_index/index.html +++ b/previews/PR313/function_index/index.html @@ -1,2 +1,2 @@ -Function index · Weave.jl
+Function index · Weave.jl
diff --git a/previews/PR313/getting_started/index.html b/previews/PR313/getting_started/index.html index b23245b..0fff6ac 100644 --- a/previews/PR313/getting_started/index.html +++ b/previews/PR313/getting_started/index.html @@ -20,4 +20,4 @@ weave( joinpath(dirname(pathof(Weave)), "../examples", "FIR_design.jmd"); doctype = "pandoc", out_path = :pwd -) +) diff --git a/previews/PR313/index.html b/previews/PR313/index.html index 89b233d..63c0f82 100644 --- a/previews/PR313/index.html +++ b/previews/PR313/index.html @@ -1,2 +1,2 @@ -Weave.jl - Scientific Reports Using Julia · Weave.jl

Weave.jl - Scientific Reports Using Julia

This is the documentation of Weave.jl. Weave is a scientific report generator/literate programming tool for Julia. It resembles Pweave, knitr, R Markdown, and Sweave.

Current features

  • Publish markdown directly to HTML and PDF using Julia or Pandoc
  • Execute code as in terminal or in a unit of code chunk
  • Capture Plots.jl or Gadfly.jl figures
  • Supports various input format: Markdown, Noweb, Jupyter Notebook, and ordinal Julia script
  • Conversions between those input formats
  • Supports various output document formats: HTML, PDF, GitHub markdown, Jupyter Notebook, MultiMarkdown, Asciidoc and reStructuredText
  • Simple caching of results

Weave in Juno demo

Contents

+Weave.jl - Scientific Reports Using Julia · Weave.jl

Weave.jl - Scientific Reports Using Julia

This is the documentation of Weave.jl. Weave is a scientific report generator/literate programming tool for Julia. It resembles Pweave, knitr, R Markdown, and Sweave.

Current features

  • Publish markdown directly to HTML and PDF using Julia or Pandoc
  • Execute code as in terminal or in a unit of code chunk
  • Capture Plots.jl or Gadfly.jl figures
  • Supports various input format: Markdown, Noweb, Jupyter Notebook, and ordinal Julia script
  • Conversions between those input formats
  • Supports various output document formats: HTML, PDF, GitHub markdown, Jupyter Notebook, MultiMarkdown, Asciidoc and reStructuredText
  • Simple caching of results

Weave in Juno demo

Contents

diff --git a/previews/PR313/notebooks/index.html b/previews/PR313/notebooks/index.html index 870209a..8dd80d1 100644 --- a/previews/PR313/notebooks/index.html +++ b/previews/PR313/notebooks/index.html @@ -1,2 +1,2 @@ -Working with Jupyter notebooks · Weave.jl

Working with Jupyter notebooks

Weaving from Jupyter notebooks

Weave supports using Jupyter Notebooks as input format. This means you can weave notebooks to any supported formats; by default, it will be weaved to HTML.

weave("notebook.ipynb") # will be weaved to HTML
Warning

You can't use chunk options with notebooks.

Output to Jupyter notebooks

As of Weave 0.5.1. there is new notebook method to convert Weave documents to Jupyter notebooks using nbconvert.

Weave.notebookFunction
notebook(source::AbstractString; kwargs...)

Convert Weave document source to Jupyter Notebook and execute the code using nbconvert. Ignores all chunk options.

Keyword options

  • out_path::Union{Symbol,AbstractString} = :pwd: Path where the output is generated can be either of:
    • :doc: Path of the source document
    • :pwd: Julia working directory (default)
    • "somepath": String of output directory e.g. "~/outdir", or of filename e.g. "~/outdir/outfile.tex"
  • timeout = -1: nbconvert cell timeout in seconds. Defaults to -1 (no timeout)
  • nbconvert_options::AbstractString = "": String of additional options to pass to nbconvert, such as "--allow-errors"
  • jupyter_path::AbstractString = "jupyter": Path/command for the Jupyter you want to use. Defaults to "jupyter", which runs whatever is linked/alias to that
Warning

The code is not executed by Weave, but by nbconvert. This means that the output doesn't necessarily always work properly; see #116.

Note

In order to just convert Weave document to Jupyter Notebook, use convert_doc instead.

source

You can specify jupyter used to execute the notebook with the jupyter_path keyword argument (this defaults to the "jupyter", i.e. whatever you have linked to that location).

Instead, you might want to use the convert_doc method below and run the code in Jupyter.

Converting between formats

You can convert between all supported input formats using the convert_doc function.

To convert from script to notebook:

convert_doc("examples/FIR_design.jl", "FIR_design.ipynb")

and from notebook to Markdown use:

convert_doc("FIR_design.ipynb", "FIR_design.jmd")
Weave.convert_docMethod
convert_doc(infile::AbstractString, outfile::AbstractString; format::Union{Nothing,AbstractString} = nothing)

Convert Weave documents between different formats

  • infile: Path of the input document
  • outfile: Path of the output document
  • format = nothing: Output document format (optional). It will be detected automatically from the outfile extension. You can also specify either of "script", "markdown", "notebook", or "noweb"
source
+Working with Jupyter notebooks · Weave.jl

Working with Jupyter notebooks

Weaving from Jupyter notebooks

Weave supports using Jupyter Notebooks as input format. This means you can weave notebooks to any supported formats; by default, it will be weaved to HTML.

weave("notebook.ipynb") # will be weaved to HTML
Warning

You can't use chunk options with notebooks.

Output to Jupyter notebooks

As of Weave 0.5.1. there is new notebook method to convert Weave documents to Jupyter notebooks using nbconvert.

Weave.notebookFunction
notebook(source::AbstractString; kwargs...)

Convert Weave document source to Jupyter Notebook and execute the code using nbconvert. Ignores all chunk options.

Keyword options

  • out_path::Union{Symbol,AbstractString} = :pwd: Path where the output is generated can be either of:
    • :doc: Path of the source document
    • :pwd: Julia working directory (default)
    • "somepath": String of output directory e.g. "~/outdir", or of filename e.g. "~/outdir/outfile.tex"
  • timeout = -1: nbconvert cell timeout in seconds. Defaults to -1 (no timeout)
  • nbconvert_options::AbstractString = "": String of additional options to pass to nbconvert, such as "--allow-errors"
  • jupyter_path::AbstractString = "jupyter": Path/command for the Jupyter you want to use. Defaults to "jupyter", which runs whatever is linked/alias to that
Warning

The code is not executed by Weave, but by nbconvert. This means that the output doesn't necessarily always work properly; see #116.

Note

In order to just convert Weave document to Jupyter Notebook, use convert_doc instead.

source

You can specify jupyter used to execute the notebook with the jupyter_path keyword argument (this defaults to the "jupyter", i.e. whatever you have linked to that location).

Instead, you might want to use the convert_doc method below and run the code in Jupyter.

Converting between formats

You can convert between all supported input formats using the convert_doc function.

To convert from script to notebook:

convert_doc("examples/FIR_design.jl", "FIR_design.ipynb")

and from notebook to Markdown use:

convert_doc("FIR_design.ipynb", "FIR_design.jmd")
Weave.convert_docMethod
convert_doc(infile::AbstractString, outfile::AbstractString; format::Union{Nothing,AbstractString} = nothing)

Convert Weave documents between different formats

  • infile: Path of the input document
  • outfile: Path of the output document
  • format = nothing: Output document format (optional). It will be detected automatically from the outfile extension. You can also specify either of "script", "markdown", "notebook", or "noweb"
source
diff --git a/previews/PR313/publish/index.html b/previews/PR313/publish/index.html index b0ac65b..6c70697 100644 --- a/previews/PR313/publish/index.html +++ b/previews/PR313/publish/index.html @@ -6,4 +6,4 @@ date: 15th December 2016 ---

Here are sample input and outputs:

They are generated as follows:

weave(joinpath(dirname(pathof(Weave)), "../examples", "FIR_design_plots.jl")) # default to md2html output format
 weave(joinpath(dirname(pathof(Weave)), "../examples", "FIR_design_plots.jl"), doctype = "md2pdf")
Note

"md2html" and "md2pdf" assume Julia markdown format as an input, while pandoc2pdf and pandoc2html assume Noweb input format (i.e. Pandoc markdown).

Templates

You can use a custom template with md2html and md2pdf formats with template keyword option, e.g.: weave("FIR_design_plots.jl", template = "custom.tpl".

As starting point, you can use the existing templates:

Templates are rendered using Mustache.jl.

Supported Markdown syntax

The markdown variant used by Weave is Julia markdown. In addition Weave supports few additional Markdown features:

Comments

You can add comments using html syntax: <!-- -->

Multiline equations

You can add multiline equations using:

$$
 x^2 = x*x
-$$
+$$ diff --git a/previews/PR313/search/index.html b/previews/PR313/search/index.html index ad51401..50b3f1e 100644 --- a/previews/PR313/search/index.html +++ b/previews/PR313/search/index.html @@ -1,2 +1,2 @@ -Search · Weave.jl

Loading search...

    +Search · Weave.jl

    Loading search...

      diff --git a/previews/PR313/usage/index.html b/previews/PR313/usage/index.html index 21497e1..15b5531 100644 --- a/previews/PR313/usage/index.html +++ b/previews/PR313/usage/index.html @@ -43,4 +43,4 @@ options: ---

      Passing arguments to documents

      You can pass arguments as Dict to the weaved document using the args argument to weave. The arguments will be available as WEAVE_ARGS variable in the document.

      This makes it possible to create the same report easily for e.g. different date ranges of input data from a database or from files with similar format giving the filename as input.

      In order to pass a filename to a document you need call weave using:

      weave("mydoc.jmd", args = Dict("filename" => "somedata.h5"))

      and you can access the filename from document as follows:

       ```julia
        print(WEAVE_ARGS["filename"])
        ```

      You can use the out_path argument to control the name of the output document.

      Include Weave document in Julia

      You can call include_weave on a Weave document to run the contents of all code chunks in Julia.

      Weave.include_weaveFunction
      include_weave(source::AbstractString, informat::Union{Symbol,AbstractString} = :auto)
      -include_weave(m::Module, source::AbstractString, informat::Union{Symbol,AbstractString} = :auto)

      Include code from Weave document calling include_string on all code from doc. Code is run in the path of the include document.

      source
      +include_weave(m::Module, source::AbstractString, informat::Union{Symbol,AbstractString} = :auto)

      Include code from Weave document calling include_string on all code from doc. Code is run in the path of the include document.

      source