MkDocs plugin to check if a build is necessary by hashing configuration and documentation files.
Project description
MkDocs Build Cache Plugin
MkDocs Build Cache Plugin is a MkDocs plugin that speeds up your documentation builds by caching the build state. It computes a unique hash based on your configuration, source files, and any additional files you wish to include. If nothing has changed since the last build and your output directory already contains valid content, the plugin can abort the build early, saving valuable time.
Installation
Install the plugin via pip:
pip install mkdocs-build-cache-plugin
Alternatively, add it to your project’s dependencies.
Usage
To enable the plugin, add it to your mkdocs.yml configuration file. You can also pass an optional list of glob patterns to include additional files in the cache hash computation.
site_name: My Docs Site
plugins:
- search
- build_cache:
include:
- "extras/*.txt"
- "assets/**/*.css"
How It Works
-
Cache ID Calculation:
When MkDocs starts, the plugin calculates a unique cache ID based on:- The main configuration file (if available).
- All files under your
docs_dir. - Any extra files that match the glob patterns provided in the
includeoption.
-
Build Skipping:
- If a cache file exists and its cache ID matches the newly computed one and the output directory (
site_dir) exists and is nonempty, the plugin raises an abort exception. This tells MkDocs that the build is up to date, and it can safely skip rebuilding. - Otherwise, the build proceeds normally. After a successful build, the plugin updates the cache file with the new cache ID.
- If a cache file exists and its cache ID matches the newly computed one and the output directory (
Configuration Options
include
-
Type:
List[str] -
Default:
[] -
Description:
A list of glob patterns specifying extra files to be included in the cache hash computation. For example:include: - "extras/*.txt" - "assets/**/*.css"
Development
To run tests locally, ensure you have pytest installed and run:
pytest
Logging
This plugin uses the mkdocs.plugins logger namespace. You can control the log output via MkDocs’ verbosity flags (e.g., --verbose or --debug).
Contributing
Contributions, suggestions, and bug reports are welcome! Please open an issue or submit a pull request in the project's repository.
License
This project is licensed under the MIT License.
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_build_cache_plugin-0.3.0.tar.gz.
File metadata
- Download URL: mkdocs_build_cache_plugin-0.3.0.tar.gz
- Upload date:
- Size: 6.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7bb3ef55d5939197cb83ea7252d3b2412fe7ee0ff85dc825823b1b014cb1be84
|
|
| MD5 |
51ccabfdfb65e0e91cf4c21084382912
|
|
| BLAKE2b-256 |
d2df683d555a901f4b97d3b621362e7f54e9fa9d085326a1e5dba3e406c50203
|
File details
Details for the file mkdocs_build_cache_plugin-0.3.0-py3-none-any.whl.
File metadata
- Download URL: mkdocs_build_cache_plugin-0.3.0-py3-none-any.whl
- Upload date:
- Size: 5.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7e6994b594ab394ceb27b0f18a85b38fbb82d8818492a72f6218f7c8bb882599
|
|
| MD5 |
78ca7231a4a40de99f82e9fc7395ca38
|
|
| BLAKE2b-256 |
679958297a2ea252169a27aa37d67de76695f932881c7ee96a9eaf53e06dee45
|