Skip to content

Conversation

@Julow
Copy link
Collaborator

@Julow Julow commented Nov 27, 2025

Closes #2702

The indentation of code-blocks containing OCaml code is reduced by 2 to avoid changing the generated documentation. The indentation within code-blocks is now significative in Odoc and shows up in generated documentation.

Odoc now strips the indentation from code and verbatim blocks. It
doesn't use the indentation of the least indented line, like
OCamlformat, but instead use the indentation of the block opening.
In code blocks, newlines can be turned into `\\n` (or the opposite) when
formatting string literals that need to break. Update the normalization
function to avoid crashing when that happens.
The updated Odoc parser considers that code blocks horizontally start at
the opening bracket. It no longer uses the indentation of the least
indented line for that.
As a result, OCamlformat cannot indent code blocks without changing
their content.

The indentation is also removed in code blocks that are formatted, to
avoid adding visible indentation in rendered documentation.
During normalisation, allow whitespaces to disappear from code blocks.
This happens when code if formatted.
@Julow Julow merged commit cb01918 into ocaml-ppx:main Dec 1, 2025
10 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Upgrade Odoc's parser

1 participant