@@ -44,6 +44,7 @@ type docItem =
44
44
(* * Additional documentation for constructors and record fields, if available. *)
45
45
}
46
46
| Module of docsForModule
47
+ | ModuleType of docsForModule
47
48
| ModuleAlias of {
48
49
id : string ;
49
50
docstring : string list ;
@@ -204,6 +205,26 @@ let rec stringifyDocItem ?(indentation = 0) ~originalEnv (item : docItem) =
204
205
(stringifyDocItem ~original Env ~indentation: (indentation + 1 ))
205
206
|> array ) );
206
207
]
208
+ | ModuleType m ->
209
+ stringifyObject ~start OnNewline:true ~indentation
210
+ [
211
+ (" id" , Some (wrapInQuotes m.id));
212
+ (" name" , Some (wrapInQuotes m.name));
213
+ (" kind" , Some (wrapInQuotes " moduleType" ));
214
+ ( " deprecated" ,
215
+ match m.deprecated with
216
+ | Some d -> Some (wrapInQuotes d)
217
+ | None -> None );
218
+ (" docstrings" , Some (stringifyDocstrings m.docstring));
219
+ ( " source" ,
220
+ Some (stringifySource ~indentation: (indentation + 1 ) m.source) );
221
+ ( " items" ,
222
+ Some
223
+ (m.items
224
+ |> List. map
225
+ (stringifyDocItem ~original Env ~indentation: (indentation + 1 ))
226
+ |> array ) );
227
+ ]
207
228
| ModuleAlias m ->
208
229
stringifyObject ~start OnNewline:true ~indentation
209
230
[
@@ -379,7 +400,7 @@ let extractDocs ~entryPointFile ~debug =
379
400
detail = typeDetail typ ~full ~env ;
380
401
source;
381
402
})
382
- | Module ( Ident p ) ->
403
+ | Module { type_ = Ident p ; isModuleType = false } ->
383
404
(* module Whatever = OtherModule *)
384
405
let aliasToModule = p |> pathIdentToString in
385
406
let id =
@@ -409,7 +430,7 @@ let extractDocs ~entryPointFile ~debug =
409
430
item.docstring @ internalDocstrings
410
431
|> List. map String. trim;
411
432
})
412
- | Module ( Structure m ) ->
433
+ | Module { type_ = Structure m ; isModuleType = false } ->
413
434
(* module Whatever = {} in res or module Whatever: {} in resi. *)
414
435
let modulePath = m.name :: modulePath in
415
436
let docs = extractDocsForModule ~module Path m in
@@ -423,8 +444,25 @@ let extractDocs ~entryPointFile ~debug =
423
444
source;
424
445
items = docs.items;
425
446
})
447
+ | Module {type_ = Structure m ; isModuleType = true } ->
448
+ (* module type Whatever = {} *)
449
+ let modulePath = m.name :: modulePath in
450
+ let docs = extractDocsForModule ~module Path m in
451
+ Some
452
+ (ModuleType
453
+ {
454
+ id = modulePath |> List. rev |> ident;
455
+ name = m.name;
456
+ docstring = item.docstring @ m.docstring;
457
+ deprecated = item.deprecated;
458
+ source;
459
+ items = docs.items;
460
+ })
426
461
| Module
427
- (Constraint (Structure _impl, Structure interface)) ->
462
+ {
463
+ type_ =
464
+ Constraint (Structure _impl, Structure interface);
465
+ } ->
428
466
(* module Whatever: { <interface> } = { <impl> }. Prefer the interface. *)
429
467
Some
430
468
(Module
0 commit comments