Admonition Extension for odoc
This extension adds support for admonition blocks (callouts) in odoc documentation. Admonitions are used to highlight important information, warnings, tips, and other notable content.
Installation
opam install odoc-admonition-extensionOnce installed, the extension is automatically loaded by odoc.
Usage
Use the @admonition tag variants in documentation comments:
(** Some documentation.
@admonition.note This is a note with important information.
*)Examples
Note
Warning
Tip
Important
Admonition Kinds
The extension supports the following tag variants:
Tag | Purpose |
|---|---|
| General supplementary information |
| Helpful suggestions and best practices |
| Potential issues or things that could go wrong |
| Critical information that should not be missed |
In API Documentation
Admonitions are especially useful in module and function documentation:
(** Connect to a database.
@admonition.warning This function will block until the connection
is established. Use {!connect_async} for non-blocking connections.
@admonition.tip For connection pooling, see {!Pool.create}.
*)
val connect : config -> tStyling
The extension generates HTML with appropriate CSS classes for styling. Each admonition type has a distinct visual appearance with colors that match its purpose:
- Note: Blue, informational
- Tip: Green, helpful
- Warning: Orange, attention
- Important: Red, critical
The CSS is automatically included when the extension is loaded and supports both light and dark modes.