Skip to content

Commit

Permalink
Preview: Upgrade to ocamlformat 0.26.0 (unreleased)
Browse files Browse the repository at this point in the history
The aim of this commit is to gather feedback.

Changelog can be found here: https://github.com/ocaml-ppx/ocamlformat/blob/main/CHANGES.md
  • Loading branch information
Julow committed Jun 27, 2023
1 parent 50c676e commit f42fd06
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 75 deletions.
2 changes: 1 addition & 1 deletion .ocamlformat
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
module-item-spacing=preserve
version=0.25.1
version = 0.26.0
66 changes: 31 additions & 35 deletions doc/examples/markup.mli
Original file line number Diff line number Diff line change
Expand Up @@ -52,46 +52,43 @@ module type Foo = sig
val bar : string
(** This comment is associated to bar. *)

class cl :
object

(** Interesting information about cl *)
end
class cl : object

(** Interesting information about cl *)
end

(** The comment for class my_class *)
class my_class :
object
inherit cl
(** A comment to describe inheritance from cl *)
class my_class : object
inherit cl
(** A comment to describe inheritance from cl *)

val mutable tutu : string
(** The comment for attribute tutu *)
val mutable tutu : string
(** The comment for attribute tutu *)

val toto : int
(** The comment for attribute toto. *)
val toto : int
(** The comment for attribute toto. *)

(** This comment is not attached to titi since
(** This comment is not attached to titi since
there is a blank line before titi, but is kept
as a comment in the class. *)

val titi : string
val titi : string

method toto : string
(** Comment for method toto *)
method toto : string
(** Comment for method toto *)

method m : float -> int
(** Comment for method m *)
end
method m : float -> int
(** Comment for method m *)
end

(** The comment for the class type my_class_type *)
class type my_class_type =
object
val mutable x : int
(** The comment for variable x. *)
class type my_class_type = object
val mutable x : int
(** The comment for variable x. *)

method m : int -> int
(** The comment for method m. *)
end
method m : int -> int
(** The comment for method m. *)
end

(** The comment for module Foo *)
module Foo : sig
Expand Down Expand Up @@ -119,16 +116,15 @@ end
module Stop : sig
(** This module demonstrates the use of stop comments ([(**/**)]) *)

class type foo =
object
method m : string
(** comment for method m *)
class type foo = object
method m : string
(** comment for method m *)

(**/**)
(**/**)

method bar : int
(** This method won't appear in the documentation *)
end
method bar : int
(** This method won't appear in the documentation *)
end

val foo : string
(** This value appears in the documentation, since the Stop special comment
Expand Down
2 changes: 1 addition & 1 deletion src/document/url.ml
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ module Anchor = struct
| None -> assert false (* We got a root, should never happen *)
| Some page ->
let anchor = Printf.sprintf "%s-%s" (Path.string_of_kind kind) name in
{ page; anchor; kind = (kind :> kind) }
{ page; anchor; kind :> kind }

let add_suffix ~kind { page; anchor; _ } suffix =
{ page; anchor = anchor ^ "." ^ suffix; kind }
Expand Down
38 changes: 16 additions & 22 deletions src/ocamlary/ocamlary.mli
Original file line number Diff line number Diff line change
Expand Up @@ -575,23 +575,19 @@ type my_mod = (module COLLECTION)

class empty_class : object end

class one_method_class :
object
method go : unit
end
class one_method_class : object
method go : unit
end

class two_method_class :
object
method one : one_method_class
class two_method_class : object
method one : one_method_class

method undo : unit
end
method undo : unit
end

class ['a] param_class :
'a
-> object
method v : 'a
end
class ['a] param_class : 'a -> object
method v : 'a
end

type my_unit_object = unit param_class

Expand All @@ -605,10 +601,9 @@ type 'a my_unit_class = unit #param_class as 'a
(* Test resolution of dependently typed modules *)
module Dep1 : sig
module type S = sig
class c :
object
method m : int
end
class c : object
method m : int
end
end

module X : sig
Expand Down Expand Up @@ -722,10 +717,9 @@ module type Dep10 = Dep9(Dep8).T with type t = int

module Dep11 : sig
module type S = sig
class c :
object
method m : int
end
class c : object
method m : int
end
end
end

Expand Down
2 changes: 1 addition & 1 deletion src/odoc/source_tree.ml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ let compile ~resolver ~parent ~output ~warnings_options:_ input =
parse_input_file input >>= fun (digest, source_tree) ->
let root =
let file = Root.Odoc_file.create_page root_name in
{ Root.id = (id :> Id.OdocId.t); file; digest }
{ Root.id :> Id.OdocId.t; file; digest }
in
let source_children = List.rev_map (source_child_id id) source_tree in
let page =
Expand Down
26 changes: 12 additions & 14 deletions src/xref2/env.ml
Original file line number Diff line number Diff line change
Expand Up @@ -527,15 +527,14 @@ let s_module : Component.Element.module_ scope =

let s_any : Component.Element.any scope =
make_scope ~root:lookup_page_or_root_module_fallback
~check:
(fun env -> function
| `Label (id, _) -> (
try
Some
(Identifier.Maps.Label.find id env.ambiguous_labels
:> Component.Element.any amb_err)
with Not_found -> None)
| _ -> None)
~check:(fun env -> function
| `Label (id, _) -> (
try
Some
(Identifier.Maps.Label.find id env.ambiguous_labels
:> Component.Element.any amb_err)
with Not_found -> None)
| _ -> None)
(fun r -> Some r)

let s_module_type : Component.Element.module_type scope =
Expand All @@ -562,11 +561,10 @@ let s_value : Component.Element.value scope =

let s_label : Component.Element.label scope =
make_scope
~check:
(fun env -> function
| `Label (id, _) -> (
try Some (Identifier.Maps.Label.find id env.ambiguous_labels)
with Not_found -> None))
~check:(fun env -> function
| `Label (id, _) -> (
try Some (Identifier.Maps.Label.find id env.ambiguous_labels)
with Not_found -> None))
(function #Component.Element.label as r -> Some r | _ -> None)

let s_constructor : Component.Element.constructor scope =
Expand Down
2 changes: 1 addition & 1 deletion src/xref2/ref_tools.ml
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ module L = struct
| `Heading
( _,
({ Odoc_model.Paths.Identifier.iv = `Label (_, name'); _ } as
label),
label),
_ )
when name = LabelName.to_string name' ->
Ok (`Identifier label)
Expand Down

0 comments on commit f42fd06

Please sign in to comment.