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.1.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

mkdocs_simple_hooks-0.1.1-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mkdocs-simple-hooks-0.1.1.tar.gz
  • Upload date:
  • Size: 3.7 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.6.4

File hashes

Hashes for mkdocs-simple-hooks-0.1.1.tar.gz
Algorithm Hash digest
SHA256 be04116586a71fa629df4acbf02427c92b83229ca1a6b93ad8716ccdf248e4f3
MD5 95cec92c4313455fff55ed7f7153ecd3
BLAKE2b-256 ce1f8dc5449a2e837c6183f9b586bfe24f474dfda27c1520981d75bdefbec012

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mkdocs_simple_hooks-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 4.2 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.6.4

File hashes

Hashes for mkdocs_simple_hooks-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 dc53c03e5ac0b0c0b0c486a8e4ed6ed832c01b069a393f82927be5af42d3e89d
MD5 92af18105831c9f436b0da1db603be4e
BLAKE2b-256 df4e479cf6c2a78fe1ed8fa20b7880602140d31c3b5908950e0f199caece789a

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