Skip to main content

PyPI - Downloads

MkDocs-Build-Plantuml-Plugin

Table of Contents

About the Project

This plugin automates the generation of PlantUML image files when using mkdocs serve.

The motivation behind this plugin is to provide a solution for users who prefer not to use inline diagrams and have encountered challenges with non-functional !includes.

Note: If you want inline diagrams in your Markdown files

```plantuml
Alice -> Bob
```

this plugin does not meet your requirements. Please check out plantuml-markdown which does exactly that.

Prerequisites

You need to have installed:

  • Python3
  • MkDocs
  • Java for Plantuml (If running locally)
  • Plantuml (if running locally)
  • This plugin (needs httplib2 for server rendering)

On macOS you can install plantuml with homebrew which puts a plantuml executable in /usr/local/bin/plantuml.

Installation

pip3 install mkdocs-build-plantuml-plugin

Usage

Plugin Settings

In mkdocs.yml add this plugin section (depicted are the default values):

plugins:
  - search
  - build_plantuml:
      render: 'server' # or "local" for local rendering
      bin_path: '/usr/local/bin/plantuml' # ignored when render: server
      server: 'http://www.plantuml.com/plantuml' # official plantuml server
      disable_ssl_certificate_validation: true # for self-signed and invalid certs
      output_format: 'svg' # or "png"
      allow_multiple_roots: false # in case your codebase contains more locations for diagrams (all ending in diagram_root)
      diagram_root: 'docs/diagrams' # should reside under docs_dir
      output_folder: 'out'
      input_folder: 'src'
      input_extensions: '' # comma separated list of extensions to parse, by default every file is parsed

It is recommended to use the server option, which is much faster than local.

Example folder structure

This would result in this directory layout:

docs/                         # the default MkDocs docs_dir directory
  diagrams/
    include/                  # for include files like theme.puml etc (optional, won't be generated)
    out/                      # the generated images, which can be included in your md files
      subdir1/file1.svg       # you can organise your diagrams in subfolders, see below
      file.svg
    src/                      # the Plantuml sources
      subdir1/file1.puml
      subdir2/
      file.puml
mkdocs.yml                    # mkdocs configuration file

When starting with mkdocs serve, it will create all diagrams initially.

Afterwards, it checks if the *.puml (or other ending) file has a newer timestamp than the corresponding file in out. If so, it will generate a new image (works also with includes). This way, it won‘t take long until the site reloads and does not get into a loop.

Including generated images

Inside your index.md or any other Markdown file you can then reference any created image as usual:

# My MkDocs Document

## Example Plantuml Images

![file](diagrams/out/file.svg)

![file1](diagrams/out/subdir1/file1.svg)

Dark Mode Support

Since Version 1.4 this plugin can support dark mode when rendering with server (prefers-color-scheme).

Note: Not in local mode, only server rendering mode

  1. Grab a general (ie. for Material Theme) dark mode support css file (i.e. from henrywhitaker3/mkdocs-material-dark-theme) for your theme

  2. Enable theme support in this plugin:

     - build_plantuml:
         [...]
         theme_enabled: true
         theme_folder: "include/themes"
         theme_light: "light.puml"
         theme_dark: "dark.puml"
    
  3. You have to provide two puml theme files, ie mydarkmode.puml and mylightmode.puml

  4. In the out directory a <file>.<ext> will be created and additionally a <file>_dark.<ext>

  5. Insert your images in markdown with ![file](diagrams/out/file.svg#darkable) (this selector is then used in the JS file to know which images have to be exchanged)

  6. provide extra_javascript file which handles the switch

You can find an example in the example folder

Example Output

DarkMode

Known restrictions

  • If you use !include and the render: "server" option, this plugin merges those files manually. If there are any issues or side effects because of that, please open a ticket.
  • Dark mode / theme support is currently only available in server rendering mode.

Contributing

Contributions are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request.

Build

Metadata

Release files for mkdocs-build-plantuml-plugin-ardihikaru 1.9.6

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-build-plantuml-plugin-ardihikaru 1.9.6
File Size Uploaded
mkdocs-build-plantuml-plugin-ardihikaru-1.9.6.tar.gz 10.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mkdocs-build-plantuml-plugin-ardihikaru 1.9.6
File Interpreter ABI Platform
mkdocs_build_plantuml_plugin_ardihikaru-1.9.6-py3-none-any.whl Python 3 none any Details

Total release size: 20.3 kB

Release files / mkdocs-build-plantuml-plugin-ardihikaru-1.9.6.tar.gz

Download URL mkdocs-build-plantuml-plugin-ardihikaru-1.9.6.tar.gz
Size 10.8 kB
Tags Source
SHA-256 checksum
How to use checksums
dac2e093450896b67c15ac64665d676b05588776e74ac0255d9d7c98ba05d00e
BLAKE2b-256 checksum
How to use checksums
4d257b046d7b603d5199fff108ba4e054d64840ee2d758b8b3380469fcbefc6e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.4.2 requests/2.31.0 setuptools/45.2.0 requests-toolbelt/0.8.0 tqdm/4.30.0 CPython/3.8.10

Release files / mkdocs_build_plantuml_plugin_ardihikaru-1.9.6-py3-none-any.whl

Download URL mkdocs_build_plantuml_plugin_ardihikaru-1.9.6-py3-none-any.whl
Size 9.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
48e3f15c2fbb1ffb89b71753305a4743811880dea14198e0b6899344feaa773f
BLAKE2b-256 checksum
How to use checksums
69223e34e142a5771d89cdd10d704b361ddedc832291dbbe9e1ee595531813a7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.4.2 requests/2.31.0 setuptools/45.2.0 requests-toolbelt/0.8.0 tqdm/4.30.0 CPython/3.8.10

Release history Release notifications | RSS feed

This release

1.9.6 This release

2 release files

1.9.5

2 release files

1.9.4

2 release files

1.9.3

2 release files

1.9.2

2 release files

1.9.1

2 release files

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