Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Define your own hooks for mkdocs, without having to create a new package.
Define your own hooks for mkdocs, without having to create a new package.
Install the plugin using pip:
pip install mkdocs-simple-hooks
Next, add a python module to either the docs/
directory or the root mkdocs directory. Then, 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.
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 mkdocs documentation.
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.
You can use the enabled
option to optionally disable this plugin. A possible use case is local development where you might want faster build times. It's recommended to use this option with an environment variable together with a default fallback (introduced in mkdocs
v1.2.1, see docs). Example:
plugins:
- mkdocs-simple-hooks:
enabled: !ENV [ENABLE_MKDOCS_SIMPLE_HOOKS, True]
hooks:
on_pre_build: "docs.hooks:copy_readme"
Which enables you to disable the plugin locally using:
export ENABLE_MKDOCS_SIMPLE_HOOKS=false
mkdocs serve
FAQs
Define your own hooks for mkdocs, without having to create a new package.
We found that mkdocs-simple-hooks demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.