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.
Development with Pixi
This repo is configured to use Pixi for fast, reproducible environments and dev tasks.
- Install Pixi (one-time)
curl -fsSL https://pixi.sh/install.sh | sh
- Install the environment (creates
.pixi/locally)
pixi install
- Common tasks
# Run tests
pixi run test
# Build and serve the docs
pixi run docs-build
pixi run docs-serve
You can also open a shell in the environment:
pixi shell
Pre-commit hooks
This repo uses pre-commit to enforce code style and basic checks:
# Install git hooks
pixi run pre-commit install
# Run hooks on all files
pixi run pre-commit-run
CI will also run pre-commit run --all-files to keep the codebase consistent.
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mkdocs_execute_plugin-0.0.9.tar.gz.
File metadata
- Download URL: mkdocs_execute_plugin-0.0.9.tar.gz
- Upload date:
- Size: 35.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.28.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
658aeccb5447d7a3ec27dbcc203a6faee28e8c551f2d33d7683fb6101a499f2f
|
|
| MD5 |
3dd779b76ee8d1a1bc6d0c44b5900da4
|
|
| BLAKE2b-256 |
f549a25b0da80729d27171a53c926e0067c8768ac403ea9c612a9346314714c6
|
File details
Details for the file mkdocs_execute_plugin-0.0.9-py3-none-any.whl.
File metadata
- Download URL: mkdocs_execute_plugin-0.0.9-py3-none-any.whl
- Upload date:
- Size: 11.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.28.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
99d37e1029ac799fce34b039819f89b5374696db8d693d2d30182288bbf195b0
|
|
| MD5 |
728af394508b18644f146e09a7e996c9
|
|
| BLAKE2b-256 |
f0a13bb23af3398452cdac6da5415e19bb4555d82f73ba9ce3cfa39818cf6b68
|