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. You can't use chunk options with notebooks.

weave("notebook.ipynb")

Output to Jupyter notebooks

As of Weave 0.5.1. there is new notebook method to convert Weave documents to Jupyter notebooks using nbconvert. The code is not executed by Weave and the output doesn't always work properly, see #116.

Weave.notebookFunction
notebook(source::String; out_path=:pwd, timeout=-1, nbconvert_options="", jupyter_path = "jupyter")

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

  • out_path: Path where the output is generated. Can be: :doc: Path of the source document, :pwd: Julia working directory, "somepath": Path as a String e.g "/home/mpastell/weaveout"
  • timeout: nbconvert cell timeout in seconds. Defaults to -1 (no timeout)
  • nbconvert_options: string of additional options to pass to nbconvert, such as --allow-errors
  • jupyter_path: Path/command for the Jupyter you want to use. Defaults to "jupyter," which runs whatever is linked/alias to that.
source

You might want to use the convert_doc method below instead and run the code in Jupyter.

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

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 notebooks to markdown use:

convert_doc("FIR_design.ipynb", "FIR_design.jmd")
Weave.convert_docMethod

convert_doc(infile::AbstractString, outfile::AbstractString; format = nothing)

Convert Weave documents between different formats

  • infile = Name of the input document
  • outfile = Name of the output document
  • format = Output format (optional). Detected from outfile extension, but can be set to "script", "markdown", "notebook" or "noweb".
source