Skip to main content

Package that brings PlantUML to MkDocs

Project description

logo

PyPI version PyPI Downloads

rd_mkdocs_puml is a fork of mkdocs_puml. It is a fast and simple package that brings plantuml diagrams to MkDocs documentation. The additional functionality it provides is that it can be used without ssl verification.

Install

Run the following command to install the package

pip install rd_mkdocs_puml

How to use

Just add plantuml plugin into plugins section of your mkdocs.yml file, in order to use puml with mkdocs.

plugins:
    - plantuml:
        puml_url: https://www.plantuml.com/plantuml/

plantuml plugin uses PlantUML only as an HTTP service. So, you should necessarily specify puml_url config.

The plantuml config with the full list of parameters is below

plugins:
    - plantuml:
        puml_url: https://www.plantuml.com/plantuml/
        num_workers: 8
        puml_keyword: puml
        verify_ssl: true

Where

Parmeter Type Descripton
puml_url str. Required URL to the plantuml service
num_workers int. Default 8 Max amount of concurrent workers that request plantuml service
puml_keyword str. Default puml The keyword for PlantUML code fence, i.e. ```puml ```
verify_ssl bool. Default True Designates whether requests should verify SSL or not

Now, you can put your puml diagrams into your .md documentation. For example,

## PUML Diagram

```puml
@startuml
Bob -> Alice : hello
@enduml
```

At the build step mkdocs sends requests to puml_url and substitutes your diagram with the svg images from the responses.

Run PlantUML service with Docker

It is possible to run plantuml/plantuml-server as a Docker container.

Add a new service to the docker-compose.yml file

version: "3"
services:
  puml:
    image: plantuml/plantuml-server
    ports:
      - '8080:8080'

Then substitute puml_url config with the local URL in the mkdocs.yml file

plugins:
    - plantuml:
        puml_url: http://127.0.0.1:8080
        num_workers: 8

Obviously, this approach works faster than using remote plantuml.com.

Standalone usage

You can use PlantUML converter without mkdocs. Below is the example,

from rd_mkdocs_puml.puml import PlantUML

puml_url = "https://www.plantuml.com/plantuml"

diagram1 = """
@startuml
Bob -> Alice : hello
@enduml
"""

diagram2 = """
@startuml
Jon -> Sansa : hello
@enduml
"""

puml = PlantUML(puml_url, num_worker=2)
svg_for_diag1, svg_for_diag2 = puml.translate([diagram1, diagram2])

How it works

The package uses PlantUML as an HTTP service. It sends GET requests to PlantUML service and receives svg images representing the diagrams.

The plantuml plugin parses .md documentation files and looks for

```puml

```

code blocks. When puml code block is found it is saved to the buffer for a later request to PlantUML service. In this step, we replace puml block with the uuid.

NOTE you must set puml keyword as an indicator that the PlantUML diagram is located in the block. Default keyword can be changed for the custom one in mkdocs.yml config file by using puml_keyword parameter.

After all pages are parsed, plantuml plugin requests PlantUML service with the collected diagrams. After the responses are received, the package substitutes uuid codes in markdown files with the corresponding svg images.

License

The project is licensed under MIT license.

Diagram icon created by Freepik.

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

rd_mkdocs_puml-1.2.4.tar.gz (6.7 kB view details)

Uploaded Source

Built Distribution

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

rd_mkdocs_puml-1.2.4-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

Details for the file rd_mkdocs_puml-1.2.4.tar.gz.

File metadata

  • Download URL: rd_mkdocs_puml-1.2.4.tar.gz
  • Upload date:
  • Size: 6.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.2

File hashes

Hashes for rd_mkdocs_puml-1.2.4.tar.gz
Algorithm Hash digest
SHA256 3fb2c118a81550cbd663f3a292f183112f5f58a50e2e5291740cf708fedd39be
MD5 b889d169f73a98979e3355cdaa2b4530
BLAKE2b-256 0f3dab088a2ca2aa6fe5e4bab8b219679779dbeb65c9fc102493d3b608037c1d

See more details on using hashes here.

File details

Details for the file rd_mkdocs_puml-1.2.4-py3-none-any.whl.

File metadata

  • Download URL: rd_mkdocs_puml-1.2.4-py3-none-any.whl
  • Upload date:
  • Size: 8.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.2

File hashes

Hashes for rd_mkdocs_puml-1.2.4-py3-none-any.whl
Algorithm Hash digest
SHA256 4d59d8a2d2aac9a2b03129790c4a36d3908e654a47b7adde0ca5298d0439c71f
MD5 a307d20eab38e9ee15e74c309f989e25
BLAKE2b-256 43be92bf6e71e3e9d5198b5101713230656b0dc82a822c33c832b3cbaf8eca8d

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