Skip to main content

MkDocs plugin for embedding Drawio files

Project description

MkDocs Plugin for embedding Drawio files

Publish Badge PyPI

Buy Sergey a ☕

Sergey (onixpro) is the original creator of this plugin. Repo can be found here.

Features

This plugin enables you to embed interactive drawio diagrams in your documentation. Simply add your diagrams like you would any other image:

![](my-diagram.drawio)

Additionally this plugin supports multi page diagrams by using the alt text to select the pages by name:

![Page-2](my-diagram.drawio)
![my-custom-page-name](my-diagram.drawio)

Setup

Install plugin using pip:

pip install mkdocs-drawio

Add the plugin to your mkdocs.yml

plugins:
  - drawio

Configuration

By default the plugin uses the official url for the minified drawio javascript library. To use a custom source for the drawio viewer you can overwritte the url. This might be useful in airlocked environments.

plugins:
  - drawio:
      viewer_js: "https://viewer.diagrams.net/js/viewer-static.min.js"

How it works

  1. mkdocs generates the html per page
  2. mkdocs-drawio attaches to the on_post_page event. For more details, please have a look at the event lifecycle documentation
  3. Adds the drawio viewer library
  4. Searches through the generated html for all img tags that have a source of type .drawio
  5. Replaces the found img tags with mxgraph html blocks (actual drawio diagram content). For more details, please have a look at the official drawio.com documentation.

Contribution guide

  1. Either use the devcontainer or setup a venv with mkdocs installed
  2. Install your current local version: pip install -e .
  3. Add a test for your changes in the example directory
  4. Test your changes by starting mkdocs serve in the example directory
  5. Increase the version pyproject.toml and setup.py
  6. Open pull request

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_drawio-1.6.2.tar.gz (4.0 kB view hashes)

Uploaded Source

Built Distribution

mkdocs_drawio-1.6.2-py3-none-any.whl (4.8 kB view hashes)

Uploaded Python 3

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