@@ -44,7 +44,14 @@ type docItem =
4444 (* * Additional documentation for constructors and record fields, if available. *)
4545 }
4646 | 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+ }
4855 | ModuleAlias of {
4956 id : string ;
5057 docstring : string list ;
@@ -57,6 +64,7 @@ and docsForModule = {
5764 docstring : string list ;
5865 deprecated : string option ;
5966 name : string ;
67+ moduletypeid : string option ;
6068 source : source ;
6169 items : docItem list ;
6270}
@@ -195,6 +203,10 @@ let rec stringifyDocItem ?(indentation = 0) ~originalEnv (item : docItem) =
195203 match m.deprecated with
196204 | Some d -> Some (wrapInQuotes d)
197205 | None -> None );
206+ ( " moduletypeid" ,
207+ match m.moduletypeid with
208+ | Some path -> Some (wrapInQuotes path)
209+ | None -> None );
198210 (" docstrings" , Some (stringifyDocstrings m.docstring));
199211 ( " source" ,
200212 Some (stringifySource ~indentation: (indentation + 1 ) m.source) );
@@ -356,6 +368,7 @@ let extractDocs ~entryPointFile ~debug =
356368 id = modulePath |> List. rev |> ident;
357369 docstring = structure.docstring |> List. map String. trim;
358370 name = structure.name;
371+ moduletypeid = None ;
359372 deprecated = structure.deprecated;
360373 source =
361374 {
@@ -439,6 +452,7 @@ let extractDocs ~entryPointFile ~debug =
439452 {
440453 id = modulePath |> List. rev |> ident;
441454 name = m.name;
455+ moduletypeid = None ;
442456 docstring = item.docstring @ m.docstring;
443457 deprecated = item.deprecated;
444458 source;
@@ -469,12 +483,33 @@ let extractDocs ~entryPointFile ~debug =
469483 (extractDocsForModule
470484 ~module Path:(interface.name :: modulePath)
471485 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+
474504 Some
475505 (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+ })
478513 | _ -> None );
479514 }
480515 in
0 commit comments