Skip to content

Commit ab3b75b

Browse files
Fix formatting of floating docs between recursive modules (#2455)
This fixes a bug that was introduced in commit bc91e42 (pr #2451)
1 parent ed30ab8 commit ab3b75b

File tree

4 files changed

+20
-2
lines changed

4 files changed

+20
-2
lines changed

CHANGES.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ profile. This started with version 0.26.0.
135135
- JaneStreet profile: doesn't align infix ops with open paren (#2204, @gpetiot)
136136
- Re-use the type let_binding from the parser instead of value_binding, improve the spacing of let-bindings regarding of having extension or comments (#2219, @gpetiot)
137137
- The `ocamlformat` package now only contains the binary, the library is available through the `ocamlformat-lib` package (#2230, @gpetiot)
138-
- The position of module and module type attributes is now preserved. (#2451, @emiletrotignon)
138+
- The position of module and module type attributes is now preserved. (#2451, #2455, @emiletrotignon)
139139

140140
### Added
141141

test/passing/tests/comment_in_modules.ml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,14 @@ module A (A:sig end) (* comment *) (B: sig end) : sig end = struct end
2525
module A (A:sig end) (* comment *) : sig end = struct end
2626

2727
module (* comment *) A (A : sig end) : sig end = struct end
28+
29+
module rec A : A =
30+
struct
31+
32+
end
33+
34+
(** floatting *)
35+
36+
and B : B = struct end
37+
(** about b *)
38+

test/passing/tests/comment_in_modules.ml.ref

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,10 @@ module A (A : sig end) (* comment *) (B : sig end) : sig end = struct end
2727
module A (A : sig end) : sig end = (* comment *) struct end
2828

2929
module (* comment *) A (A : sig end) : sig end = struct end
30+
31+
module rec A : A = struct end
32+
33+
(** floatting *)
34+
35+
(** about b *)
36+
and B : B = struct end

vendor/parser-extended/docstrings.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ let add_text_attrs dsl attrs =
171171
(** {!add_text_attrs} but operate on [ext_attrs]. *)
172172
let add_text_attrs' text attrs' =
173173
let open Parsetree in
174-
{ attrs' with attrs_before = add_text_attrs text attrs'.attrs_before }
174+
{ attrs' with attrs_after = add_text_attrs text attrs'.attrs_after }
175175

176176
(* Find the first non-info docstring in a list, attach it and return it *)
177177
let get_docstring ~info dsl =

0 commit comments

Comments
 (0)