File tree Expand file tree Collapse file tree 17 files changed +92
-86
lines changed
test/passing/refs.janestreet Expand file tree Collapse file tree 17 files changed +92
-86
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,14 @@ Items marked with an asterisk (\*) are changes that are likely to format
4
4
existing code differently from the previous release when using the default
5
5
profile. This started with version 0.26.0.
6
6
7
+ ## unreleased
8
+
9
+ ### Fixed
10
+
11
+ - Fixed ` wrap-comments=true ` not working with the janestreet profile (#2645 , @Julow )
12
+ Asterisk-prefixed comments are also now formatted the same way as with the
13
+ default profile.
14
+
7
15
## 0.27.0
8
16
9
17
### Highlight
Original file line number Diff line number Diff line change @@ -146,7 +146,7 @@ let split_asterisk_prefixed =
146
146
147
147
let mk ?(prefix = " " ) ?(suffix = " " ) kind = {prefix; suffix; kind}
148
148
149
- let decode_comment ~ parse_comments_as_doc txt loc =
149
+ let decode_comment txt loc =
150
150
let txt =
151
151
(* Windows compatibility *)
152
152
let f = function '\r' -> false | _ -> true in
@@ -170,7 +170,6 @@ let decode_comment ~parse_comments_as_doc txt loc =
170
170
| '=' -> mk (Verbatim txt)
171
171
| _ when is_all_whitespace txt ->
172
172
mk (Verbatim " " ) (* Make sure not to format to [(* *) ]. *)
173
- | _ when parse_comments_as_doc -> mk (Doc txt)
174
173
| _ -> (
175
174
let lines =
176
175
let content_offset = opn_offset + 2 in
@@ -194,6 +193,6 @@ let decode_docstring _loc = function
194
193
| "\n " | " " -> mk (Verbatim " " )
195
194
| txt -> mk ~prefix: " *" (Doc txt)
196
195
197
- let decode ~ parse_comments_as_doc = function
198
- | Comment {txt; loc} -> decode_comment ~parse_comments_as_doc txt loc
196
+ let decode = function
197
+ | Comment {txt; loc} -> decode_comment txt loc
199
198
| Docstring {txt; loc} -> decode_docstring loc txt
Original file line number Diff line number Diff line change @@ -48,4 +48,4 @@ type decoded =
48
48
; suffix : string (* * Just before the closing. *)
49
49
; kind : decoded_kind }
50
50
51
- val decode : parse_comments_as_doc : bool -> t -> decoded
51
+ val decode : t -> decoded
Original file line number Diff line number Diff line change @@ -581,18 +581,22 @@ end
581
581
582
582
let fmt_cmt (conf : Conf.t ) cmt ~fmt_code =
583
583
let open Fmt in
584
- let parse_comments_as_doc = conf.fmt_opts.ocp_indent_compat.v in
585
- let decoded = Cmt. decode ~parse_comments_as_doc cmt in
584
+ let decoded = Cmt. decode cmt in
586
585
(* TODO: Offset should be computed from location. *)
587
586
let offset = 2 + String. length decoded.prefix in
588
587
let pro = str " (*" $ str decoded.prefix
589
588
and epi = str decoded.suffix $ str " *)" in
589
+ let fmt_doc txt =
590
+ Doc. fmt ~pro ~epi ~fmt_code conf ~loc: (Cmt. loc cmt) txt ~offset
591
+ in
590
592
match decoded.kind with
591
593
| Verbatim txt -> Verbatim. fmt ~pro ~epi txt
592
- | Doc txt ->
593
- Doc. fmt ~pro ~epi ~fmt_code conf ~loc: (Cmt. loc cmt) txt ~offset
594
+ | Doc txt -> fmt_doc txt
594
595
| Normal txt ->
595
- if conf.fmt_opts.wrap_comments.v then Wrapped. fmt ~pro ~epi txt
596
+ if
597
+ conf.fmt_opts.ocp_indent_compat.v && conf.fmt_opts.parse_docstrings.v
598
+ then fmt_doc txt
599
+ else if conf.fmt_opts.wrap_comments.v then Wrapped. fmt ~pro ~epi txt
596
600
else Unwrapped. fmt ~pro ~epi txt
597
601
| Code code -> Cinaps. fmt ~pro ~epi ~fmt_code conf ~offset code
598
602
| Asterisk_prefixed lines -> Asterisk_prefixed. fmt ~pro ~epi lines
Original file line number Diff line number Diff line change @@ -152,14 +152,18 @@ let make_mapper ~ignore_doc_comments ~normalize_doc =
152
152
; typ }
153
153
154
154
let normalize_cmt (conf : Conf.t ) =
155
- let parse_comments_as_doc = conf.fmt_opts.ocp_indent_compat.v in
155
+ let parse_comments_as_doc =
156
+ conf.fmt_opts.ocp_indent_compat.v && conf.fmt_opts.parse_docstrings.v
157
+ in
156
158
object (self )
157
159
method cmt c =
158
- let decoded = Cmt. decode ~parse_comments_as_doc c in
160
+ let decoded = Cmt. decode c in
159
161
match decoded.Cmt. kind with
160
162
| Verbatim txt -> txt
161
163
| Doc txt -> self#doc txt
162
- | Normal txt -> Docstring. normalize_text txt
164
+ | Normal txt ->
165
+ if parse_comments_as_doc then self#doc txt
166
+ else Docstring. normalize_text txt
163
167
| Code txt -> self#code txt
164
168
| Asterisk_prefixed lines ->
165
169
String. concat ~sep: " " (List. map ~f: Docstring. normalize_text lines)
Original file line number Diff line number Diff line change @@ -45,7 +45,7 @@ type typ = typ
45
45
46
46
(* TEST
47
47
arguments = "???"
48
- *)
48
+ *)
49
49
50
50
(* On Windows the runtime expand windows wildcards (asterisks and
51
51
* question marks).
@@ -57,4 +57,4 @@ type typ = typ
57
57
*
58
58
* The source code of this test is empty: we just check the arguments
59
59
* expansion.
60
- * * )
60
+ *)
Original file line number Diff line number Diff line change @@ -483,13 +483,13 @@ let _ =
483
483
*)
484
484
();
485
485
(* indentation preserved
486
- *)
486
+ *)
487
487
();
488
488
(* indentation preserved
489
- *)
489
+ *)
490
490
();
491
491
(* indentation not preserved
492
- *)
492
+ *)
493
493
()
494
494
;;
495
495
Original file line number Diff line number Diff line change @@ -483,13 +483,13 @@ let _ =
483
483
*)
484
484
();
485
485
(* indentation preserved
486
- *)
486
+ *)
487
487
();
488
488
(* indentation preserved
489
- *)
489
+ *)
490
490
();
491
491
(* indentation not preserved
492
- *)
492
+ *)
493
493
()
494
494
;;
495
495
Original file line number Diff line number Diff line change @@ -257,8 +257,8 @@ module A = struct
257
257
end
258
258
259
259
(* Same with get_pure, except that when we have both "x = t" and "y = t" where t is a primed ident,
260
- * we add "x = y" to the result. This is crucial for the normalizer, as it tend to drop "x = t" before
261
- * processing "y = t". If we don't explicitly preserve "x = y", the normalizer cannot pick it up *)
260
+ * we add "x = y" to the result. This is crucial for the normalizer, as it tend to drop "x = t" before
261
+ * processing "y = t". If we don't explicitly preserve "x = y", the normalizer cannot pick it up *)
262
262
let _ = ()
263
263
264
264
(** Tags without text *)
Original file line number Diff line number Diff line change @@ -257,8 +257,8 @@ module A = struct
257
257
end
258
258
259
259
(* Same with get_pure, except that when we have both "x = t" and "y = t" where t is a primed ident,
260
- * we add "x = y" to the result. This is crucial for the normalizer, as it tend to drop "x = t" before
261
- * processing "y = t". If we don't explicitly preserve "x = y", the normalizer cannot pick it up *)
260
+ * we add "x = y" to the result. This is crucial for the normalizer, as it tend to drop "x = t" before
261
+ * processing "y = t". If we don't explicitly preserve "x = y", the normalizer cannot pick it up *)
262
262
let _ = ()
263
263
264
264
(** Tags without text *)
You can’t perform that action at this time.
0 commit comments