Skip to main content

mkdocs-diagrams

A plugin for the MkDocs documentation site generator which facilitates easy embedding of system architecture diagrams through the Diagrams project (view examples).

Installation

mkdocs-diagrams is available on PyPI. It can be installed through pip install mkdocs-diagrams or equivalent command with pipenv or poetry.

You'll also need to have the graphviz dot tool installed on your system. It's available as graphviz in most package managers.

Once installed, configure MkDocs to use this plugin by including diagrams in the plugins list in your mkdocs.yml. For example:

plugins:
  - diagrams
  - search

(If you don't have a plugins key in your config yet, you'll almost surely want to include search as well. It's a default plugin that will otherwise get deactivated.)

Usage

Warning: This plugin will execute .diagram.py files during build, as that is how Diagrams itself operates. Be careful using this plugin with untrusted input as this effectively allows arbitrary code execution.

Once installed, the diagrams plugin can be used by including diagrams files in your docs directory.

For example, create a file named example.diagrams.py with the following contents:

from diagrams import Cluster, Diagram
from diagrams.aws.compute import ECS, EKS, Lambda
from diagrams.aws.database import Redshift
from diagrams.aws.integration import SQS
from diagrams.aws.storage import S3


with Diagram("Event Processing", show=False):
    source = EKS("k8s source")

    with Cluster("Event Flows"):
        with Cluster("Event Workers"):
            workers = [ECS("worker1"),
                       ECS("worker2"),
                       ECS("worker3")]

        queue = SQS("event queue")

        with Cluster("Processing"):
            handlers = [Lambda("proc1"),
                        Lambda("proc2"),
                        Lambda("proc3")]

    store = S3("events store")
    dw = Redshift("analytics")

    source >> workers >> queue >> handlers
    handlers >> store
    handlers >> dw

When MkDocs is run (either with build or serve), this will result in a file named event_processing.png being created. Include this in your markdown files using regular image syntax: ![Event processing architecture](event_processing.png)

Configuration

This plugin supports a few config options, which can be set as follows:

plugins:
  - diagrams:
      file_extension: ".diagrams.py"
      max_workers: 5

file_extension

Sets the filename extension for diagram files. When mkdocs build or mkdocs serve is run, all files ending in this extension will be executed.

Default: .diagrams.py

max_workers

A pool of workers is used to render diagram files in parallel on multi-core systems. Setting this allows you to limit the number of workers to this amount.

Default: Dynamically chosen (os.cpu_count() + 2)

Metadata

Release files for mkdocs-diagrams 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mkdocs-diagrams 1.0.0
File Size Uploaded Provenance Actions
mkdocs-diagrams-1.0.0.tar.gz 5.6 kB Without provenance Details for mkdocs-diagrams-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for mkdocs-diagrams 1.0.0
File Interpreter ABI Platform Actions
mkdocs_diagrams-1.0.0-py3-none-any.whl Python 3 none any Details for mkdocs_diagrams-1.0.0-py3-none-any.whl

Total release size: 11.1 kB

Release files / mkdocs-diagrams-1.0.0.tar.gz

Download URL mkdocs-diagrams-1.0.0.tar.gz
Size 5.6 kB
Tags Source
SHA-256 checksum
How to use checksums
769ee4ff3c137a914429acb2b762ce4291ab9408ee5211ed77b90d2c9d32bad5
BLAKE2b-256 checksum
How to use checksums
fa9030ed25466788e279cc75bc9c503daac02837682fce0fb7d96058c99b11d1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.2.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.5

Release files / mkdocs_diagrams-1.0.0-py3-none-any.whl

Download URL mkdocs_diagrams-1.0.0-py3-none-any.whl
Size 5.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
38820d76e1aef4dd9766e8e9df164d43b0a2e1685dc4397027664371b0e4e145
BLAKE2b-256 checksum
How to use checksums
6da23babdc8bb8593c9a35ff795c493eaf1601466f8dacca2df3c996a97636a6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.2.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.5

Security for mkdocs-diagrams 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page