Skip to content

Improve Component.Fmt#1448

Open
jonludlam wants to merge 11 commits into
ocaml:masterfrom
jonludlam:moredocs
Open

Improve Component.Fmt#1448
jonludlam wants to merge 11 commits into
ocaml:masterfrom
jonludlam:moredocs

Conversation

@jonludlam

Copy link
Copy Markdown
Member

This is in advance of some more docs of the internals of odoc.

jonludlam and others added 11 commits June 10, 2026 12:58
Embed an example of the Fmt module. We'll use this example over the
next few commits to demonstrate how they change the formatting.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Render the canonical `Canonical`/`CanonicalType`/`CanonicalModuleType`
constructors with wrap2r (which picks the shorter canonical path when
short_paths is set) instead of wrap2. No change to the demonstration, which
has no canonical paths.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Add a config flag that prints Identifiers using only the leaf
name, as the HTML renderer does.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Render module expansions as `=> sig ... end` / `=> functor ...` rather than
the slightly odd `(sig : ... end)` / `(functor: ...)`.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Only print the canonical annotation when a module actually has one, instead
of emitting `(canonical=None)` on every module declaration.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Print arrow types without wrapping every left operand in parens (only when
the operand is itself an arrow), and render type-constructor applications as
`a t` / `(a, b) t` instead of `[a] t` / `[a, b] t`.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Render `with type` constraints as `t = ...` / `t := ...` instead of the
noisy `t(params ) = ...`

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…sigs

Render empty signatures as `sig end` (not `sig  end` with a stray gap),
print functor-parameter idents short when short_paths is set, and drop the
trailing `of ` on argument-less variant constructors (`A` not `A of `).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Wrap the name of a hidden module declaration in [brackets] so hidden
modules are distinguishable in the rendered signature.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…e_expr

Lay out unexpanded signatures as `sig <items> end` with hv boxing, matching
the other signature printers, instead of cramming the keyword against the
first item.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Rework the Fmt docstring from a single signature dump into worked
documentation.

The prelude now exposes [sig_of] (source string -> Component.Signature.t) and a
[readable] config alias ([default] with short_paths on) instead of the previous
all-in-one [show].

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@jonludlam jonludlam added the no changelog This pull request does not need a changelog entry label Jun 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no changelog This pull request does not need a changelog entry

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant