Skip to content

Commit d88e57a

Browse files
Julowjonludlam
authored andcommitted
Collect comment attached on constraints in cmt files
Constraints are handled separately and are not associated with their comment. As a quick workaround, turn these into standalone comments.
1 parent d1924fb commit d88e57a

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/loader/cmt.ml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,13 @@ let read_type_extension env parent tyext =
124124
in
125125
{ parent; type_path; doc; type_params; private_; constructors; }
126126

127+
(** Make a standalone comment out of a comment attached to an item that isn't
128+
rendered. For example, [constraint] items are read separately and not
129+
associated with their comment. *)
130+
let mk_class_comment = function
131+
| [] -> None
132+
| doc -> Some (ClassSignature.Comment (`Docs doc))
133+
127134
let rec read_class_type_field env parent ctf =
128135
let open ClassSignature in
129136
let open Odoc_model.Names in
@@ -144,10 +151,10 @@ let rec read_class_type_field env parent ctf =
144151
let virtual_ = (virtual_ = Virtual) in
145152
let type_ = read_core_type env typ in
146153
Some (Method {id; doc; private_; virtual_; type_})
147-
| Tctf_constraint(_, _) -> None
154+
| Tctf_constraint(_, _) -> mk_class_comment doc
148155
| Tctf_inherit cltyp ->
149156
let expr = read_class_signature env parent [] cltyp in
150-
Some (Inherit { Inherit.expr; doc })
157+
Some (Inherit {Inherit.expr; doc})
151158
| Tctf_attribute attr ->
152159
match Doc_attr.standalone container attr with
153160
| None -> None
@@ -235,11 +242,11 @@ let rec read_class_field env parent cf =
235242
false, Cmi.read_type_expr env expr.exp_type
236243
in
237244
Some (Method {id; doc; private_; virtual_; type_})
238-
| Tcf_constraint(_, _) -> None
245+
| Tcf_constraint(_, _) -> mk_class_comment doc
239246
| Tcf_inherit(_, cl, _, _, _) ->
240247
let expr = read_class_structure env parent [] cl in
241248
Some (Inherit {Inherit.expr; doc})
242-
| Tcf_initializer _ -> None
249+
| Tcf_initializer _ -> mk_class_comment doc
243250
| Tcf_attribute attr ->
244251
match Doc_attr.standalone container attr with
245252
| None -> None

0 commit comments

Comments
 (0)