Skip to main content

Embed interactive JupyterLite notebooks in your MkDocs site.

Project description

mkdocs-jupyterlite

A MkDocs plugin that enables embedding interactive jupyterlite notebooks in your docs.

Say you have a notebook example.ipynb in your awesome project, and you want users to be able to play around with it. In the past, you could use a tool like Binder to achieve this. But, that requires a full docker environment and a remote server. By using JupyterLite, you can run Jupyter notebooks directly in the browser without any server-side dependencies.

However, to use jupyterlite, you have to manually install jupyterlite and then run a build step to package your notebooks, other files, and python dependencies into a single static site.

This plugin automates that process for you.

Installation

Step 1: Install the plugin from PyPI:

python -m pip install mkdocs-jupyterlite

Step 2: Configure your mkdocs.yml file

See the mkdocs.yml that configures this project's site.

site_name: mkdocs-jupyterlite
site_url: https://nickcrews.github.io/mkdocs-jupyterlite/
repo_url: https://github.com/nickcrews/mkdocs-jupyterlite/

nav:
  - Home: index.md
  - Notebook 1: notebook.ipynb

plugins:
  - jupyterlite:
      enabled: true
      notebook_patterns:
        # include all
        - "**/*.ipynb",
        # exclude drafts
        - "!**/draft_*.ipynb",  
        # re-include a specific draft
        - "project/drafts/draft_keep.ipynb",
        # exclude an anchored notebook
        - "!/top_secret.ipynb",

Here are the details on the configuration options:

enabled

bool, whether or not the plugin is enabled. Defaults to true.

notebook_patterns

A list of patterns that uses gitignore semantics to include and exclude files. The last matching pattern will be used to determine if a file is a notebook.

For all files that match, the content of the page will be an iframe that embeds the JupyterLite Notebook html.

Contributing

I want this to be usable for other people, so file an issue if you want to use this in your site, but run into any problems.

Possible improvements:

  • Include custom python wheels into the JupyterLite environment.
  • Passing an entire jupyter-lite.json config file.
  • Instead of using an iframe, actually inline the contents of the generated HTML?
  • Fix the TOC so clicking headers actually scrolls in the iframe.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mkdocs_jupyterlite-0.2.0.tar.gz (98.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mkdocs_jupyterlite-0.2.0-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

Details for the file mkdocs_jupyterlite-0.2.0.tar.gz.

File metadata

  • Download URL: mkdocs_jupyterlite-0.2.0.tar.gz
  • Upload date:
  • Size: 98.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for mkdocs_jupyterlite-0.2.0.tar.gz
Algorithm Hash digest
SHA256 0b59b243cebc06f3f9fe75998a1ee0916b870582721209edf6aa71046001441c
MD5 9aef284947ef4ae0d4feb9aa69f2ad77
BLAKE2b-256 219bb16899936af1dfb1f046cce0a544b3bb05bc0ee79003ef23eeee2207aa8c

See more details on using hashes here.

Provenance

The following attestation bundles were made for mkdocs_jupyterlite-0.2.0.tar.gz:

Publisher: publish.yml on NickCrews/mkdocs-jupyterlite

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mkdocs_jupyterlite-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for mkdocs_jupyterlite-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 68b6808e81aca7a42a625a57cab4537fd4ddedb6332d83d0a320836bed017815
MD5 6191b1074e3a695136eee34ee04699cb
BLAKE2b-256 9ac66abbb99d03000264719ae71447c62ad913e9d26e041c2c81f755cf326c10

See more details on using hashes here.

Provenance

The following attestation bundles were made for mkdocs_jupyterlite-0.2.0-py3-none-any.whl:

Publisher: publish.yml on NickCrews/mkdocs-jupyterlite

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page