Skip to main content

No project description provided

Project description

mkdocs-jupyter: Use Jupyter Notebooks in mkdocs

PyPI Testing Coverage Status License

  • Add Jupyter Notebooks directly to the mkdocs navigation
  • Support for multiple formats:
  • Same style as regular Jupyter Notebooks
  • Option to execute the notebook before converting
  • Support for ipywidgets
  • Support for mkdocs TOC
  • Option to include notebook source

mkdocs-jupyter default theme mkdocs-jupyter material theme

Usage

pip install mkdocs-jupyter

In your mkdocs.yml:

nav:
- Home: index.md
- Notebook page: notebook.ipynb
- Python file: python_script.py

plugins:
  - mkdocs-jupyter

Options

Execute Notebook

You can tell the plugin to execute the notebook before converting, default is False:

plugins:
  - mkdocs-jupyter:
      execute: True

Kernel Name

By default the plugin will use the kernel specified in the notebook to execute it. You can specify a custom kernel name to use for all the notebooks:

plugins:
  - mkdocs-jupyter:
      kernel_name: python3

Download notebook link

You can tell the plugin to include the notebook source to make it easy to show a download button in the theme, default is False:

plugins:
  - mkdocs-jupyter:
      include_source: True

This setting will also create a page.nb_url value that you can use in your theme to make a link in each page.

For example in mkdocs-material (see customization), you can create a main.html file like this:

{% extends "base.html" %}

{% block content %}
{% if page.nb_url %}
    <a href="{{ page.nb_url }}" title="Download Notebook" class="md-content__button md-icon">
        {% include ".icons/material/download.svg" %}
    </a>
{% endif %}

{{ super() }}
{% endblock content %}

Download Noteboon button

Styles

This extensions includes some CSS styles to make the Notebook look "decent" inside a generic mkdoc theme but in general some extra customization needs to be done to make the Jupyter Notebook based pages look as good and native as the markdown ones. This is usually simple CSS tweaks.

Material theme

For popular the mkdocs-material please take a look at their customization docs)

Create a main.html file like:

{% extends "base.html" %}

{% block content %}
{{ super() }}

<style>
    .jp-RenderedHTMLCommon p {
        font-size: .8rem;
        line-height: 1.6;
    }

    .jp-RenderedHTMLCommon li {
        font-size: .8rem;
        line-height: 1.6;
    }

    .jp-RenderedHTMLCommon h1 {
        margin: 0 0 1.25em;
        color: var(--md-default-fg-color--light);
        font-weight: 300;
        font-size: 2em;
        line-height: 1.3;
        letter-spacing: -0.01em;
    }

    .jp-RenderedHTMLCommon h2 {
        margin: 1.6em 0 .64em;
        font-weight: 300;
        font-size: 1.965em;
        line-height: 1.4;
        letter-spacing: -0.01em;
    }

    .jp-RenderedHTMLCommon h3 {
        margin: 1.6em 0 .8em;
        font-weight: 400;
        font-size: 1.57em;
        line-height: 1.5;
        letter-spacing: -0.01em;
    }

    .jp-RenderedHTMLCommon hr {
        border: none;
    }
</style>
{% endblock content %}

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-jupyter-0.16.1.tar.gz (1.7 MB view details)

Uploaded Source

File details

Details for the file mkdocs-jupyter-0.16.1.tar.gz.

File metadata

  • Download URL: mkdocs-jupyter-0.16.1.tar.gz
  • Upload date:
  • Size: 1.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/54.1.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.8

File hashes

Hashes for mkdocs-jupyter-0.16.1.tar.gz
Algorithm Hash digest
SHA256 de5c1667cc07c93bf11a70fba6b1a9f67b9a9729390c918891f55bcc889e3c45
MD5 98fafbb75de474ee4d83bfd18db48d1c
BLAKE2b-256 25c478ae93226d73afcfc8c05ff085ddb132ae001e36d0cd7d90bb9fbd8b6bd9

See more details on using hashes here.

Supported by

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