Diagram Support with Kroki
This guide explains how to use Kroki for text-based diagram rendering in Antora documentation sites.
The Problem
Documentation often requires diagrams to explain architecture, workflows, processes, and data models. Traditionally, teams face several challenges:
-
Tool Fragmentation - Different diagram types require different tools (PlantUML for UML, Mermaid for flowcharts, Graphviz for graphs, etc.)
-
Binary Files - Image-based diagrams (PNG, JPG) are binary files that don’t work well with version control (no diffs, merge conflicts)
-
Maintenance Burden - Updating diagrams requires opening specialized tools, exporting to image formats, committing both source and image files, and keeping them in sync
-
Collaboration Issues - Not all team members have the same diagram tools installed
-
Documentation Drift - Diagrams become outdated because updating them is cumbersome
The Solution: Kroki
Kroki provides unified diagram rendering for 20+ formats through a single service.
How It Works
During the Antora build process:
-
Kroki extension detects diagram blocks in your AsciiDoc files
-
Sends the diagram source to the Kroki service
-
Receives rendered SVG/PNG images
-
Embeds them in the generated HTML documentation
Supported Diagram Types
| Format | Use Case | Example |
|---|---|---|
PlantUML |
UML diagrams, sequence diagrams, component diagrams |
Architecture, API flows |
C4 |
Architecture diagrams (Context, Container, Component, Code) |
System architecture |
BPMN |
Business process diagrams |
Workflow documentation |
Mermaid |
Flowcharts, sequence diagrams, Gantt charts |
Process flows |
GraphViz |
Graph visualizations |
Dependency graphs |
Ditaa |
ASCII art diagrams |
Simple sketches |
BlockDiag |
Block diagrams |
Infrastructure diagrams |
SeqDiag |
Sequence diagrams |
Interaction flows |
ActDiag |
Activity diagrams |
User journeys |
Nwdiag |
Network diagrams |
Network topology |
ERD |
Entity-relationship diagrams |
Database schemas |
Excalidraw |
Hand-drawn style diagrams |
Informal diagrams |
Vega/Vega-Lite |
Data visualizations |
Charts and graphs |
Using the VSHN Antora Image
Why VSHN?
The official antora/antora:latest Docker image is minimal and doesn’t include diagram rendering extensions. The VSHN extended Antora image (ghcr.io/vshn/antora) includes:
-
Kroki Pre-installed -
asciidoctor-krokiextension ready to use -
Additional Tools -
antora-site-generator-lunr(search),make,git,yq,jq -
Drop-in Replacement - Same CLI interface as official Antora image
-
Version Pinning - Explicit version tags for reproducible builds
-
Community Maintained - Actively maintained by VSHN
Decision Matrix
| Criteria | Official + Custom | VSHN Image |
|---|---|---|
Diagram Support |
Need to add |
Pre-installed |
Maintenance Effort |
High (custom builds) |
Low (community maintained) |
Additional Features |
None |
Search, tools |
Time to Deploy |
Requires build pipeline |
Immediate |
Registry Setup |
Required |
Public registry (ghcr.io) |
Usage Examples
PlantUML Sequence Diagram
[plantuml,format=svg]
----
@startuml
actor User
participant "API Gateway" as API
participant "Auth Service" as Auth
database "User DB" as DB
User -> API: POST /login
API -> Auth: Validate credentials
Auth -> DB: Query user
DB --> Auth: User data
Auth --> API: JWT token
API --> User: 200 OK + token
@enduml
----
C4 Architecture Diagram
[plantuml,format=svg]
----
@startuml
!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Container.puml
Person(user, "User", "Documentation reader")
System_Boundary(docs, "Documentation System") {
Container(nginx, "NGINX", "Web Server", "Serves static content")
Container(antora, "Antora", "Generator", "Builds documentation")
}
System_Ext(git, "Git Repository", "Source content")
System_Ext(kroki, "Kroki", "Diagram renderer")
Rel(user, nginx, "Views", "HTTPS")
Rel(antora, git, "Clones", "Git")
Rel(antora, kroki, "Renders diagrams", "HTTPS")
Rel(antora, nginx, "Generates content")
@enduml
----
Benefits
For Documentation Authors
-
Version Control Friendly - Diagrams are text, get proper diffs
-
No Special Tools - Just a text editor
-
Fast Updates - Change text, commit, done
-
Consistency - Diagrams follow same style automatically
-
Collaboration - Easy to review and suggest changes
Security Considerations
Public Kroki Service
By default, diagrams are rendered using the public Kroki service at https://kroki.io
Privacy implications:
-
Diagram source code is sent to external service
-
Consider if your diagrams contain sensitive information
-
Public service has rate limits
Self-Hosted Kroki
If you need to keep diagram source private, deploy your own Kroki instance:
# antora-playbook.yml
asciidoc:
attributes:
kroki-server-url: https://kroki.your-company.com
See Kroki Installation Guide for setup instructions.
Performance
Troubleshooting
Diagram Not Rendering
Check 1: Verify extension is enabled
grep -A5 "asciidoc:" antora-playbook.yml
Check 2: Check build logs for errors
Check 3: Test diagram syntax at https://kroki.io