Skip to content

Commit

Permalink
odoc: Fix formatting of paragraphs in lists (#2607)
Browse files Browse the repository at this point in the history
The boxing of paragraphs was wrong in heavy-syntax lists:

    (** Lists can't be nested
        {ul
         {- foo }
         {- module
            system
            documentation
            including
            + bar
            + baz
         }
        } *)
  • Loading branch information
Julow authored Oct 31, 2024
1 parent 3cb0c25 commit 0df6987
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ profile. This started with version 0.26.0.
- Display `a##b` instead of `a ## b` and similarly for operators that start with # (#2580, @v-gb)
- \* Fix arrow type indentation with `break-separators=before` (#2598, @Julow)
- Fix missing parentheses around a let in class expressions (#2599, @Julow)
- Fix formatting of paragraphs in lists in documentation (#2607, @Julow)

## 0.26.2 (2024-04-18)

Expand Down
2 changes: 1 addition & 1 deletion lib/Fmt_odoc.ml
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ let rec fmt_inline_elements c elements =

and fmt_nestable_block_element c elm =
match elm.Loc.value with
| `Paragraph elems -> fmt_inline_elements c elems
| `Paragraph elems -> hovbox 0 (fmt_inline_elements c elems)
| `Code_block (s1, s2) -> fmt_code_block c s1 s2
| `Math_block s -> fmt_math_block s
| `Verbatim s -> fmt_verbatim_block ~loc:elm.location s
Expand Down
9 changes: 9 additions & 0 deletions test/passing/tests/doc_comments-no-parse-docstrings.mli.ref
Original file line number Diff line number Diff line change
Expand Up @@ -641,3 +641,12 @@ type x =
(** at@ *)

(** \@at *)

(** Lists can't be nested
- foo
- module system documentation including
{ol
{- bar}
{- baz}
}
*)
9 changes: 9 additions & 0 deletions test/passing/tests/doc_comments-no-wrap.mli.ref
Original file line number Diff line number Diff line change
Expand Up @@ -683,3 +683,12 @@ type x =
(** at@ *)

(** \@at *)

(** Lists can't be nested
{ul
{- foo }
{- module system documentation including
+ bar
+ baz
}
} *)
9 changes: 9 additions & 0 deletions test/passing/tests/doc_comments.mli
Original file line number Diff line number Diff line change
Expand Up @@ -648,3 +648,12 @@ type x =

(** at@ *)
(** \@at *)

(** Lists can't be nested
- foo
- module system documentation including
{ol
{- bar}
{- baz}
}
*)
9 changes: 9 additions & 0 deletions test/passing/tests/doc_comments.mli.ref
Original file line number Diff line number Diff line change
Expand Up @@ -677,3 +677,12 @@ type x =
(** at@ *)

(** \@at *)

(** Lists can't be nested
{ul
{- foo }
{- module system documentation including
+ bar
+ baz
}
} *)

0 comments on commit 0df6987

Please sign in to comment.