MSC Extension for odoc
This extension adds support for Message Sequence Charts (MSC) in odoc documentation. MSC is a graphical and textual language for describing interactions between components.
Installation
opam install odoc-msc-extensionOnce installed, the extension is automatically loaded by odoc.
Usage
Use the {@msc[...]} tag to embed Message Sequence Charts:
{@msc[
msc {
a, b, c;
a -> b [label="request"];
b -> c [label="forward"];
c -> b [label="response"];
b -> a [label="reply"];
}
]}Examples
Simple Request-Response
Three-Party Interaction
With Conditions and Boxes
Parallel Messages
Authentication Flow
Options
The extension supports the following options:
named-style- MscGen style:basic,lazy,classic, etc.width- CSS width (e.g.,500px,100%)height- CSS heightformat- Output format: omit for client-side JS, orpng/svgfor server-side rendering (requiresmscgenCLI tool)
How It Works
By default, diagrams are rendered client-side using the mscgen_js library loaded from a CDN. The extension injects the necessary <script> tags into the HTML output.
For server-side rendering, install the mscgen CLI tool and use format=png or format=svg.
Syntax Reference
MSC syntax basics:
- Declare entities:
a, b, c; - Messages:
a -> b [label="text"]; - Return messages:
a <- b [label="text"]; - Boxes:
a box a [label="text"]; - Separators:
--- [label="text"];
See the MscGen documentation for the complete syntax reference.