Note: This plugin is part of the DraftMk ecosystem – a full-stack markdown documentation platform with live editing, GitHub integration, and role-based publishing.
draftmk-mkdocs-role-filter-plugin
A custom MkDocs plugin that filters documentation pages based on role-based access metadata in your Markdown frontmatter.
Features
- Filters content at build time based on allowed roles
- Supports role-based navigation pruning
- Easy to integrate into existing MkDocs projects
Installation
You can install this plugin using pip (recommended in a virtual environment):
pip install draftmk-mkdocs-role-filter-plugin
Usage
In your mkdocs.yml configuration file, enable the plugin and set the allowed roles:
plugins:
- role-filter:
allowed_roles:
- public
Pages not matching the specified roles will be excluded from the build and navigation.
Frontmatter Example
Each Markdown file should declare its role in the frontmatter:
---
title: "Getting Started"
role: public
---
You can use custom roles such as internal, admin, etc.
How It Works
The plugin performs two key operations:
on_page_markdown
- Checks each page's frontmatter for a
rolefield. - If the role matches one of the configured
allowed_roles, the page is included in the build. - If not, the page content is hidden.
on_nav
- Prunes the MkDocs navigation (
nav) to exclude items that have no visible children or unauthorized pages. - This ensures the final navigation reflects only authorized content.
Development
To test locally with editable install:
pip install -e .
License
MIT © Jonmatum
echo "Pura Vida & Happy Coding!";
Metadata
Release files for draftmk-mkdocs-role-filter-plugin 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| draftmk_mkdocs_role_filter_plugin-0.2.0.tar.gz | 4.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| draftmk_mkdocs_role_filter_plugin-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 8.7 kB
Release files / draftmk_mkdocs_role_filter_plugin-0.2.0.tar.gz
| Download URL | draftmk_mkdocs_role_filter_plugin-0.2.0.tar.gz |
|---|---|
| Size | 4.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
420cf56738e50d517f46549622d6b7021ae7e23388d117368b79b1f891707e80
|
|
BLAKE2b-256 checksum How to use checksums |
7f262abbeb30fe731281a8d2b5086d88ef8e986d489285525a11e042b1781739
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.3
|
Release files / draftmk_mkdocs_role_filter_plugin-0.2.0-py3-none-any.whl
| Download URL | draftmk_mkdocs_role_filter_plugin-0.2.0-py3-none-any.whl |
|---|---|
| Size | 4.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
92141fcdd40b6d6a0b177a582b1791f0ebe7ffff6d45738df48df934481c359f
|
|
BLAKE2b-256 checksum How to use checksums |
a507aedfd43553ba1041e840ebf6605082789ce555a8edc5298797c917600a21
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.3
|