Skip to main content

A MkDocs plugin to execute notebooks and embed the results in the documentation.

Project description

MkDocs Execute Plugin

Plugin for MkDocs that executes documentation files using jupytext and embeds the output in your documentation.

Installation

Start by install the plugin using pip:

pip install mkdocs-execute-plugin

Basic usage

Configuring mkdocs

After installing it, you can enable the plugin by adding it to the plugin section of your mkdocs.yml:

plugins:
  - execute

Adding executable files

By default, this plugin will execute all code blocks inside markdown files if the file has the execute tag. An example markdown file can be found below.

---
execute: true
---

```python
print('Hello world!')
```

On top of that, the plugin will also execute all python (.py) files by default.

print('Hello world!')

Hiding cell input or output

It is possible to hide the input or output of a cell by applying the hide-input and hide-output tags respectively. It is also possible to hide a cell completely using the hide-cell tag.

```python tags=["hide-input"]
print('Hidden input')
```

```python tags=["hide-output"]
print('Hidden output')
```

```python tags=["hide-cell"]
print('Completely hidden')
```

Configuration

All configuration options can be found below. The given values are the defaults.

# Default configuration
plugins:
  - execute:
      # Specify which files to include for execution. Should be a list of .gitignore style glob patterns.
      # Note that only files with the execute tag set to true will be executed. To override, see `execute_without_tag`.
      include: 
        - '*.py'
        - '*.md'
      # Specify which glob patterns to exclude for execution. Same format as `include`.
      exclude: []
      # Specify which files should still be executed if the execute tag is missing. Same format as `include`.
      # If the execute is set to false for a file matching this pattern, it will NOT be executed.
      execute_without_tag:
        - '*.py'
      # Markdown template used to render the executed files.
      markdown_template: 'markdown/index.md.j2'
      # You can modify the names of all tags.
      tags:
        # Tag that marks the file as executable.
        execute: 'execute'
        # Tag that hides a cell completely, both the input and output.
        # Note that the cell will still be executed.
        hide_cell: 'hide-cell'
        # Tag that hides the cell input (code).
        hide_input: 'hide-input'
        # Tag that hides the cell output.
        hide_output: 'hide-output'

Supported formats and languages

This plugin uses jupytext to execute and then convert files to markdown. This means all languages and formats supported by jupytext should work.

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_execute_plugin-0.0.8.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

mkdocs_execute_plugin-0.0.8-py3-none-any.whl (9.9 kB view details)

Uploaded Python 3

File details

Details for the file mkdocs_execute_plugin-0.0.8.tar.gz.

File metadata

File hashes

Hashes for mkdocs_execute_plugin-0.0.8.tar.gz
Algorithm Hash digest
SHA256 892972c8295cddac8187fbe153b570a297cceb0c56145d6441a3457b600f055e
MD5 efd64b59fe4660b68f402efacc7e6d67
BLAKE2b-256 effad3ff75edbb541ec1e7220e7f08bc22cda71c4c741f6142275cd0d305f27d

See more details on using hashes here.

File details

Details for the file mkdocs_execute_plugin-0.0.8-py3-none-any.whl.

File metadata

File hashes

Hashes for mkdocs_execute_plugin-0.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 b401842d4057c8dc9464f16bc3d7ce8c94410fc9e25151fcc2381f2ac39f4d81
MD5 244659f1d6b878d804c3dfc91993c32a
BLAKE2b-256 cc4f2b386e2efb0c65b9c7b2b52fc2b05c4312ab0705fba56ddb9f10a45657fb

See more details on using hashes here.

Supported by

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