The new Jupyter Book stack�a more powerful, modular, re-usable toolchain
Chris Holdgraf, 2i2c and UC Berkeley
�
bit.ly/2020-jc-jupyter-book-stack
�
The Executable Book Project
executablebooks.org
IAB
QuantEcon
ipypublish
�
What is Jupyter Book?
Build an online book with
Jupyter Notebooks and Markdown
jupyterbook.org
�
To learn more about Jupyter Book, see jupyterbook.org
This talk is about the tech stack underneath the re-write
The Jupyter Book re-write
�
nbconvert
Old Jupyter Book engine
New Jupyter Book engine
�
The new Jupyter Book stack is...
�
an overview of the stack
4. build output
.ipynb
.md
Partial Sphinx
AST
HTML
Latex
Website
Full Sphinx AST
execute
parse
2. cache and execute
convert
insert
outputs
7. controller process
ipynb+assets
build
An overview of the Jupyter Book build process
�
parsing and writing markdown in Sphinx
Brings the features of reStructuredText to Markdown
Is a superset of CommonMark -> all pre-existing Jupyter markdown is valid MyST Markdown
Has extended syntax for extra functionality for publishing and computational documents
MyST Markdown
�
(some) extended MyST syntax
�
A Python implementation of the popular markdown-it JS package
Configurable syntax: you can add new rules and even replace existing ones.
Pluggable: Adds syntax extensions to extend the parser (see the plugin list)
markdown-it-py
markdown-it-py.readthedocs.io
�
Example of markdown-it-py
�
myst-parser.readthedocs.io
A (CommonMark / MyST) Markdown parser for Sphinx
Translates MyST roles and directives into Sphinx
Uses markdown-it-py for parsing
myst-parser
conf.py:
extensions = [
…
“myst_parser”,
…
]
�
```{directivename} args
:key: val
Some content
```
Roles and directives�kind of like functions, but in markdown
{rolename}`interpreted text`
�
```{directivename} args
:key: val
Some content
```
```{figure} myfig.png
:caption: my caption
:label: my_label
:name: Figure 1
```
Roles and directives�kind of like functions, but in markdown
{rolename}`interpreted text`
{ref}`my_label`
�
working with�notebooks in Sphinx
Parse ipynb files in Sphinx. Directly convert Jupyter Notebooks into Sphinx documents.
Execute and Cache your notebook content. Save time building your documentation without needing to commit your notebook outputs directly into git.
Write MyST Markdown. MyST Markdown allows you to write Sphinx roles and directives in markdown.
Insert notebook outputs into your content. Generate outputs as you build your documentation, and insert them across pages.
Write Jupyter Notebooks entirely with Markdown. Write notebooks in pure-text and convert with Jupytext at build-time.
myst-nb
myst-nb.readthedocs.io
�
Examples of myst-markdown in notebook
�
Markdown notebooks with
�
An API and CLI for staging, executing, and cacheing Jupyter Notebooks.
Be smart about when to re-execute (code cell changes, not markdown)
Parallel access to notebooks (for execution)
Execution statistics/reports
jupyter-cache
jupyter-cache.readthedocs.io
�
�
extending sphinx
design and features
Bootstrap 4 for visual elements and functionality.
Flexible content layout that is inspired by beautiful online books, such as the Edward Tufte CSS guide
Visual classes designed for Jupyter Notebooks. Cell inputs, outputs, and interactive functionality are all supported.
Launch buttons for online interactivity. For pages that are built with computational material, connect your site to an online BinderHub for interactive content.
sphinx-book-theme
sphinx-book-theme.readthedocs.io
�
�
sphinx-thebe
sphinx-thebe.readthedocs.io
�
sphinx-panels
sphinx-panels.readthedocs.io/
�
sphinx-comments
sphinx-comments.readthedocs.io
�
Jupyter Book ties�it all together
4. build output
.ipynb
.md
Partial Sphinx
AST
HTML
Latex
Website
Full Sphinx AST
execute
parse
2. cache and execute
convert
insert
outputs
ipynb+assets
build
Jupyter Book is a light wrapper and CLI around these tools
�
Try Jupyter Book
jupyterbook.org
Follow the project
executablebooks.org
github.com/executablebooks
Connect!�discuss.executablebooks.org
@choldgraf
