@@ -124,6 +124,13 @@ let read_type_extension env parent tyext =
124
124
in
125
125
{ parent; type_path; doc; type_params; private_; constructors; }
126
126
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
+
127
134
let rec read_class_type_field env parent ctf =
128
135
let open ClassSignature in
129
136
let open Odoc_model.Names in
@@ -144,10 +151,10 @@ let rec read_class_type_field env parent ctf =
144
151
let virtual_ = (virtual_ = Virtual ) in
145
152
let type_ = read_core_type env typ in
146
153
Some (Method {id; doc; private_; virtual_; type_})
147
- | Tctf_constraint (_ , _ ) -> None
154
+ | Tctf_constraint (_ , _ ) -> mk_class_comment doc
148
155
| Tctf_inherit cltyp ->
149
156
let expr = read_class_signature env parent [] cltyp in
150
- Some (Inherit { Inherit. expr; doc })
157
+ Some (Inherit {Inherit. expr; doc})
151
158
| Tctf_attribute attr ->
152
159
match Doc_attr. standalone container attr with
153
160
| None -> None
@@ -235,11 +242,11 @@ let rec read_class_field env parent cf =
235
242
false , Cmi. read_type_expr env expr.exp_type
236
243
in
237
244
Some (Method {id; doc; private_; virtual_; type_})
238
- | Tcf_constraint (_ , _ ) -> None
245
+ | Tcf_constraint (_ , _ ) -> mk_class_comment doc
239
246
| Tcf_inherit (_ , cl , _ , _ , _ ) ->
240
247
let expr = read_class_structure env parent [] cl in
241
248
Some (Inherit {Inherit. expr; doc})
242
- | Tcf_initializer _ -> None
249
+ | Tcf_initializer _ -> mk_class_comment doc
243
250
| Tcf_attribute attr ->
244
251
match Doc_attr. standalone container attr with
245
252
| None -> None
0 commit comments