Skip to main content

MkDocs plugin to render Diagrams files

Project description

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)

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-diagrams-0.0.2.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

mkdocs_diagrams-0.0.2-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

Details for the file mkdocs-diagrams-0.0.2.tar.gz.

File metadata

  • Download URL: mkdocs-diagrams-0.0.2.tar.gz
  • Upload date:
  • Size: 5.2 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.2.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.2

File hashes

Hashes for mkdocs-diagrams-0.0.2.tar.gz
Algorithm Hash digest
SHA256 41e538bab943005e864f6d0082cfdc80892ca05dee01037584317d157f6b73e7
MD5 7f5fab5cf4007f72a17cac9df8002a9c
BLAKE2b-256 a615dcb08d422c297c57b6141c2f38bbe22db719f8d2ef9ca68dcca9f440dcfd

See more details on using hashes here.

File details

Details for the file mkdocs_diagrams-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: mkdocs_diagrams-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 5.3 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.2.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.2

File hashes

Hashes for mkdocs_diagrams-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c97d084b9ef581f968236a27031fb61b22ff98b21a5e98dd486d4ca9e943fa01
MD5 6a93fab05b24c5e35d9caf84176be3dc
BLAKE2b-256 ed9e5507beb05e1bddd9f00a8ebcd91df9f36b6147d24c47f0cc02a2bd40da79

See more details on using hashes here.

Supported by

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