Skip to main content

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 the search plugin. MkDocs enables it by default if there is no plugins 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

mkdocs-simple-hooks-0.1.0.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

mkdocs_simple_hooks-0.1.0-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

Details for the file mkdocs-simple-hooks-0.1.0.tar.gz.

File metadata

  • Download URL: mkdocs-simple-hooks-0.1.0.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.0

File hashes

Hashes for mkdocs-simple-hooks-0.1.0.tar.gz
Algorithm Hash digest
SHA256 cce4d2b418f00ec29a4a40e05c00291a997c69b915d43983dd3684dcea2e113a
MD5 685136a2d009b88fda71b380d442f8f8
BLAKE2b-256 0efbca0799751dc19db9eed2460b650e05b4f699a4fcb5270699e4099328f4bb

See more details on using hashes here.

File details

Details for the file mkdocs_simple_hooks-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: mkdocs_simple_hooks-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.0

File hashes

Hashes for mkdocs_simple_hooks-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 87e2b004965a954bcf6e0f463122cf86cccc0f612e8178903706272ae47d89ba
MD5 ae6769fc4814727a453094c655ff9e01
BLAKE2b-256 f19dd71a89bda0e0a3a164da2fba2bbb5fb7f7be108a9dc566713ff8c1c37a41

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page