Registry / web-framework / mkdocs-simple-hooks

mkdocs-simple-hooks

JSON →
library0.1.5pypypiunverified

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.

pip install mkdocs-simple-hooks
INSTALL
IMPORT
SIG · MKDOCS-SIMPLE-HOOK
M
mkdocs-simple-hooks
web-frameworkpythonv0.1.5
Install
3.0s avg
Import
Disk
32MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.1.5 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.000s · 33MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 3.0s · import 0.000s · 34MB
32MB installed
● package 32MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Hook definition in mkdocs.yml
plugins: - mkdocs-simple-hooks: hooks: on_pre_build: "docs.hooks:copy_readme"
Hooks are defined as Python functions in a module (e.g., 'docs/hooks.py') and referenced as a string in mkdocs.yml, not directly imported into Python code.

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
Debug
Known issues
breakingThis plugin is officially deprecated and no longer supported as MkDocs 1.4.0 and later versions include native support for hooks, making this plugin redundant. Users are strongly advised to migrate to the native MkDocs hooks functionality.
fix
Remove `mkdocs-simple-hooks` from `mkdocs.yml` and `requirements.txt`. Refactor hook functions to be directly referenced under the `hooks:` configuration in `mkdocs.yml` as per MkDocs documentation.
affects: All versions of mkdocs-simple-hooks with MkDocs >= 1.4.0
gotchaIf you don't have a `plugins` entry in your `mkdocs.yml`, MkDocs typically enables the `search` plugin by default. When you add `mkdocs-simple-hooks`, you must explicitly list `search` if you still want it, as adding any plugin disables implicit defaults.
fix
Ensure your `mkdocs.yml` explicitly lists all desired plugins: `plugins: [search, mkdocs-simple-hooks]`
affects: All versions
gotchaTo enable/disable the plugin dynamically, especially in different environments, you can use MkDocs' `!ENV` tag with an environment variable. Without careful handling, the plugin might be active when not intended or vice-versa.
fix
Configure in `mkdocs.yml`: `plugins: - mkdocs-simple-hooks: enabled: !ENV [ENABLE_MKDOCS_SIMPLE_HOOKS, True]` and set `ENABLE_MKDOCS_SIMPLE_HOOKS` accordingly in your environment.
affects: All versions
Upgrade
Version history
0.1.5latest on PyPI · released Jan 7, 2022
Audit
Dependencies
mkdocsrequiredThis is an MkDocs plugin and requires MkDocs to function.
Agent activity
4 hits · last 30 days
node
4
Resources
mkdocs-simple-hooks — pip install mkdocs-simple-hooks · libregistry