1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
# 1 "test/xref2/lib/common.cppo.ml"
open Result
open Odoc_model.Names
let _ = Toploop.set_paths ()
let cmti_of_string s =
Odoc_xref2.Tools.reset_caches ();
let env = Compmisc.initial_env () in
let l = Lexing.from_string s in
let p = Parse.interface l in
Typemod.type_interface
# 30 "test/xref2/lib/common.cppo.ml"
env p;;
let cmt_of_string s =
let env = Compmisc.initial_env () in
let l = Lexing.from_string s in
let p = Parse.implementation l in
# 37 "test/xref2/lib/common.cppo.ml"
Typemod.type_implementation "" "" "" env p
# 44 "test/xref2/lib/common.cppo.ml"
let parent = Odoc_model.Paths.Identifier.Mk.page (None, PageName.make_std "None")
let id = Odoc_model.Paths.Identifier.Mk.root (Some parent, ModuleName.make_std "Root")
let root_of_compilation_unit ~package ~hidden ~module_name ~digest =
ignore(package);
let file_representation : Odoc_model.Root.Odoc_file.t =
Odoc_model.Root.Odoc_file.create_unit ~force_hidden:hidden module_name in
Ok {Odoc_model.Root.id; file = file_representation; digest}
let root =
let root_result =
root_of_compilation_unit
~package:"nopackage"
~hidden:false
~module_name:"Root"
~digest:"nodigest"
in
match root_result with
| Ok r -> r
| _ -> failwith "Bad result"
let root_identifier = `Identifier id
let root_module name = Odoc_model.Paths.Identifier.Mk.module_ (id, ModuleName.make_std name)
let root_pp fmt (_ : Odoc_model.Root.t) = Format.fprintf fmt "Common.root"
let model_of_string str =
let cmti = cmti_of_string str in
Odoc_loader__Cmti.read_interface (Some parent) "Root" ~warnings_tag:None cmti
let model_of_string_impl str =
# 79 "test/xref2/lib/common.cppo.ml"
let cmt = (cmt_of_string str).structure in
# 81 "test/xref2/lib/common.cppo.ml"
Odoc_loader__Cmt.read_implementation (Some parent) "Root" ~warnings_tag:None cmt
let signature_of_mli_string str =
Odoc_xref2.Ident.reset ();
let _, sg, _ = model_of_string str in
sg
module Ident = Ident
module LangUtils = struct
module Lens = struct
open Odoc_model
type ('a, 'b) lens =
{ get : 'a -> 'b
; set : 'b -> 'a -> 'a }
type ('a, 'b) prism =
{ preview : 'a -> 'b option
; review : 'b -> 'a }
let option : ('a option, 'a) prism =
let preview = function | Some x -> Some x | None -> None in
let review = function x -> Some x in
{preview; review}
let compose : ('a, 'b) lens -> ('b, 'c) lens -> ('a, 'c) lens =
fun x y ->
let get z = y.get (x.get z) in
let set a z = x.set (y.set a (x.get z)) z in
{get; set}
let compose_prism : ('a, 'b) lens -> ('b, 'c) prism -> ('a, 'c) lens =
fun x y ->
let get z = x.get z |> y.preview |> function | Some x -> x | None -> raise Not_found in
let set a z = x.set (y.review a) z in
{get; set}
let fst : ('a * 'b, 'a) lens =
let get (x,_) = x in
let set a (_, y) = (a, y) in
{get; set}
let snd : ('a * 'b, 'b) lens =
let get (_, y) = y in
let set a (x, _) = (x, a) in
{get; set}
let hd : ('a list, 'a) prism =
let preview = function
| x::_ -> Some x
| _ -> None
in
let review x = [x]
in
{ review ; preview }
let nth n : ('a list, 'a) prism =
let preview l = try Some (List.nth l n) with _ -> None in
let review x = [x]
in { review; preview }
let (|--) = compose
let (|-~) = compose_prism
let get lens x = lens.get x
let set lens y x = lens.set y x
let name_of_id = Paths.Identifier.name
module Signature = struct
open Lang.Signature
let module_ : string -> (t, Lang.Module.t) lens = fun name ->
let module M = Lang.Module in
let get sg =
let rec inner = function
| [] -> raise Not_found
| (Module (_r,m'))::_xs when name_of_id m'.M.id = name ->
m'
| _::xs -> inner xs
in inner sg.items
in
let set m sg =
let rec inner = function
| [] -> raise Not_found
| (Module (r, m'))::xs when name_of_id m'.M.id = name ->
(Module (r, m)::xs)
| x::xs -> x :: inner xs
in
{sg with items = inner sg.items}
in
{ get; set }
let module_type : string -> (t, Lang.ModuleType.t) lens = fun name ->
let module MT = Lang.ModuleType in
let get sg =
let rec inner = function
| [] -> raise Not_found
| (ModuleType m')::_xs when name_of_id m'.MT.id = name ->
m'
| _::xs -> inner xs
in inner sg.items
in
let set m sg =
let rec inner = function
| [] -> raise Not_found
| (ModuleType m')::xs when name_of_id m'.MT.id = name ->
(ModuleType m::xs)
| x::xs -> x :: inner xs
in
{sg with items = inner sg.items}
in
{ get; set }
let type_ : string -> (t, Lang.TypeDecl.t) lens = fun name ->
let module T = Lang.TypeDecl in
let get sg =
let rec inner = function
| [] -> raise Not_found
| (Type (_,t'))::_xs when name_of_id t'.T.id = name ->
t'
| _::xs -> inner xs
in inner sg.items
in
let set t sg =
let rec inner = function
| [] -> raise Not_found
| (Type (r,t'))::xs when name_of_id t'.T.id = name ->
(Type (r,t))::xs
| x::xs -> x :: inner xs
in
{sg with items = inner sg.items }
in
{ get; set }
let value : string -> (t, Lang.Value.t) lens = fun name ->
let module V = Lang.Value in
let get sg =
let rec inner = function
| [] -> raise Not_found
| (Value v) ::_xs when name_of_id v.V.id = name ->
v
| _::xs -> inner xs
in inner sg.items
in
let set v sg =
let rec inner = function
| [] -> raise Not_found
| (Value v') :: xs when name_of_id v'.V.id = name ->
(Value v)::xs
| x::xs -> x :: inner xs
in
{sg with items = inner sg.items}
in
{ get; set }
let includes : (t, Lang.Include.t list) lens =
let get l =
List.fold_left (fun acc item ->
match item with
| (Include i) -> i::acc
| _ -> acc) [] l.items |> List.rev
in
let set _ _ =
raise (Invalid_argument "set includes")
in
{get; set }
end
module Module = struct
open Lang.Module
let id : (t, Paths.Identifier.Module.t) lens =
let get m = m.id in
let set id t = {t with id} in
{get; set}
let type_ : (t, decl) lens =
let get m = m.type_ in
let set type_ m = {m with type_} in
{get; set}
let decl_moduletype : (decl, Lang.ModuleType.expr) prism =
let review x = ModuleType x in
let preview = function | ModuleType x -> Some x | _ -> None in
{review; preview}
end
module Include = struct
open Lang.Include
let expansion_sig : (t, Lang.Signature.t) lens =
let get x = x.expansion.content in
let set x i = {i with expansion = {i.expansion with content=x}} in
{get; set}
end
module ModuleType = struct
open Lang.ModuleType
let id : (t, Paths.Identifier.ModuleType.t) lens =
let get mt = mt.id in
let set id mt = {mt with id} in
{get; set}
let expr : (t, expr option) lens =
let get mt = mt.expr in
let set expr mt = {mt with expr} in
{get; set}
let expr_signature : (expr, Lang.Signature.t) prism =
let review x = Signature x in
let preview = function | Signature x -> Some x | _ -> None in
{review; preview}
let expr_functor : (expr, (Lang.FunctorParameter.t * expr)) prism =
let review (x,y) = Functor (x,y) in
let preview = function | Functor (x,y) -> Some (x,y) | _ -> None in
{review; preview}
end
module FunctorParameter = struct
open Lang.FunctorParameter
let id : (parameter, Paths.Identifier.FunctorParameter.t) lens =
let get mt = mt.id in
let set id mt = {mt with id} in
{get; set}
let expr : (parameter, Lang.ModuleType.expr) lens =
let get mt = mt.expr in
let set expr mt = {mt with expr} in
{get; set}
let named : (t, parameter) prism =
let review x = Named x in
let preview = function | Unit -> None | Named p -> Some p in
{review; preview}
end
module TypeDecl = struct
open Lang.TypeDecl
module Equation = struct
open Equation
let params : (t, param list) lens =
let get t = t.params in
let set params t = {t with params} in
{ get; set }
let manifest : (t, Lang.TypeExpr.t option) lens =
let get t = t.manifest in
let set manifest t = {t with manifest} in
{ get; set }
end
let id : (t, Paths.Identifier.Type.t) lens =
let get t = t.id in
let set id t = {t with id} in
{ get; set }
let equation : (t, Lang.TypeDecl.Equation.t) lens =
let get t = t.equation in
let set equation t = {t with equation} in
{ get; set }
let representation : (t, Representation.t option) lens =
let get t = t.representation in
let set representation t = {t with representation} in
{ get; set }
end
module TypeExpr = struct
open Lang.TypeExpr
let constr : (t, (Odoc_model.Paths.Path.Type.t * t list)) prism =
let review (x,y) = Constr (x,y) in
let preview = function | Constr (x,y) -> Some (x,y) | _ -> None in
{review; preview}
end
end
let test =
let open Lens in
Signature.type_ "t" |-- TypeDecl.equation |-- TypeDecl.Equation.manifest
module Lookup = struct
let module_from_sig : Odoc_model.Lang.Signature.t -> string -> Odoc_model.Lang.Module.t =
fun sg mname ->
let rec inner = function
| Odoc_model.Lang.Signature.Module (_, m) :: rest -> begin
let id = m.Odoc_model.Lang.Module.id in
match id.iv with
| `Module (_, mname') ->
if ModuleName.to_string mname' = mname
then m
else inner rest
| _ -> inner rest
end
| _::rest ->
Format.fprintf Format.std_formatter "Found somethine else\n%!";
inner rest
| _ -> raise Not_found
in
inner sg.items
end
let sig_of_module : Odoc_model.Lang.Module.t -> Odoc_model.Lang.Signature.t =
let open Odoc_model.Lang in
fun x ->
match x.type_ with
| Module.ModuleType ModuleType.Signature s -> s
| _ -> raise Not_found
module Fmt : sig
open Odoc_model
type 'a fmt = Format.formatter -> 'a -> unit
open Paths
val identifier : [< Identifier.t_pv] Paths.Identifier.id fmt
open Lang
val signature : Signature.t fmt
val module_decl : Module.decl fmt
val module_ : Module.t fmt
val module_type : ModuleType.t fmt
val u_module_type_expr : ModuleType.U.expr fmt
val functor_parameter : FunctorParameter.t fmt
val type_equation : TypeDecl.Equation.t fmt
val substitution : ModuleType.substitution fmt
val type_expr : TypeExpr.t fmt
val resolved_path : Path.Resolved.t fmt
val path : Path.t fmt
val model_fragment : Fragment.t fmt
val model_resolved_fragment : Fragment.Resolved.t fmt
end = struct
open Odoc_model.Lang
type 'a fmt = Format.formatter -> 'a -> unit
let identifier ppf i =
Format.fprintf ppf "%a"
Odoc_xref2.Component.Fmt.(model_identifier default)
(i :> Odoc_model.Paths.Identifier.t)
let rec signature ppf sg =
let open Signature in
Format.fprintf ppf "@[<v>";
List.iter (function
| Module (_,m) ->
Format.fprintf ppf
"@[<v 2>module %a@]@,"
module_ m
| ModuleType mt ->
Format.fprintf ppf
"@[<v 2>module type %a@]@,"
module_type mt
| Type (_,t) ->
Format.fprintf ppf
"@[<v 2>type %a@]@," type_decl t
| _ ->
Format.fprintf ppf
"@[<v 2>unhandled signature@]@,") sg.items;
Format.fprintf ppf "@]"
and module_decl ppf d =
let open Module in
match d with
| Alias (p, _) ->
Format.fprintf ppf "= %a" path (p :> Odoc_model.Paths.Path.t)
| ModuleType mt ->
Format.fprintf ppf ": %a" module_type_expr mt
and module_ ppf m =
Format.fprintf ppf "%a %a" identifier m.id module_decl m.type_
and module_type ppf mt =
match mt.expr with
| Some x -> Format.fprintf ppf "%a = %a" identifier mt.id module_type_expr x
| None -> Format.fprintf ppf "%a" identifier mt.id
and u_module_type_expr ppf mt =
let open ModuleType.U in
match mt with
| Path p -> path ppf (p :> Odoc_model.Paths.Path.t)
| Signature sg -> Format.fprintf ppf "sig@,@[<v 2>%a@]end" signature sg
| With (subs, expr) -> Format.fprintf ppf "%a with [%a]" u_module_type_expr expr substitution_list subs
| _ -> Format.fprintf ppf "unhandled module_type_expr"
and module_type_expr ppf mt =
let open ModuleType in
match mt with
| Path {p_path; _} -> path ppf (p_path :> Odoc_model.Paths.Path.t)
| Signature sg -> Format.fprintf ppf "sig@,@[<v 2>%a@]end" signature sg
| With {w_substitutions; w_expr; _} -> Format.fprintf ppf "%a with [%a]" u_module_type_expr w_expr substitution_list w_substitutions
| Functor (arg, res) -> Format.fprintf ppf "(%a) -> %a" functor_parameter arg module_type_expr res
| _ -> Format.fprintf ppf "unhandled module_type_expr"
and functor_parameter ppf x =
match x with
| Unit -> ()
| Named x -> Format.fprintf ppf "%a" functor_parameter_parameter x
and functor_parameter_parameter ppf x =
Format.fprintf ppf "%a : %a" identifier x.FunctorParameter.id module_type_expr x.FunctorParameter.expr
and type_equation ppf t =
match t.TypeDecl.Equation.manifest with
| Some m -> Format.fprintf ppf " = %a" type_expr m
| None -> ()
and type_decl ppf t =
let open TypeDecl in
Format.fprintf ppf "%a%a" identifier t.id type_equation t.equation
and substitution ppf t =
let open ModuleType in
match t with
| ModuleEq (frag, decl) ->
Format.fprintf ppf "%a = %a" model_fragment (frag :> Odoc_model.Paths.Fragment.t) module_decl decl
| ModuleSubst (frag, mpath) ->
Format.fprintf ppf "%a := %a" model_fragment (frag :> Odoc_model.Paths.Fragment.t) path (mpath :> Odoc_model.Paths.Path.t)
| TypeEq (frag, decl) ->
Format.fprintf ppf "%a%a" model_fragment (frag :> Odoc_model.Paths.Fragment.t) type_equation decl
| TypeSubst (frag, decl) ->
Format.fprintf ppf "%a:%a" model_fragment (frag :> Odoc_model.Paths.Fragment.t) type_equation decl
| ModuleTypeEq (frag, decl) ->
Format.fprintf ppf "%a%a" model_fragment (frag :> Odoc_model.Paths.Fragment.t) module_type_expr decl
| ModuleTypeSubst (frag, decl) ->
Format.fprintf ppf "%a:%a" model_fragment (frag :> Odoc_model.Paths.Fragment.t) module_type_expr decl
and substitution_list ppf l =
match l with
| sub :: (_ :: _) as subs -> Format.fprintf ppf "%a; %a" substitution sub substitution_list subs
| sub :: [] -> Format.fprintf ppf "%a" substitution sub
| [] -> ()
and type_expr ppf e =
let open TypeExpr in
match e with
| Var x -> Format.fprintf ppf "%s" x
| Constr (p,_args) -> path ppf (p :> Odoc_model.Paths.Path.t)
| _ -> Format.fprintf ppf "unhandled type_expr"
and resolved_path : Format.formatter -> Odoc_model.Paths.Path.Resolved.t -> unit = fun ppf p ->
let cast p = (p :> Odoc_model.Paths.Path.Resolved.t) in
match p with
| `Apply (p1, p2) -> Format.fprintf ppf "%a(%a)" resolved_path (cast p1) resolved_path (cast p2)
| `Identifier p -> Format.fprintf ppf "global(%a)" identifier p
| `Alias (dest, src) -> Format.fprintf ppf "(%a -> %a)" path (src :> Odoc_model.Paths.Path.t) resolved_path (cast dest)
| `AliasModuleType (path, realpath) -> Format.fprintf ppf "(%a -> %a)" resolved_path (cast path) resolved_path (cast realpath)
| `Subst (modty, m) -> Format.fprintf ppf "(%a subst-> %a)" resolved_path (cast modty) resolved_path (cast m)
| `Module (p, m) -> Format.fprintf ppf "%a.%s" resolved_path (cast p) (ModuleName.to_string m)
| `ModuleType (p, mt) -> Format.fprintf ppf "%a.%s" resolved_path (cast p) (ModuleTypeName.to_string mt)
| `Type (p, t) -> Format.fprintf ppf "%a.%s" resolved_path (cast p) (TypeName.to_string t)
| `Value (p, t) -> Format.fprintf ppf "%a.%s" resolved_path (cast p) (ValueName.to_string t)
| `OpaqueModule m -> Format.fprintf ppf "opaquemodule(%a)" resolved_path (cast m)
| `OpaqueModuleType m -> Format.fprintf ppf "opaquemoduletype(%a)" resolved_path (cast m)
| `SubstT (_, _)
| `CanonicalModuleType (_, _)
| `CanonicalType (_, _)
| `Class (_, _)
| `ClassType (_, _)
| `Hidden _
| `SubstitutedT _
| `SubstitutedMT _
| `CoreType _
| `Substituted _
| `SubstitutedCT _
| `Canonical _ -> Format.fprintf ppf "unimplemented resolved_path"
and path : Format.formatter -> Odoc_model.Paths.Path.t -> unit =
fun ppf (p : Odoc_model.Paths.Path.t) ->
match p with
| `Resolved rp -> Format.fprintf ppf "resolved[%a]" resolved_path (rp :> Odoc_model.Paths.Path.Resolved.t)
| `Identifier (i,b) -> Format.fprintf ppf "identifier(%a,%b)" identifier i b
| `Root s -> Format.fprintf ppf "%a" ModuleName.fmt s
| `Forward s -> Format.fprintf ppf "%s" s
| `Dot (parent,s) -> Format.fprintf ppf "%a.%a" path (parent :> Odoc_model.Paths.Path.t) ModuleName.fmt s
| `DotMT (parent,s) -> Format.fprintf ppf "%a.%a" path (parent :> Odoc_model.Paths.Path.t) ModuleTypeName.fmt s
| `DotT (parent,s) -> Format.fprintf ppf "%a.%a" path (parent :> Odoc_model.Paths.Path.t) TypeName.fmt s
| `DotV (parent,s) -> Format.fprintf ppf "%a.%a" path (parent :> Odoc_model.Paths.Path.t) ValueName.fmt s
| `Apply (func,arg) -> Format.fprintf ppf "%a(%a)" path (func :> Odoc_model.Paths.Path.t) path (arg :> Odoc_model.Paths.Path.t)
| `SubstitutedT _|`SubstitutedMT _|`Substituted _|`SubstitutedCT _ -> Format.fprintf ppf "Unimplemented path"
and model_fragment ppf (f : Odoc_model.Paths.Fragment.t) =
match f with
| `Root -> ()
| `Resolved rf -> model_resolved_fragment ppf rf
| `Dot (sg, d) -> Format.fprintf ppf "*%a.%s" model_fragment (sg :> Odoc_model.Paths.Fragment.t) d
and model_resolved_fragment ppf (f : Odoc_model.Paths.Fragment.Resolved.t) =
match f with
| `Root (`Module p) -> Format.fprintf ppf "root_module(%a)" resolved_path (p :> Odoc_model.Paths.Path.Resolved.t)
| `Root (`ModuleType p) -> Format.fprintf ppf "root_module_type(%a)" resolved_path (p :> Odoc_model.Paths.Path.Resolved.t)
| `Module (sg, m) -> Format.fprintf ppf "%a.%s" model_resolved_fragment (sg :> Odoc_model.Paths.Fragment.Resolved.t) (ModuleName.to_string m)
| `Type (sg, m) -> Format.fprintf ppf "%a.%s" model_resolved_fragment (sg :> Odoc_model.Paths.Fragment.Resolved.t) (TypeName.to_string m)
| _ -> Format.fprintf ppf "UNIMPLEMENTED model_resolved_fragment"
end
end
let my_compilation_unit id (s : Odoc_model.Lang.Signature.t) =
{ Odoc_model.Lang.Compilation_unit.
id = id
; root = root
; digest = "nodigest"
; imports = []
; source = None
; interface = true
; hidden = false
; content = Module s
; expansion = None
; linked = false
; canonical = None
; source_loc = None
}
let mkresolver () =
Odoc_odoc.Resolver.create
~roots:None ~important_digests:false
~directories:(List.map Odoc_odoc.Fs.Directory.of_string
# 616 "test/xref2/lib/common.cppo.ml"
(Load_path.get_paths () |> List.filter (fun s -> s <> ""))
# 620 "test/xref2/lib/common.cppo.ml"
) ~open_modules:[]
let warnings_options =
{ Odoc_model.Error.warn_error = false; print_warnings = true; warnings_tag = None }
let handle_warnings ww =
match Odoc_model.Error.handle_warnings ~warnings_options ww with
| Ok x -> x
| Error (`Msg msg) -> failwith msg
let resolve unit =
let resolver = mkresolver () in
let resolve_env = Odoc_odoc.Resolver.build_compile_env_for_unit resolver unit in
Odoc_xref2.Compile.compile ~filename:"<test>" resolve_env unit
|> handle_warnings
let resolve_from_string s =
let id, sg, _ = model_of_string s in
let unit = my_compilation_unit id sg in
resolve unit
let compile_signature ?(id = id) sg =
let open Odoc_xref2 in
Lookup_failures.catch_failures ~filename:"<test>" (fun () ->
Compile.signature Env.empty id sg)
|> handle_warnings
let compile_mli test_data =
let sg = signature_of_mli_string test_data in
compile_signature sg