@@ -47,6 +47,7 @@ let typeReactRef ~type_ =
47
47
nameJS = reactRefCurrent;
48
48
optional = Mandatory ;
49
49
type_ = Null type_;
50
+ docString = None ;
50
51
};
51
52
] )
52
53
@@ -162,12 +163,13 @@ let rec renderType ~(config : Config.t) ?(indent = None) ~typeNameIsInterface
162
163
type_ |> renderType ~config ~indent ~type NameIsInterface ~in FunType)
163
164
in
164
165
let noPayloadsRendered = noPayloads |> List. map labelJSToString in
165
- let field ~name value =
166
+ let field ~name ? docString value =
166
167
{
167
168
mutable_ = Mutable ;
168
169
nameJS = name;
169
170
optional = Mandatory ;
170
171
type_ = TypeVar value;
172
+ docString;
171
173
}
172
174
in
173
175
let fields fields =
@@ -232,7 +234,7 @@ let rec renderType ~(config : Config.t) ?(indent = None) ~typeNameIsInterface
232
234
^ " | " ))
233
235
234
236
and renderField ~config ~indent ~typeNameIsInterface ~inFunType
235
- {mutable_; nameJS = lbl ; optional; type_} =
237
+ {mutable_; nameJS = lbl ; optional; type_; docString } =
236
238
let optMarker =
237
239
match optional == Optional with
238
240
| true -> " ?"
@@ -249,8 +251,16 @@ and renderField ~config ~indent ~typeNameIsInterface ~inFunType
249
251
| false -> EmitText. quotes lbl
250
252
in
251
253
252
- Indent. break ~indent ^ mutMarker ^ lbl ^ optMarker ^ " : "
253
- ^ (type_ |> renderType ~config ~indent ~type NameIsInterface ~in FunType)
254
+ let defStr =
255
+ mutMarker ^ lbl ^ optMarker ^ " : "
256
+ ^ (type_ |> renderType ~config ~indent ~type NameIsInterface ~in FunType)
257
+ in
258
+ match docString with
259
+ | None -> Indent. break ~indent ^ defStr
260
+ | Some docString ->
261
+ (* Always print comments on newline before definition. *)
262
+ let indentStr = indent |> Option. value ~default: " " in
263
+ " \n " ^ indentStr ^ " /**" ^ docString ^ " */\n " ^ indentStr ^ defStr
254
264
255
265
and renderFields ~config ~indent ~inFunType ~typeNameIsInterface fields =
256
266
let indent1 = indent |> Indent. more in
0 commit comments