Populate a Draw.io diagram template with dynamic data and embed it in a mkdocs site
This is a proof-of-concept for generating infrastructure diagrams for project documentation using cloud provider data.
- Draw.io
- Docker and Docker Compose
-
Create a Draw.io diagram using Jinja2 syntax for applicable labels
-
Save the diagram to
docs/_diagrams
in the XML-based.drawio
format -
Use
mkdocs-drawio-file
to reference your diagram in a Markdown file indocs/
![](<DIAGRAM_NAME>.drawio)
-
Modify the
get_context()
function inrender_diagrams.py
to fetch your desired dynamic data -
Build the Docker image
# Using Docker CLI docker build --tag docs . # Using Docker Compose docker-compose build
-
Start the container
# Docker CLI docker run --name docs --detach --restart unless-stopped --publish 8000:80 docs:latest # Docker Compose docker-compose up -d
-
Navigate to
http://localhost:8000
in your browser