Skip to main content

MkDocs plugin for Draftmk to filter documentation by user roles

Project description

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 role field.
  • 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!";

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

draftmk_mkdocs_role_filter_plugin-0.2.0.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file draftmk_mkdocs_role_filter_plugin-0.2.0.tar.gz.

File metadata

File hashes

Hashes for draftmk_mkdocs_role_filter_plugin-0.2.0.tar.gz
Algorithm Hash digest
SHA256 420cf56738e50d517f46549622d6b7021ae7e23388d117368b79b1f891707e80
MD5 a31ee345bd76e57aa6febcab72f74439
BLAKE2b-256 7f262abbeb30fe731281a8d2b5086d88ef8e986d489285525a11e042b1781739

See more details on using hashes here.

File details

Details for the file draftmk_mkdocs_role_filter_plugin-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for draftmk_mkdocs_role_filter_plugin-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 92141fcdd40b6d6a0b177a582b1791f0ebe7ffff6d45738df48df934481c359f
MD5 ae1cc287a644bb357b26ae59f9c208d2
BLAKE2b-256 a507aedfd43553ba1041e840ebf6605082789ce555a8edc5298797c917600a21

See more details on using hashes here.

Supported by

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