Build a Jupyter Book
with The Turing Way

Two smiling people, with outstretched arms, stand infront of banner text saying welcome! The text is sorrounded by marks implying lights and fireworks.
Headshot of Angus, a smiling white man in his late, late twenties with stubble and medium length dark brown hair. He is wearing a mustard orange jumper and standing against a cream background.
Angus
Photograph of Arielle Bennett, a white woman with black framed glasses, brown hair and red lipstick, wearing a green jumper, with a conference presentation just visible in the background
Arielle
Headshot of Chris Holdgraf, a smiling man with short blondish-brown hair and a beard, wearing a blue patterned shirt against a gray background.
Chris
Photograph of Franklin.
Franklin
Photograph of Jim, a white man in his 30s. He has very short fair hair and a short beard. He is wearing headphones and taking the photograph using his camera and a mirror.
Jim
Photograph of Kirstie - a white woman in her 40s - and her daughter Mackenzie who was 2 at the time. They are hiking up a green, grassy hill in the Lake District in the UK. Mackenzie is in a backpack looking over Kirstie's shoulder. They both have blonde hair and are smiling at the camera.
Kirstie
Photograph of Robert, a white man in his late 30s. He has graying dark brown hair and a beard, is wearing glasses and a green shirt.
Robert
Photograph of Rowan.
Rowan
Time Activity
09:00 Introduction
09:20 Installation
09:30 Jupyter Book Showcase
09:45 Jupyter Book Fundamentals
10:30 Coffee Break ☕️
11:00 Executable Content and Building a PDF
11:45 Advanced MyST Showcase
12:05 Join us!
12:30 Close and Lunch 🍽️

Installing Jupyter Book

next.jupyterbook.org/start/install

A QR code linking to the Jupyter Book 2 installation dcumentation.

                        $ pip install "jupyter-book>=2.0.0a0"
                    

                        $ npm install -g "jupyter-book@>=2.0.0-a0"
                    

Jupyter Book

The Jupyter Book logo, formed of text reading jupyter book where the word book is surrounded by braces.
Create documents and knowledge bases that are reusable, reproducible, and interactive.
  • Features for beautiful typesetting, in many domains
  • Builds from MyST Markdown or Jupyter Notebooks

Jupyter Book

Superpowers

  • Simple to use, easy for users to extend
  • Simple to use, easy for developers to extend
  • Content that is canonical and machine readable
  • Content that is modular and composable
  • Computation as a first-class citizen
  • Led by an open community

Jupyter Book

Executable content

  • Jupyter Notebooks
  • code-cell blocks in Markdown
  • Inline statements using eval in Markdown
Screenshot of a Jupyter Notebook session where one cell defines a function for the Fibonacci series

                                        # Title

                                        ```{code-cell} python
                                        hello = "hello"
                                        there = "there"
                                        phrase = f"{hello}, {there}!"
                                        print(phrase)
                                        ```
                                    

                                    # Title

                                    1 + 1 is {eval}`1 + 1`
                                    

Executing

  • Before build (for notebooks)
  • At build time
  • Live in a browser

Jupyter Book

More features!

  • Plugins
  • Cross-book references and embedding
  • Multiple export formats (HTML, pdf, docx, JATS)

Jupyter Book

Jupyter Book 1

MyST Parser
Sphinx

Jupyter Book 2

mystmd

Jupyter Book

doi: 10.25080/hwcj9957

The Turing Way

The Turing Way project is illustrated as a road or path with shops for different data science skills. People can go in and out with their shopping cart and pick and choose what they need.
book.the-turing-way.org

Activity

The template

jupyter-book.github.io/workshop-template

Activity

Set up your project

jupyter-book.github.io/workshop-template/setup

We recommend the entirely local route

Building and editing in GitHub is possible if installing packages is difficult

If you finish early, get a head start reading the cheat sheet 📖

Showing off Jupyter Book

Examples from the real world

The Turing Way: Rich Referencing

Let's see it live!

Showing off Jupyter Book

Examples from the real world

Project Pythia: Executeable code

Let's see it live!

