@@ -44,7 +44,14 @@ 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
+ | ModuleType of {
48
+ id : string ;
49
+ docstring : string list ;
50
+ deprecated : string option ;
51
+ name : string ;
52
+ source : source ;
53
+ items : docItem list ;
54
+ }
48
55
| ModuleAlias of {
49
56
id : string ;
50
57
docstring : string list ;
@@ -57,6 +64,7 @@ and docsForModule = {
57
64
docstring : string list ;
58
65
deprecated : string option ;
59
66
name : string ;
67
+ moduletypeid : string option ;
60
68
source : source ;
61
69
items : docItem list ;
62
70
}
@@ -195,6 +203,10 @@ let rec stringifyDocItem ?(indentation = 0) ~originalEnv (item : docItem) =
195
203
match m.deprecated with
196
204
| Some d -> Some (wrapInQuotes d)
197
205
| None -> None );
206
+ ( " moduletypeid" ,
207
+ match m.moduletypeid with
208
+ | Some path -> Some (wrapInQuotes path)
209
+ | None -> None );
198
210
(" docstrings" , Some (stringifyDocstrings m.docstring));
199
211
( " source" ,
200
212
Some (stringifySource ~indentation: (indentation + 1 ) m.source) );
@@ -356,6 +368,7 @@ let extractDocs ~entryPointFile ~debug =
356
368
id = modulePath |> List. rev |> ident;
357
369
docstring = structure.docstring |> List. map String. trim;
358
370
name = structure.name;
371
+ moduletypeid = None ;
359
372
deprecated = structure.deprecated;
360
373
source =
361
374
{
@@ -439,6 +452,7 @@ let extractDocs ~entryPointFile ~debug =
439
452
{
440
453
id = modulePath |> List. rev |> ident;
441
454
name = m.name;
455
+ moduletypeid = None ;
442
456
docstring = item.docstring @ m.docstring;
443
457
deprecated = item.deprecated;
444
458
source;
@@ -469,12 +483,33 @@ let extractDocs ~entryPointFile ~debug =
469
483
(extractDocsForModule
470
484
~module Path:(interface.name :: modulePath)
471
485
interface))
472
- | Module {type_ = Constraint (Structure m , Ident _ )} ->
473
- (* module M: T = { }. Print M *)
486
+ | Module {type_ = Constraint (Structure m , Ident p )} ->
487
+ (* module M: T = { <impl> }. Print M *)
488
+ let docs =
489
+ extractDocsForModule ~module Path:(m.name :: modulePath)
490
+ m
491
+ in
492
+ let identModulePath = p |> Path. head |> Ident. name in
493
+
494
+ let moduleTypeIdPath =
495
+ match
496
+ ProcessCmt. fileForModule ~package: full.package
497
+ identModulePath
498
+ |> Option. is_none
499
+ with
500
+ | false -> []
501
+ | true -> [modulePath |> List. rev |> List. hd]
502
+ in
503
+
474
504
Some
475
505
(Module
476
- (extractDocsForModule
477
- ~module Path:(m.name :: modulePath) m))
506
+ {
507
+ docs with
508
+ moduletypeid =
509
+ Some
510
+ (makeId ~identifier: (Path. name p)
511
+ moduleTypeIdPath);
512
+ })
478
513
| _ -> None );
479
514
}
480
515
in
0 commit comments