A MkDocs plugin to bundle specific code blocks into a downloadable ZIP or raw file.
Project description
mkdocs-zip-bundle-plugin
A MkDocs plugin that turns code blocks into downloadable files. Tag any code block with a bundle ID and filename — the plugin injects a download button automatically. Works with single files (direct download) or multiple files (ZIP archive).
Built to pair with mkdocs-placeholder-plugin: if your docs use interactive placeholders like @PORT@, the downloaded file will contain the user's actual values, not the defaults.
Features
- Single file downloads — one code block gets a direct raw file download, no ZIP needed
- Multi-file ZIP bundles — group multiple code blocks into one ZIP with a single button
- Placeholder-aware — captures the live browser state, so user-edited values are included in the download
- Nested paths — use
configs/app.yamlas a filename to create subdirectories inside the ZIP - Custom button labels — override auto-generated text per bundle
- Self-contained — ships with JSZip and default styling, no extra dependencies
Installation
pip install mkdocs-zip-bundle-plugin
Requires Python 3.8+ and MkDocs 1.4+. Download buttons require a modern browser (Chrome, Firefox, Safari, Edge).
Configuration
plugins:
- search
- zip-bundle:
include_jszip: true # set to false if you already load JSZip elsewhere
zip_label_suffix: "(.zip)" # appended to multi-file bundle button labels
Also enable the attr_list extension so MkDocs can read attributes on code blocks:
markdown_extensions:
- attr_list
- pymdownx.superfences # recommended for reliable attribute support
Usage
Add data-zip-bundle and data-zip-filename attributes to any fenced code block:
Single file
```yaml { data-zip-bundle="my-app" data-zip-filename="compose.yaml" }
services:
app:
image: my-image:latest
```
The plugin injects a Download compose.yaml button directly after the code block.
Multiple files (ZIP)
```yaml { data-zip-bundle="my-app" data-zip-filename="compose.yaml" }
services:
app:
image: my-image:latest
```
```bash { data-zip-bundle="my-app" data-zip-filename="setup.sh" }
mkdir -p /data/app
```
Both blocks share the same bundle ID. The plugin injects a single Download My App (.zip) button after the last block.
Custom button label
```yaml { data-zip-bundle="my-app" data-zip-filename="compose.yaml" data-zip-label="Download config" }
...
```
Force ZIP for a single file
```yaml { data-zip-bundle="my-app" data-zip-filename="compose.yaml" data-zip-force="true" }
...
```
Nested directories
```yaml { data-zip-bundle="my-app" data-zip-filename="config/app.yaml" }
...
```
```bash { data-zip-bundle="my-app" data-zip-filename="scripts/setup.sh" }
...
```
The ZIP will contain config/app.yaml and scripts/setup.sh preserving the directory structure.
How it works with placeholders
If you use mkdocs-placeholder-plugin, your docs can have editable values like @PORT@ or @DATA_PATH@ that users customize in the browser.
When the user clicks a download button from this plugin, the downloaded file contains whatever is currently in the code block — including any values the user has already changed. This makes it possible to offer personalized, copy-paste-ready config files directly from your documentation.
License
Project details
Release history Release notifications | RSS feed
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_zip_bundle_plugin-0.1.1.tar.gz.
File metadata
- Download URL: mkdocs_zip_bundle_plugin-0.1.1.tar.gz
- Upload date:
- Size: 38.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
59dab342bed4d95c76b4c3a24189d219004f3363f863affc93ce3e0e02e2394b
|
|
| MD5 |
828c2ec82ee12621ba014ac9734b653f
|
|
| BLAKE2b-256 |
2cf84537d1daa94978111875c6686c1f70c894afc1f3350176c9bea827d4e6d6
|
File details
Details for the file mkdocs_zip_bundle_plugin-0.1.1-py3-none-any.whl.
File metadata
- Download URL: mkdocs_zip_bundle_plugin-0.1.1-py3-none-any.whl
- Upload date:
- Size: 36.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6dbc7ef7d7e7a44755859e7425f2e9d6ad85a53024ee4e17d5f6a6da0dc81c87
|
|
| MD5 |
7276d732da8d4b0968f1114c8fef7648
|
|
| BLAKE2b-256 |
4819ad8dfba33f9c1355da3b13dd7a8fe563e866158d32e850dd4dcc89cbede5
|