Weave.jl/previews/PR313/notebooks/index.html

3 lines
11 KiB
HTML

<!DOCTYPE html>
<html lang="en"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width, initial-scale=1.0"/><title>Working with Jupyter notebooks · Weave.jl</title><link rel="canonical" href="http://weavejl.mpastell.com/stable/notebooks/"/><link href="https://fonts.googleapis.com/css?family=Lato|Roboto+Mono" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.11.2/css/fontawesome.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.11.2/css/solid.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.11.2/css/brands.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.11.1/katex.min.css" rel="stylesheet" type="text/css"/><script>documenterBaseURL=".."</script><script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js" data-main="../assets/documenter.js"></script><script src="../siteinfo.js"></script><script src="../../versions.js"></script><link class="docs-theme-link" rel="stylesheet" type="text/css" href="../assets/themes/documenter-dark.css" data-theme-name="documenter-dark"/><link class="docs-theme-link" rel="stylesheet" type="text/css" href="../assets/themes/documenter-light.css" data-theme-name="documenter-light" data-theme-primary/><script src="../assets/themeswap.js"></script></head><body><div id="documenter"><nav class="docs-sidebar"><div class="docs-package-name"><span class="docs-autofit">Weave.jl</span></div><form class="docs-search" action="../search/"><input class="docs-search-query" id="documenter-search-query" name="q" type="text" placeholder="Search docs"/></form><ul class="docs-menu"><li><a class="tocitem" href="../">Weave.jl - Scientific Reports Using Julia</a></li><li><a class="tocitem" href="../getting_started/">Getting started</a></li><li><a class="tocitem" href="../usage/">Using Weave</a></li><li><a class="tocitem" href="../publish/">Publishing to HTML and PDF</a></li><li><a class="tocitem" href="../chunk_options/">Chunk options</a></li><li class="is-active"><a class="tocitem" href>Working with Jupyter notebooks</a><ul class="internal"><li><a class="tocitem" href="#Weaving-from-Jupyter-notebooks-1"><span>Weaving from Jupyter notebooks</span></a></li><li><a class="tocitem" href="#Output-to-Jupyter-notebooks-1"><span>Output to Jupyter notebooks</span></a></li><li><a class="tocitem" href="#Converting-between-formats-1"><span>Converting between formats</span></a></li></ul></li><li><a class="tocitem" href="../function_index/">Function index</a></li></ul><div class="docs-version-selector field has-addons"><div class="control"><span class="docs-label button is-static is-size-7">Version</span></div><div class="docs-selector control is-expanded"><div class="select is-fullwidth is-size-7"><select id="documenter-version-selector"></select></div></div></div></nav><div class="docs-main"><header class="docs-navbar"><nav class="breadcrumb"><ul class="is-hidden-mobile"><li class="is-active"><a href>Working with Jupyter notebooks</a></li></ul><ul class="is-hidden-tablet"><li class="is-active"><a href>Working with Jupyter notebooks</a></li></ul></nav><div class="docs-right"><a class="docs-edit-link" href="https://github.com/JunoLab/Weave.jl/blob/master/doc/src/notebooks.md" title="Edit on GitHub"><span class="docs-icon fab"></span><span class="docs-label is-hidden-touch">Edit on GitHub</span></a><a class="docs-settings-button fas fa-cog" id="documenter-settings-button" href="#" title="Settings"></a><a class="docs-sidebar-button fa fa-bars is-hidden-desktop" id="documenter-sidebar-button" href="#"></a></div></header><article class="content" id="documenter-page"><h1 id="Working-with-Jupyter-notebooks-1"><a class="docs-heading-anchor" href="#Working-with-Jupyter-notebooks-1">Working with Jupyter notebooks</a><a class="docs-heading-anchor-permalink" href="#Working-with-Jupyter-notebooks-1" title="Permalink"></a></h1><h2 id="Weaving-from-Jupyter-notebooks-1"><a class="docs-heading-anchor" href="#Weaving-from-Jupyter-notebooks-1">Weaving from Jupyter notebooks</a><a class="docs-heading-anchor-permalink" href="#Weaving-from-Jupyter-notebooks-1" title="Permalink"></a></h2><p>Weave supports using <a href="https://jupyter.org/">Jupyter Notebook</a>s as input format. This means you can <a href="../usage/#Weave.weave"><code>weave</code></a> notebooks to any supported formats; by default, it will be weaved to HTML.</p><pre><code class="language-julia">weave(&quot;notebook.ipynb&quot;) # will be weaved to HTML</code></pre><div class="admonition is-warning"><header class="admonition-header">Warning</header><div class="admonition-body"><p>You can&#39;t use chunk options with notebooks.</p></div></div><h2 id="Output-to-Jupyter-notebooks-1"><a class="docs-heading-anchor" href="#Output-to-Jupyter-notebooks-1">Output to Jupyter notebooks</a><a class="docs-heading-anchor-permalink" href="#Output-to-Jupyter-notebooks-1" title="Permalink"></a></h2><p>As of Weave 0.5.1. there is new <a href="#Weave.notebook"><code>notebook</code></a> method to convert Weave documents to Jupyter notebooks using <a href="http://nbconvert.readthedocs.io/en/latest/execute_api.html">nbconvert</a>.</p><article class="docstring"><header><a class="docstring-binding" id="Weave.notebook" href="#Weave.notebook"><code>Weave.notebook</code></a><span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">notebook(source::AbstractString; kwargs...)</code></pre><p>Convert Weave document <code>source</code> to Jupyter Notebook and execute the code using <a href="https://nbconvert.readthedocs.io/en/latest/"><code>nbconvert</code></a>. <strong>Ignores</strong> all chunk options.</p><p><strong>Keyword options</strong></p><ul><li><code>out_path::Union{Symbol,AbstractString} = :pwd</code>: Path where the output is generated can be either of:<ul><li><code>:doc</code>: Path of the source document</li><li><code>:pwd</code>: Julia working directory (default)</li><li><code>&quot;somepath&quot;</code>: <code>String</code> of output directory e.g. <code>&quot;~/outdir&quot;</code>, or of filename e.g. <code>&quot;~/outdir/outfile.tex&quot;</code></li></ul></li><li><code>timeout = -1</code>: nbconvert cell timeout in seconds. Defaults to <code>-1</code> (no timeout)</li><li><code>nbconvert_options::AbstractString = &quot;&quot;</code>: <code>String</code> of additional options to pass to nbconvert, such as <code>&quot;--allow-errors&quot;</code></li><li><code>jupyter_path::AbstractString = &quot;jupyter&quot;</code>: Path/command for the Jupyter you want to use. Defaults to <code>&quot;jupyter&quot;</code>, which runs whatever is linked/alias to that</li></ul><div class="admonition is-warning"><header class="admonition-header">Warning</header><div class="admonition-body"><p>The code is <em><strong>not</strong></em> executed by Weave, but by <a href="https://nbconvert.readthedocs.io/en/latest/"><code>nbconvert</code></a>. This means that the output doesn&#39;t necessarily always work properly; see <a href="https://github.com/mpastell/Weave.jl/issues/116">#116</a>.</p></div></div><div class="admonition is-info"><header class="admonition-header">Note</header><div class="admonition-body"><p>In order to <em>just</em> convert Weave document to Jupyter Notebook, use <a href="#Weave.convert_doc-Tuple{AbstractString,AbstractString}"><code>convert_doc</code></a> instead.</p></div></div></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JunoLab/Weave.jl/blob/637075d44c0d82dde7dc9b1e7d39320bfde02a33/src/Weave.jl#L209-L233">source</a></section></article><p>You can specify <code>jupyter</code> used to execute the notebook with the <code>jupyter_path</code> keyword argument (this defaults to the <code>&quot;jupyter&quot;</code>, i.e. whatever you have linked to that location).</p><p>Instead, you might want to use the <a href="#Weave.convert_doc-Tuple{AbstractString,AbstractString}"><code>convert_doc</code></a> method below and run the code in Jupyter.</p><h2 id="Converting-between-formats-1"><a class="docs-heading-anchor" href="#Converting-between-formats-1">Converting between formats</a><a class="docs-heading-anchor-permalink" href="#Converting-between-formats-1" title="Permalink"></a></h2><p>You can convert between all supported input formats using the <a href="#Weave.convert_doc-Tuple{AbstractString,AbstractString}"><code>convert_doc</code></a> function.</p><p>To convert from script to notebook:</p><pre><code class="language-julia">convert_doc(&quot;examples/FIR_design.jl&quot;, &quot;FIR_design.ipynb&quot;)</code></pre><p>and from notebook to Markdown use:</p><pre><code class="language-julia">convert_doc(&quot;FIR_design.ipynb&quot;, &quot;FIR_design.jmd&quot;)</code></pre><article class="docstring"><header><a class="docstring-binding" id="Weave.convert_doc-Tuple{AbstractString,AbstractString}" href="#Weave.convert_doc-Tuple{AbstractString,AbstractString}"><code>Weave.convert_doc</code></a><span class="docstring-category">Method</span></header><section><div><pre><code class="language-julia">convert_doc(infile::AbstractString, outfile::AbstractString; format::Union{Nothing,AbstractString} = nothing)</code></pre><p>Convert Weave documents between different formats</p><ul><li><code>infile</code>: Path of the input document</li><li><code>outfile</code>: Path of the output document</li><li><code>format = nothing</code>: Output document format (optional). It will be detected automatically from the <code>outfile</code> extension. You can also specify either of <code>&quot;script&quot;</code>, <code>&quot;markdown&quot;</code>, <code>&quot;notebook&quot;</code>, or <code>&quot;noweb&quot;</code></li></ul></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JunoLab/Weave.jl/blob/637075d44c0d82dde7dc9b1e7d39320bfde02a33/src/writers.jl#L29-L37">source</a></section></article></article><nav class="docs-footer"><a class="docs-footer-prevpage" href="../chunk_options/">« Chunk options</a><a class="docs-footer-nextpage" href="../function_index/">Function index »</a></nav></div><div class="modal" id="documenter-settings"><div class="modal-background"></div><div class="modal-card"><header class="modal-card-head"><p class="modal-card-title">Settings</p><button class="delete"></button></header><section class="modal-card-body"><p><label class="label">Theme</label><div class="select"><select id="documenter-themepicker"><option value="documenter-light">documenter-light</option><option value="documenter-dark">documenter-dark</option></select></div></p><hr/><p>This document was generated with <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> on <span class="colophon-date" title="Saturday 9 May 2020 12:35">Saturday 9 May 2020</span>. Using Julia version 1.4.1.</p></section><footer class="modal-card-foot"></footer></div></div></div></body></html>