this repo has no description
1(*
2 * Copyright (c) 2014 Leo White <lpw25@cl.cam.ac.uk>
3 *
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 *)
16
17module Ocaml_ident = Ident
18module Ocaml_env = Env
19
20(** Identifiers for definitions *)
21
22module Identifier : sig
23 (** {2 Generic operations} *)
24
25 type 'a id = 'a Paths_types.id = { iv : 'a; ihash : int; ikey : string }
26
27 module type IdSig = sig
28 type t
29 type t_pv
30 val equal : t -> t -> bool
31 val hash : t -> int
32 val compare : t -> t -> int
33 end
34
35 module Id = Paths_types.Identifier
36
37 module Any : IdSig with type t = Id.any and type t_pv = Id.any_pv
38
39 module RootModule :
40 IdSig with type t = Id.root_module and type t_pv = Id.root_module_pv
41
42 module Signature :
43 IdSig with type t = Id.signature and type t_pv = Id.signature_pv
44
45 module ClassSignature :
46 IdSig with type t = Id.class_signature and type t_pv = Id.class_signature_pv
47
48 module LabelParent :
49 IdSig with type t = Id.label_parent and type t_pv = Id.label_parent_pv
50
51 module Module : IdSig with type t = Id.module_ and type t_pv = Id.module_pv
52
53 module FunctorParameter : sig
54 include
55 IdSig
56 with type t = Id.functor_parameter
57 and type t_pv = Id.functor_parameter_pv
58
59 val functor_arg_pos : t -> int
60 (** Gets the index in which the functor argument is, in the argument list.
61 Useful to turn identifiers into unique anchors, since multiple arguments
62 can have the same name. *)
63 end
64
65 module ModuleType :
66 IdSig with type t = Id.module_type and type t_pv = Id.module_type_pv
67
68 module Type : IdSig with type t = Id.type_ and type t_pv = Id.type_pv
69
70 module Class : IdSig with type t = Id.class_ and type t_pv = Id.class_pv
71
72 module ClassType :
73 IdSig with type t = Id.class_type and type t_pv = Id.class_type_pv
74
75 module DataType : sig
76 type t = Id.datatype
77 type t_pv = Id.datatype_pv
78 end
79 module FieldParent : sig
80 type t = Id.field_parent
81 type t_pv = Id.field_parent_pv
82 end
83 module UnboxedFieldParent : sig
84 type t = Id.unboxed_field_parent
85 type t_pv = Id.unboxed_field_parent_pv
86 end
87
88 module FunctorResult : sig
89 type t = Id.functor_result
90 type t_pv = Id.functor_result_pv
91 end
92
93 module Constructor : sig
94 type t = Id.constructor
95 type t_pv = Id.constructor_pv
96 end
97
98 module Field : sig
99 type t = Id.field
100 type t_pv = Id.field_pv
101 end
102
103 module UnboxedField : sig
104 type t = Id.unboxed_field
105 type t_pv = Id.unboxed_field_pv
106 end
107
108 module Extension : sig
109 type t = Id.extension
110 type t_pv = Id.extension_pv
111 end
112
113 module ExtensionDecl : sig
114 type t = Paths_types.Identifier.extension_decl
115
116 type t_pv = Paths_types.Identifier.extension_decl_pv
117
118 val equal : t -> t -> bool
119
120 val hash : t -> int
121
122 val compare : t -> t -> int
123 end
124
125 module Exception : sig
126 type t = Id.exception_
127 type t_pv = Id.exception_pv
128 end
129
130 module Value : sig
131 type t = Id.value
132 type t_pv = Id.value_pv
133 end
134
135 module Method : sig
136 type t = Id.method_
137 type t_pv = Id.method_pv
138 end
139
140 module InstanceVariable : sig
141 type t = Id.instance_variable
142 type t_pv = Id.instance_variable_pv
143 end
144 module Label : IdSig with type t = Id.label and type t_pv = Id.label_pv
145
146 module Page : sig
147 type t = Id.page
148 type t_pv = Id.page_pv
149 end
150
151 module LeafPage : sig
152 type t = Id.leaf_page
153 type t_pv = Id.leaf_page_pv
154 end
155
156 module ContainerPage : sig
157 type t = Id.container_page
158 type t_pv = Id.container_page_pv
159 end
160
161 module NonSrc : sig
162 type t = Id.non_src
163 type t_pv = Id.non_src_pv
164 val hash : t -> int
165 val equal : ([< t_pv ] id as 'a) -> 'a -> bool
166 end
167
168 module SourcePage : sig
169 type t = Id.source_page
170 type t_pv = Id.source_page_pv
171 end
172
173 module SourceLocation : sig
174 type t = Id.source_location
175 type t_pv = Id.source_location_pv
176 end
177
178 module AssetFile : sig
179 type t = Id.asset_file
180 type t_pv = Id.asset_file_pv
181 end
182
183 module OdocId : sig
184 type t = Id.odoc_id
185 type t_pv = Id.odoc_id_pv
186 end
187
188 module Path : sig
189 module Module :
190 IdSig with type t = Id.path_module and type t_pv = Id.path_module_pv
191
192 module ModuleType :
193 IdSig with type t = Id.path_module_type and type t_pv = Id.module_type_pv
194
195 module Type :
196 IdSig with type t = Id.path_type and type t_pv = Id.path_type_pv
197
198 module Value : IdSig with type t = Id.path_value and type t_pv = Id.value_pv
199
200 module ClassType :
201 IdSig
202 with type t = Id.path_class_type
203 and type t_pv = Id.path_class_type_pv
204
205 type t = Id.path_any
206 end
207
208 type t = Id.any
209
210 type t_pv = Id.any_pv
211
212 val hash : t -> int
213
214 val name : [< t_pv ] id -> string
215
216 val fullname : [< t_pv ] id -> string list
217 (** The fullname of value [x] in module [M] is [M.x], whereas the regular name
218 is [x]. *)
219
220 val is_hidden : [< t_pv ] id -> bool
221
222 val compare : t -> t -> int
223
224 val equal : ([< t_pv ] id as 'a) -> 'a -> bool
225
226 val label_parent : [< NonSrc.t_pv ] id -> LabelParent.t
227
228 module Maps : sig
229 module Any : Map.S with type key = Any.t
230
231 module FunctorParameter : Map.S with type key = FunctorParameter.t
232
233 module Module : Map.S with type key = Module.t
234
235 module ModuleType : Map.S with type key = ModuleType.t
236
237 module Type : Map.S with type key = Type.t
238
239 module Class : Map.S with type key = Class.t
240
241 module ClassType : Map.S with type key = ClassType.t
242
243 module Label : Map.S with type key = Label.t
244
245 module Path : sig
246 module Type : Map.S with type key = Path.Type.t
247
248 module ClassType : Map.S with type key = Path.ClassType.t
249 end
250 end
251
252 module Hashtbl : sig
253 module Any : Hashtbl.S with type key = Any.t
254 module ContainerPage : Hashtbl.S with type key = ContainerPage.t
255 module LeafPage : Hashtbl.S with type key = LeafPage.t
256 module RootModule : Hashtbl.S with type key = RootModule.t
257 module SourcePage : Hashtbl.S with type key = SourcePage.t
258 end
259
260 module Mk : sig
261 open Names
262
263 val page :
264 ContainerPage.t option * PageName.t ->
265 [> `Page of ContainerPage.t option * PageName.t ] id
266
267 val leaf_page :
268 ContainerPage.t option * PageName.t ->
269 [> `LeafPage of ContainerPage.t option * PageName.t ] id
270
271 val source_page : ContainerPage.t * string -> SourcePage.t
272
273 val asset_file : Page.t * AssetName.t -> AssetFile.t
274
275 val root :
276 ContainerPage.t option * ModuleName.t ->
277 [> `Root of ContainerPage.t option * ModuleName.t ] id
278
279 val implementation : string -> [> `Implementation of ModuleName.t ] id
280
281 val module_ :
282 Signature.t * ModuleName.t ->
283 [> `Module of Signature.t * ModuleName.t ] id
284
285 val parameter :
286 Signature.t * ModuleName.t ->
287 [> `Parameter of Signature.t * ModuleName.t ] id
288
289 val result : Signature.t -> [> `Result of Signature.t ] id
290
291 val module_type :
292 Signature.t * ModuleTypeName.t ->
293 [> `ModuleType of Signature.t * ModuleTypeName.t ] id
294
295 val class_ :
296 Signature.t * TypeName.t -> [> `Class of Signature.t * TypeName.t ] id
297
298 val class_type :
299 Signature.t * TypeName.t -> [> `ClassType of Signature.t * TypeName.t ] id
300
301 val type_ :
302 Signature.t * TypeName.t -> [> `Type of Signature.t * TypeName.t ] id
303
304 val core_type : string -> [> `CoreType of TypeName.t ] id
305
306 val constructor :
307 DataType.t * ConstructorName.t ->
308 [> `Constructor of DataType.t * ConstructorName.t ] id
309
310 val field :
311 FieldParent.t * FieldName.t ->
312 [> `Field of FieldParent.t * FieldName.t ] id
313
314 val unboxed_field :
315 UnboxedFieldParent.t * UnboxedFieldName.t ->
316 [> `UnboxedField of UnboxedFieldParent.t * UnboxedFieldName.t ] id
317
318 val extension :
319 Signature.t * ExtensionName.t ->
320 [> `Extension of Signature.t * ExtensionName.t ] id
321
322 val extension_decl :
323 Signature.t * (ExtensionName.t * ExtensionName.t) ->
324 [> `ExtensionDecl of Signature.t * ExtensionName.t * ExtensionName.t ] id
325 (** [extension_decl (sg, e1, eN)] defines an extension declaration where
326 [sg] is the parent, [e1] is the first constructor of the extension, and
327 [eN] is the constructor the Id is created for. [e1] will be used for the
328 url, and [eN] will be the one displayed. The first constructor of the
329 extension will always be used to reference the extension point. *)
330
331 val exception_ :
332 Signature.t * ExceptionName.t ->
333 [> `Exception of Signature.t * ExceptionName.t ] id
334
335 val value :
336 Signature.t * ValueName.t -> [> `Value of Signature.t * ValueName.t ] id
337
338 val method_ :
339 ClassSignature.t * MethodName.t ->
340 [> `Method of ClassSignature.t * MethodName.t ] id
341
342 val instance_variable :
343 ClassSignature.t * InstanceVariableName.t ->
344 [> `InstanceVariable of ClassSignature.t * InstanceVariableName.t ] id
345
346 val label :
347 LabelParent.t * LabelName.t ->
348 [> `Label of LabelParent.t * LabelName.t ] id
349
350 val source_location :
351 SourcePage.t * DefName.t ->
352 [> `SourceLocation of SourcePage.t * DefName.t ] id
353
354 val source_location_mod :
355 SourcePage.t -> [> `SourceLocationMod of SourcePage.t ] id
356
357 val source_location_int :
358 SourcePage.t * LocalName.t ->
359 [> `SourceLocationInternal of SourcePage.t * LocalName.t ] id
360 end
361
362 (** Create a synthetic parent identifier for items inside an include's
363 module type expression. Uses a lowercase module name (illegal in normal
364 OCaml) to ensure no clashes with real identifiers. Each call returns a
365 fresh identifier. *)
366 val fresh_include_parent : Signature.t -> Signature.t
367end
368
369(** Normal OCaml paths (i.e. the ones present in types) *)
370module rec Path : sig
371 module Resolved : sig
372 module Module : sig
373 type t = Paths_types.Resolved_path.module_
374
375 val is_hidden : t -> weak_canonical_test:bool -> bool
376
377 (* val identifier : t -> Identifier.Path.Module.t *)
378
379 (* val root : t -> string option *)
380 end
381
382 module ModuleType : sig
383 type t = Paths_types.Resolved_path.module_type
384
385 (* val is_hidden : t -> weak_canonical_test:bool -> bool *)
386
387 (* val identifier : t -> Identifier.Path.ModuleType.t *)
388 end
389
390 module Type : sig
391 type t = Paths_types.Resolved_path.type_
392
393 (* val of_ident : Identifier.Path.Type.t -> t *)
394
395 (* val is_hidden : t -> bool *)
396
397 (* val identifier : t -> Identifier.Path.Type.t *)
398 end
399
400 module Value : sig
401 type t = Paths_types.Resolved_path.value
402 end
403
404 module ClassType : sig
405 type t = Paths_types.Resolved_path.class_type
406
407 (* val of_ident : Identifier.Path.ClassType.t -> t *)
408
409 (* val is_hidden : t -> bool *)
410 end
411
412 type t = Paths_types.Resolved_path.any
413
414 val identifier : t -> Identifier.t option
415 (** If the path points to a core type, no identifier can be generated *)
416
417 val is_hidden : t -> bool
418 end
419
420 module Module : sig
421 type t = Paths_types.Path.module_
422
423 (* val root : t -> string option *)
424 end
425
426 module ModuleType : sig
427 type t = Paths_types.Path.module_type
428 end
429
430 module Type : sig
431 type t = Paths_types.Path.type_
432 end
433
434 module Value : sig
435 type t = Paths_types.Path.value
436 end
437
438 module ClassType : sig
439 type t = Paths_types.Path.class_type
440 end
441
442 type t = Paths_types.Path.any
443
444 val is_hidden : t -> bool
445end
446
447(** OCaml path fragments for specifying module substitutions *)
448module Fragment : sig
449 module Resolved : sig
450 module Signature : sig
451 type t = Paths_types.Resolved_fragment.signature
452 end
453
454 module Module : sig
455 type t = Paths_types.Resolved_fragment.module_
456 end
457
458 module ModuleType : sig
459 type t = Paths_types.Resolved_fragment.module_type
460 end
461
462 module Type : sig
463 type t = Paths_types.Resolved_fragment.type_
464 end
465
466 type leaf = Paths_types.Resolved_fragment.leaf
467
468 type root = Paths_types.Resolved_fragment.root
469
470 type t = Paths_types.Resolved_fragment.any
471
472 val identifier : t -> Identifier.t option
473
474 val is_hidden : t -> bool
475 end
476
477 module Signature : sig
478 type t = Paths_types.Fragment.signature
479 end
480
481 module Module : sig
482 type t = Paths_types.Fragment.module_
483 end
484
485 module ModuleType : sig
486 type t = Paths_types.Fragment.module_type
487 end
488
489 module Type : sig
490 type t = Paths_types.Fragment.type_
491 end
492
493 type leaf = Paths_types.Fragment.leaf
494
495 type t = Paths_types.Fragment.any
496end
497
498(** References present in documentation comments ([{!Foo.Bar}]) *)
499module rec Reference : sig
500 module Resolved : sig
501 module Signature : sig
502 type t = Paths_types.Resolved_reference.signature
503 end
504
505 module ClassSignature : sig
506 type t = Paths_types.Resolved_reference.class_signature
507 end
508
509 module DataType : sig
510 type t = Paths_types.Resolved_reference.datatype
511 end
512
513 module FieldParent : sig
514 type t = Paths_types.Resolved_reference.field_parent
515 end
516
517 module UnboxedFieldParent : sig
518 type t = Paths_types.Resolved_reference.unboxed_field_parent
519 end
520
521 module LabelParent : sig
522 type t = Paths_types.Resolved_reference.label_parent
523 end
524
525 module Module : sig
526 type t = Paths_types.Resolved_reference.module_
527 end
528
529 module ModuleType : sig
530 type t = Paths_types.Resolved_reference.module_type
531 end
532
533 module Type : sig
534 type t = Paths_types.Resolved_reference.type_
535 end
536
537 module Constructor : sig
538 type t = Paths_types.Resolved_reference.constructor
539 end
540
541 module Field : sig
542 type t = Paths_types.Resolved_reference.field
543 end
544
545 module UnboxedField : sig
546 type t = Paths_types.Resolved_reference.unboxed_field
547 end
548
549 module Extension : sig
550 type t = Paths_types.Resolved_reference.extension
551 end
552
553 module ExtensionDecl : sig
554 type t = Paths_types.Resolved_reference.extension_decl
555 end
556
557 module Exception : sig
558 type t = Paths_types.Resolved_reference.exception_
559 end
560
561 module Value : sig
562 type t = Paths_types.Resolved_reference.value
563 end
564
565 module Class : sig
566 type t = Paths_types.Resolved_reference.class_
567 end
568
569 module ClassType : sig
570 type t = Paths_types.Resolved_reference.class_type
571 end
572
573 module Method : sig
574 type t = Paths_types.Resolved_reference.method_
575 end
576
577 module InstanceVariable : sig
578 type t = Paths_types.Resolved_reference.instance_variable
579 end
580
581 module Label : sig
582 type t = Paths_types.Resolved_reference.label
583 end
584
585 module Page : sig
586 type t = Paths_types.Resolved_reference.page
587 end
588
589 module Asset : sig
590 type t = Paths_types.Resolved_reference.asset
591
592 val identifier : t -> Identifier.AssetFile.t
593 end
594
595 type t = Paths_types.Resolved_reference.any
596
597 val identifier : t -> Identifier.t option
598 end
599
600 module Signature : sig
601 type t = Paths_types.Reference.signature
602 end
603
604 module ClassSignature : sig
605 type t = Paths_types.Reference.class_signature
606 end
607
608 module DataType : sig
609 type t = Paths_types.Reference.datatype
610 end
611
612 module FragmentTypeParent : sig
613 type t = Paths_types.Reference.fragment_type_parent
614 end
615
616 module LabelParent : sig
617 type t = Paths_types.Reference.label_parent
618 end
619
620 module Module : sig
621 type t = Paths_types.Reference.module_
622 end
623
624 module ModuleType : sig
625 type t = Paths_types.Reference.module_type
626 end
627
628 module Type : sig
629 type t = Paths_types.Reference.type_
630 end
631
632 module Constructor : sig
633 type t = Paths_types.Reference.constructor
634 end
635
636 module Field : sig
637 type t = Paths_types.Reference.field
638 end
639
640 module UnboxedField : sig
641 type t = Paths_types.Reference.unboxed_field
642 end
643
644 module Extension : sig
645 type t = Paths_types.Reference.extension
646 end
647
648 module ExtensionDecl : sig
649 type t = Paths_types.Reference.extension_decl
650 end
651
652 module Exception : sig
653 type t = Paths_types.Reference.exception_
654 end
655
656 module Value : sig
657 type t = Paths_types.Reference.value
658 end
659
660 module Class : sig
661 type t = Paths_types.Reference.class_
662 end
663
664 module ClassType : sig
665 type t = Paths_types.Reference.class_type
666 end
667
668 module Method : sig
669 type t = Paths_types.Reference.method_
670 end
671
672 module InstanceVariable : sig
673 type t = Paths_types.Reference.instance_variable
674 end
675
676 module Label : sig
677 type t = Paths_types.Reference.label
678 end
679
680 module Page : sig
681 type t = Paths_types.Reference.page
682 end
683
684 module Asset : sig
685 type t = Paths_types.Reference.asset
686 end
687
688 module Hierarchy : sig
689 type t = Paths_types.Reference.hierarchy
690 end
691
692 type t = Paths_types.Reference.any
693
694 type tag_any = Paths_types.Reference.tag_any
695 type tag_hierarchy = Paths_types.Reference.tag_hierarchy
696end