Skip to content

Commit d887231

Browse files
authored
Set 'doc-comments = before' in profile 'ocamlformat' (#1325)
* Set 'doc-comments = before' in profile 'ocamlformat' This option is now deprecated, the value currently used by the ocamlformat profile will be removed. This is already done for the conventional profile, the new `doc-comments-val = after` option (set by default) minimizes the diffs.
1 parent 1088a90 commit d887231

26 files changed

+91
-90
lines changed

CHANGES.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@
1717
+ Add the option `doc-comments-val=before|after` (#1012) (Jules Aguillon)
1818
This option set the placement of documentation comment on `val` and `external` only.
1919
It is set to `after` by default.
20-
The default for `doc-comments` is changed from `after` to `before`, this
21-
option will be deleted in the future.
20+
21+
+ The default for `doc-comments` is changed from `after` to `before` (#1012, #1325) (Jules Aguillon)
22+
This affects both `conventional` (default) and `ocamlformat` profiles.
2223

2324
+ Some options are now deprecated:
2425
* `doc-comments` (#1293, #1012)

lib/Ast.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,9 @@ val assoc_of_prec : prec -> assoc
157157
(** [assoc_of_prec prec] is the associativity of Ast terms with precedence
158158
[prec]. (Associativity is uniform across precedence levels.) *)
159159

160-
type 'a xt = private {ctx: t; ast: 'a}
161160
(** Term-in-context [{ctx; ast}] records that [ast] is (considered to be) an
162161
immediate sub-term of [ctx]. *)
162+
type 'a xt = private {ctx: t; ast: 'a}
163163

164164
val sub_typ : ctx:t -> core_type -> core_type xt
165165
(** Construct a core_type-in-context. *)

lib/Conf.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1461,7 +1461,7 @@ let ocamlformat_profile =
14611461
; comment_check= true
14621462
; disable= false
14631463
; disambiguate_non_breaking_match= false
1464-
; doc_comments= `After
1464+
; doc_comments= `Before
14651465
; doc_comments_val= `After
14661466
; doc_comments_padding= 2
14671467
; doc_comments_tag_only= `Default

lib/Conf.mli

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
(** Configuration options *)
1313

14+
(** Formatting options *)
1415
type t =
1516
{ align_cases: bool
1617
; align_constructors_decl: bool
@@ -86,7 +87,6 @@ type t =
8687
; type_decl_indent: int
8788
; wrap_comments: bool (** Wrap comments at margin. *)
8889
; wrap_fun_args: bool }
89-
(** Formatting options *)
9090

9191
type file = Stdin | File of string
9292

@@ -102,12 +102,12 @@ type action =
102102
(** Check whether the input files already are formatted. *)
103103
| Print_config of t (** Print the configuration and exit. *)
104104

105+
(** Options changing the tool's behavior *)
105106
type opts =
106107
{ debug: bool (** Generate debugging output if true. *)
107108
; margin_check: bool
108109
(** Check whether the formatted output exceeds the margin. *)
109110
; format_invalid_files: bool }
110-
(** Options changing the tool's behavior *)
111111

112112
val action : unit -> (action * opts) Cmdliner.Term.result
113113
(** Formatting action: input type and source, and output destination. *)

lib/Config_option.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ module Make (C : CONFIG) : sig
4242

4343
val deprecated : since_version:string -> string -> deprecated
4444

45-
type removed_value
4645
(** Indicate that a configuration value has been removed in an ocamlformat
4746
release. A message indicating how to migrate will be displayed. *)
47+
type removed_value
4848

4949
val removed_value :
5050
name:string -> version:string -> msg:string -> removed_value

lib/Fmt.mli

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313

1414
module Format = Format_
1515

16-
type s = (unit, Format.formatter, unit) format
1716
(** Format strings that accept no arguments. *)
17+
type s = (unit, Format.formatter, unit) format
1818

19-
type t
2019
(** Format thunks. *)
20+
type t
2121

2222
val ( $ ) : t -> t -> t
2323
(** Format concatenation: [a $ b] formats [a], then [b]. *)

lib/Source.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
**********************************************************************)
1111
open Migrate_ast
1212

13-
type t = string
1413
(** Concrete syntax. *)
14+
type t = string
1515

1616
let create s = s
1717

lib/Translation_unit.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
open Migrate_ast
1515
open Parse_with_comments
1616

17+
(** Operations on translation units. *)
1718
type 'a t =
1819
{ init_cmts: debug:bool -> Source.t -> 'a -> Cmt.t list -> Cmts.t
1920
; fmt: debug:bool -> Source.t -> Cmts.t -> Conf.t -> 'a -> Fmt.t
@@ -32,7 +33,6 @@ type 'a t =
3233
-> Normalize.docstring_error list
3334
; normalize: Conf.t -> 'a with_comments -> 'a
3435
; printast: Format.formatter -> 'a -> unit }
35-
(** Operations on translation units. *)
3636

3737
exception
3838
Internal_error of

lib/Translation_unit.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
open Parse_with_comments
1313

14+
(** Operations on translation units. *)
1415
type 'a t =
1516
{ init_cmts: debug:bool -> Source.t -> 'a -> Cmt.t list -> Cmts.t
1617
; fmt: debug:bool -> Source.t -> Cmts.t -> Conf.t -> 'a -> Fmt.t
@@ -29,7 +30,6 @@ type 'a t =
2930
-> Normalize.docstring_error list
3031
; normalize: Conf.t -> 'a with_comments -> 'a
3132
; printast: Caml.Format.formatter -> 'a -> unit }
32-
(** Operations on translation units. *)
3333

3434
type error
3535

test/cli/stdin_and_intf.expected

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
val x : string
22

3-
module X : S
43
(** Make sure this file cannot be parsed as an impl file *)
4+
module X : S

test/passing/break_separators-after.ml.ref

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,9 @@ type trace_mod_funs =
9797
{trace_mod: bool option; trace_funs: bool Map.M(String).t}
9898

9999
module Fooooo = struct
100-
type t = {fooooo: fooo; fooooo: fooooooo}
101100
(** This is a long docstring so that it cannot be on the same line as the
102101
record type. *)
102+
type t = {fooooo: fooo; fooooo: fooooooo}
103103

104104
val select :
105105
(* The fsevents context *)

test/passing/break_separators-after_docked.ml.ref

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,9 @@ type trace_mod_funs = {
110110
}
111111

112112
module Fooooo = struct
113-
type t = {fooooo: fooo; fooooo: fooooooo}
114113
(** This is a long docstring so that it cannot be on the same line as the
115114
record type. *)
115+
type t = {fooooo: fooo; fooooo: fooooooo}
116116

117117
val select :
118118
(* The fsevents context *)

test/passing/break_separators-after_docked_wrap.ml.ref

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,9 @@ type trace_mod_funs = {
108108
}
109109

110110
module Fooooo = struct
111-
type t = {fooooo: fooo; fooooo: fooooooo}
112111
(** This is a long docstring so that it cannot be on the same line as the
113112
record type. *)
113+
type t = {fooooo: fooo; fooooo: fooooooo}
114114

115115
val select :
116116
(* The fsevents context *)

test/passing/break_separators-after_wrap.ml.ref

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,9 @@ type trace_mod_funs =
9595
{trace_mod: bool option; trace_funs: bool Map.M(String).t}
9696

9797
module Fooooo = struct
98-
type t = {fooooo: fooo; fooooo: fooooooo}
9998
(** This is a long docstring so that it cannot be on the same line as the
10099
record type. *)
100+
type t = {fooooo: fooo; fooooo: fooooooo}
101101

102102
val select :
103103
(* The fsevents context *)

test/passing/break_separators-before_docked.ml.ref

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,9 @@ type trace_mod_funs = {
110110
}
111111

112112
module Fooooo = struct
113-
type t = {fooooo: fooo; fooooo: fooooooo}
114113
(** This is a long docstring so that it cannot be on the same line as the
115114
record type. *)
115+
type t = {fooooo: fooo; fooooo: fooooooo}
116116

117117
val select :
118118
(* The fsevents context *)

test/passing/break_separators-before_docked_wrap.ml.ref

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,9 @@ type trace_mod_funs = {
108108
}
109109

110110
module Fooooo = struct
111-
type t = {fooooo: fooo; fooooo: fooooooo}
112111
(** This is a long docstring so that it cannot be on the same line as the
113112
record type. *)
113+
type t = {fooooo: fooo; fooooo: fooooooo}
114114

115115
val select :
116116
(* The fsevents context *)

test/passing/break_separators-wrap.ml.ref

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,9 @@ type trace_mod_funs =
9595
{trace_mod: bool option; trace_funs: bool Map.M(String).t}
9696

9797
module Fooooo = struct
98-
type t = {fooooo: fooo; fooooo: fooooooo}
9998
(** This is a long docstring so that it cannot be on the same line as the
10099
record type. *)
100+
type t = {fooooo: fooo; fooooo: fooooooo}
101101

102102
val select :
103103
(* The fsevents context *)

test/passing/break_separators.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,9 @@ type trace_mod_funs =
9797
{trace_mod: bool option; trace_funs: bool Map.M(String).t}
9898

9999
module Fooooo = struct
100-
type t = {fooooo: fooo; fooooo: fooooooo}
101100
(** This is a long docstring so that it cannot be on the same line as the
102101
record type. *)
102+
type t = {fooooo: fooo; fooooo: fooooooo}
103103

104104
val select :
105105
(* The fsevents context *)

test/passing/comment_in_modules.ml.ref

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ module type M = sig
1212
(* comments *)
1313
end
1414

15+
(** Xxxxxxx xxxxxxxx xx xxxxxxx xxxxxxxxxxxxx xxxxxxxxx xx xxxx *)
1516
module Mmmmmmmmmmmmmmmmmmmmmm =
1617
Aaaaaaaaaaaaaaaaaaaaaa.Bbbbbbbbbbbbbbbbbbbbbbbb
17-
(** Xxxxxxx xxxxxxxx xx xxxxxxx xxxxxxxxxxxxx xxxxxxxxx xx xxxx *)
1818

1919
(** Xxxxxxx xxxxxxxx xx xxxxxxx xxxxxxxxxxxxx xxxxxxxxx xx xxxx *)
2020
module Fffffffffffffff (Yyyyyyyyyyyyyyy : Z.S) =

0 commit comments

Comments
 (0)