MkDocs Simple Hooks

0.1.5 · deprecated · verified Tue Apr 14

mkdocs-simple-hooks is a deprecated Python plugin for MkDocs that allowed users to define custom hooks directly within their project's Python modules without needing to create a separate MkDocs plugin package. Its functionality has been natively implemented in MkDocs 1.4 and later. The current version is 0.1.5, with the last release in January 2022, indicating an inactive release cadence.

Warnings

Install

Imports

Quickstart

To get started, define your hook functions in a Python file (e.g., `docs/hooks.py`) and then reference these functions in your `mkdocs.yml` configuration under the `plugins.mkdocs-simple-hooks.hooks` section. The example demonstrates copying `README.md` to `docs/index.md` before the build process.

# 1. Create a Python file, e.g., 'docs/hooks.py'
# content of docs/hooks.py:
import shutil

def copy_readme(*args, **kwargs):
    shutil.copy('README.md', 'docs/index.md')

# 2. Configure mkdocs.yml (add this to your existing mkdocs.yml):
# plugins:
#   - mkdocs-simple-hooks:
#       hooks:
#         on_pre_build: "docs.hooks:copy_readme"

# 3. Ensure 'mkdocs' is installed and run from your project root:
# pip install mkdocs
# mkdocs build
# mkdocs serve

view raw JSON →