Define your own hooks for mkdocs, without having to create a new package.
Project description
mkdocs-simple-hooks
Define your own hooks for mkdocs, without having to create a new package.
Setup
Install the plugin using pip:
pip install mkdocs-simple-hooks
Next, add the plugin and hooks definition to your mkdocs.yml
:
plugins:
- search
- mkdocs-simple-hooks:
hooks:
hook-name: "your.module:hook_function"
If you have no
plugins
entry in your config file yet, you'll likely also want to add thesearch
plugin. MkDocs enables it by default if there is noplugins
entry set.
More information about plugins in the MkDocs documentation.
Usage
You can use this plugin to create simple hooks for mkdocs
without having to create
a separate plugin package.
Just define a function and register it as a hook in the mkdocs.yml
. The function shall
have the same API as the desired hook. To see available hooks and their API, see the
events chapter in the documentation.
Example
Let's say you want to copy the README.md
file to docs/index.md
. To do that, create
a new file, e.g.: docs/hooks.py
, and put the following function there:
import shutil
def copy_readme(*args, **kwargs):
shutil.copy("README.md", "docs/index.md")
Now, register the hook in your mkdocs.yml
:
plugins:
- mkdocs-simple-hooks:
hooks:
on_pre_build: "docs.hooks:copy_readme"
That's all - the copy_readme()
function will run every time, before building the documentation.
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-simple-hooks-0.1.3.tar.gz
.
File metadata
- Download URL: mkdocs-simple-hooks-0.1.3.tar.gz
- Upload date:
- Size: 4.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/3.8.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 209f707cfb976ded4ac5a3f89ab96309a5b26d153e748a9c7bf728c7f6974051 |
|
MD5 | 43e29cd972900ae4cb6464bd5e131c4c |
|
BLAKE2b-256 | d6fe07a3fae3d1f1094431609616d3f9b52a9d6e716e09bd84856ec22b018959 |
File details
Details for the file mkdocs_simple_hooks-0.1.3-py3-none-any.whl
.
File metadata
- Download URL: mkdocs_simple_hooks-0.1.3-py3-none-any.whl
- Upload date:
- Size: 4.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/3.8.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 98af391af5d8cf86faa7c21d189d299c7af3258908f0f272fd981bbc143b0e33 |
|
MD5 | 38a2fa47f72106b89eb17fda58cb0c1f |
|
BLAKE2b-256 | c0e2ded33335cb8c57ac453fa3a65b96c1745398245eaece46e91542a9d621a8 |