Back to Skills

ocaml-docs

verified

Fixing odoc documentation warnings and errors. Use when running dune build @doc, resolving reference syntax issues, cross-package references, ambiguous references, hidden fields, or @raise tags in OCaml documentation.

View on GitHub

Marketplace

ocaml-claude-marketplace

avsm/ocaml-claude-marketplace

Plugin

ocaml-dev

development

Repository

avsm/ocaml-claude-marketplace
15stars

plugins/ocaml-dev/skills/ocaml-docs/SKILL.md

Last Verified

January 20, 2026

Install Skill

Select agents to install to:

Scope:
npx add-skill https://github.com/avsm/ocaml-claude-marketplace/blob/main/plugins/ocaml-dev/skills/ocaml-docs/SKILL.md -a claude-code --skill ocaml-docs

Installation paths:

Claude
.claude/skills/ocaml-docs/
Powered by add-skill CLI

Instructions

# OCaml Documentation (odoc) Skill

## When to Use

Use this skill when fixing odoc documentation warnings, typically from `dune build @doc`.

**Prerequisites:** This skill covers odoc v3 syntax which is not yet in released versions of dune or odoc. You need:
- dune pinned to https://github.com/jonludlam/dune/tree/odoc-v3-rules-3.21
- odoc pinned to https://github.com/jonludlam/odoc/tree/staging

## Reference Syntax

Use path-based disambiguation `{!Path.To.kind-Name}` rather than `{!kind:Path.To.Name}`:

```ocaml
(* Correct *)
{!Jsont.exception-Error}
{!Proto.Incoming.t.constructor-Message}
{!module-Foo.module-type-Bar.exception-Baz}

(* Incorrect *)
{!exception:Jsont.Error}
{!constructor:Proto.Incoming.t.Message}
```

This allows disambiguation at any position in the path.

## Reference Kinds

- `module-` for modules
- `type-` for types
- `val-` for values
- `exception-` for exceptions
- `constructor-` for variant constructors
- `field-` for record fields
- `module-type-` for module types

## Cross-Package References

When odoc cannot resolve a reference to another package, add a documentation dependency in `dune-project`:

```lisp
(package
 (name mypackage)
 ...
 (documentation (depends other-package)))
```

Do NOT convert doc references `{!Foo}` to code markup `[Foo]` - this loses the hyperlink.

## Cross-Library References (Same Package)

When referencing modules from another library in the same package, use the full path through re-exported modules.

Example: If `claude.mli` has `module Proto = Proto`, reference proto modules as `{!Proto.Incoming}` not `{!Incoming}`.

## Missing Module Exports

If odoc reports "Couldn't find X" where X is the last path component:

1. Check if the module is re-exported in the parent module's `.mli`
2. Add `module X = X` to the parent's `.mli` if missing

## Ambiguous References

When odoc warns about ambiguity (e.g., both an exception and module named `Error`):

```ocaml
{!Jsont.exception-Error}  (* for the exception *)
{!Jsont

Validation Details

Front Matter
Required Fields
Valid Name Format
Valid Description
Has Sections
Allowed Tools
Instruction Length:
4239 chars