Odoc_extension_registrySourceOdoc Extension Registry
This module provides a minimal registry for odoc tag extensions. It is kept separate to avoid circular dependencies between odoc_document and odoc_extension_api.
Resources that can be injected into the page (HTML only)
type support_file = {filename : string;Relative path, e.g., "extensions/admonition.css"
*)content : string;File content
*)}Support files that extensions want to output
type asset = {asset_filename : string;Filename for the asset, e.g., "diagram-1.png"
*)asset_content : bytes;Binary content
*)}Binary asset generated by an extension (e.g., rendered PNG)
type option_doc = {opt_name : string;Option name, e.g., "width"
*)opt_description : string;What the option does
*)opt_default : string option;Default value if any
*)}Documentation for an extension option
type extension_info = {info_kind : [ `Tag | `Code_block ];Type of extension
*)info_prefix : string;The prefix this extension handles
*)info_description : string;Short description of what it does
*)info_options : option_doc list;Supported options
*)info_example : string option;Example usage
*)}Documentation/metadata for an extension
type 'block extension_result = {content : 'block;overrides : (string * string) list;resources : resource list;assets : asset list;Binary assets to write alongside the HTML output. Use __ODOC_ASSET__filename__ placeholder in content to reference.
}Result of processing a custom tag. We use a record with a polymorphic content type that gets instantiated with the actual Block.t by odoc_document.
type 'block handler =
string ->
Comment.nestable_block_element Location_.with_location list ->
'block extension_result optionType of handler functions stored in the registry. The handler takes a tag name and content, returns an optional result. If None, the tag is handled by the default mechanism.
Support files registered by extensions
Extract the prefix from a tag name (part before the first dot)
Similar to custom tag handlers, but for code blocks like {@dot[...]}. Handlers can transform code blocks based on language and metadata.
Metadata for code blocks, extracted from parser AST
Type of code block handler functions. Takes metadata and code content, returns optional transformed result.
Registry for code block handlers, indexed by language prefix
Extract the prefix from a language tag (part before the first dot)
Extensions can register documentation that describes their options and usage. This is displayed by odoc extensions.
Registry for extension documentation