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
Built Distribution
File details
Details for the file mkdocs_execute_plugin-0.0.7.tar.gz
.
File metadata
- Download URL: mkdocs_execute_plugin-0.0.7.tar.gz
- Upload date:
- Size: 6.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.27.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3a88f9f97977dbf6da8171e76412456566ad1da7fb09a42a5dbbfa7d280cd430 |
|
MD5 | d5134e3877ec1250255640cdee624c44 |
|
BLAKE2b-256 | 0651c4388794a554518a59c37b3b2d2962ecbded38e45e3014a9f84093530f94 |
File details
Details for the file mkdocs_execute_plugin-0.0.7-py3-none-any.whl
.
File metadata
- Download URL: mkdocs_execute_plugin-0.0.7-py3-none-any.whl
- Upload date:
- Size: 9.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.27.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 32106efe3972fc41a6dbb70430e6f06a024d1b0dabed4a434c59cf51d266b097 |
|
MD5 | 1f82e12d65251e8f6cc1be4bc3c4510d |
|
BLAKE2b-256 | 7787dd4924cb89bd7f508357e71664c5349c468354148eb3aaa00734bde03614 |