Showing off Jupyter Book

Examples from the real world

Environmental Data Science: Executeable code

Let's see it live!

Activity

Jupyter Book Fundamentals

Lesson 2
The basics of structuring and writing a Jupyter Book

Activity

More content

Lesson 3
Using directives and roles to create richer documents
Lesson 4
Sharing and reusing content

Break

☕️

Activity

Executable content

Lesson 5
Adding the outputs of notebooks and code cells to our projects

Activity

Build a PDF

Lesson 7
Output documents for print or publishing

Advanced MyST

The most exciting thing about Jupyter Book is not the dialect of Markdown!

Jupyter Book is a tool for structured communication.

I want to find the glossary terms in TTW

Take the glossary URL
book.the-turing-way.org/afterword/glossary/

and tweak it to point to the structured data
book.the-turing-way.org/afterword.glossary.json

I want to find the glossary terms in TTW

The data is JSON!


             $ curl https://book.the-turing-way.org/afterword.glossary.json

                {
                  "version": 2,
                  "kind": "Article",
                  "sha256": "4347650f55c9dd2731a58abd686252ceee472e608780998c6bd3f2ec25e6c3de",
                  "slug": "afterword.glossary",
                  "location": "/afterword/glossary.md",
                  "frontmatter": {
                  ...
                  "mdast": {
                  ...

                     

I want to find the glossary terms in TTW

What does a "node" look like?

View in the MyST Sandbox

I want to find the glossary terms in TTW

Pull out the TTW glossary terms


                        $ curl https://book.the-turing-way.org/\
                               afterword.glossary.json \
                          | jq -r ' 
                              # Pull out our AST
                              .mdast |
                              # Recursively walk through AST
                              .. | 
                              # Pull out definitionTerm nodes
                              select(.type? == "definitionTerm") |
                              # Pull out text nodes from their children
                              .children[] | select(.type == "text") |
                              # Dump the text value!
                              .value' 
                     

Acceptance Testing
Acknowledgements
Add
Adversarial Learning
Artificial intelligence (AI)
Authors
Binder
Binderhub
Binderize
Branch
Bug
Build
Checkout
Citizen Science
Clone
Code Coverage
Code of Conduct
Code Review
Coercive authorship
Commit
Commit Message
Communication Channel
Community Member
Computational Environment
Conda
Consortia authorship
Container
Continuous Delivery
Continuous Deployment
Continuous Integration
Contributing Guidelines
Contributors
Corresponding author
Creative Commons
CRediT Taxonomy
Data repository
Differential privacy
DMP
DNS
Docker Container
Docker Compose
Dockerfile
Docker Image
Docker Registry
Digital Object Identifier
End to End Test
Epistemology
Equitable, Diverse and Inclusive Practices
Ethical Source Software
FAIR
Fair Code
Federated Learning
First author
Free or Libre Software
Free Cultural Works
Generalisable
Git
Github
GitLab
Ghost author
Gift author
Group authorship
Guarantor
Hazard
Head
Helm
Honorary authorship
Hosting
Human Readable
Identifier
Image
Inner source
Integration Testing
Intersectionality
Issues
Issue Tracking
Job
JupyterHub
Kubernetes
License
Last author
Machine Learning (ML)
Machine Readable
Main
Maintainers
Makefile
Merge
Merge Conflict
Metadata
Mock Test
Open access
Open access publishing (gratis)
Open access publishing (libre)
Open core
Open data
Open educational resources
Open license
Open notebooks
Open project
Open scholarship
Open source
Open source hardware
Open source software
ORCID
Owner
Package Management System
Persistent Identifier
Pattern
Peer Review
Persona
Persona Canvas
Phony Target
Plain Language
Positionality
Power Users
Preprint
Prerequisite
Project Design
Pull Request
Push
RDM
README
Recipe
Regression Test
Replicable
repo2docker
Repository
Reproducible
Rendered Output
Research Compendia
Research Data Management
Research Ethics
Research Objects
Review
Risk
Risk Assessment
Risk Matrix
Roadmapping
Robust
Rule
Runtime Test
Self Archiving
Self Reflection
SHA
Shared authorship
Smoke Testing
Source Available
Staged
Stale
Stochastic Code
Syntax
System Testing
Target
Test Driven Development
Test Stub
Test Suite
Testing Framework
Travis
Unit
Unit Testing
Virtual Machine
YAML
            

Manipulating the AST with a plugin

You've written an assignment with the help of a close friend LLMs can be our friends, right?

They use too many (—). How can we automate the process of cleaning up the text?

Jupyter Book supports .

These are small units of code that can manipulate the AST.

Let's write a plugin that replaces em-dashes with two hyphens!

First, our document

Got it -- I'll help you to write your PhD thesis on nuclear structure in the style of a sleep-deprived badger.

Nuclear structure is — yawn — a highly complex field. Badgers don't understand nuclear physics.

A badger swimming with various physics phenomena overlayed

Take me to your lede


                export default {
                  name: "My plugin",
                  transforms: [
                    {
                      name: "remove-ai",
                      doc: "A transform to hide the involvement of LLMs, we promise.",
                      stage: "document",
                      plugin: (_, utils) => (root) => {
                        const nodes = utils.selectAll("text", root);
                        for (const node of nodes) {
                          node.value = node.value.replace("—", "--");
                        }
                      },
                    },
                  ],
                };
            

Nuclear structure is a highly complex field. Badgers don't understand nuclear physics.

A badger swimming with various physics phenomena overlayed

Plugins can make your life easier


                :::{list-table}
                - - Build `/pull` endpoint
                  - 15h
                  - 26h
                - - Write tests for repoprovider endpoint
                  - 5h
                  - 9h
                - - Open pull-request and shepherd through to merge
                  - 4h
                  - 8h
                - - Additional learning and refinement
                  - 2h
                  - 6h
                :::
              

Plugins can make your life easier

            :::{}
- - Build `/pull` endpoint
  - 15h
  - 26h
- - Write tests for repoprovider endpoint
  - 5h
  - 9h
- - Open pull-request and shepherd through to merge
  - 4h
  - 8h
- - Additional learning and refinement
  - 2h
  - 6h
:::
            

Plugins can make your life easier

            
            :::{blog-posts}
            :::
            
            
Go to the source code

Introducing the Haiku of Demos

  • Do the demo live.
  • Encounter complications.
  • Maybe have regret.
  • Oh No.

Separating structured data from presentation

Another DEMO? I think so!

Reflections & feedback

QR code linking to feedback form at bit.ly/turingway-feedback

Creating with MyST 🌁

  • You have the tools 🛠️
  • Jupyter Books are great for
    • Books
    • Technical documents
    • Data science examples
    • Research papers
  • What will you make?
  • Which projects could you help?

Contributing to Jupyter Book

jupyterbook.org
mystmd.org/guide
github.com/jupyterbook
discord.mystmd.org

The Turing Way Community

A group of people work together on a stage labelled our community. Some are tending to plants with symbols representing data and version control. A new community member is being welcomed to the team. Text emphasises working together, sharing knowledge and helping eachother.
Community-written handbook for reproducible, ethical and collaborative data science.

The Turing Way Community

Empowering contributors

  • Mentor contributors at all levels
  • Governance emphasises community power
  • Open working groups
  • Open governance and decision making

The Turing Way Community

Get involved

  • Edit and improve pages
  • Gardening and maintenance
  • Working groups
  • Community management
  • Event coordination
  • Mentoring contributors
  • Funding and sustainability

The Turing Way Community

Events and onboarding

  • Collaboration Cafés ☕️
  • Onboarding calls ☎️
  • Book Dash 📘💨
  • Community Forum 📣

The Turing Way Community

Where to find us

slack.the-turing-way.org
book.the-turing-way.org
news.the-turing-way.org
git.the-turing-way.org
calendar.the-turing-way.org

More Jupyter Book 2 at JupyterCon

Introducing Jupyter Book 2: Next-generation Tools for Creating Computational Narratives
Tuesday 11:00
Pacific Room
Two people hold up a large banner with the word thanks written on it.