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
|
(**************************************************************************)
(* *)
(* OCaml *)
(* *)
(* Sebastien Hinderer, projet Cambium, INRIA Paris *)
(* *)
(* Copyright 2022 Institut National de Recherche en Informatique et *)
(* en Automatique. *)
(* *)
(* All rights reserved. This file is distributed under the terms of *)
(* the GNU Lesser General Public License version 2.1, with the *)
(* special exception on linking described in the file LICENSE. *)
(* *)
(**************************************************************************)
(** Representation and manipulation of modules and module types. *)
module String = Misc.Stdlib.String
module Name = Odoc_name
(** {1 Types} *)
type module_element =
Element_module of t_module
| Element_module_type of t_module_type
| Element_included_module of included_module
| Element_class of Odoc_class.t_class
| Element_class_type of Odoc_class.t_class_type
| Element_value of Odoc_value.t_value
| Element_type_extension of Odoc_extension.t_type_extension
| Element_exception of Odoc_exception.t_exception
| Element_type of Odoc_type.t_type
| Element_module_comment of Odoc_types.text
(** To keep the order of elements in a module. *)
and mmt = Mod of t_module | Modtype of t_module_type
and included_module = {
im_name : Name.t;
mutable im_module : mmt option;
mutable im_info : Odoc_types.info option;
}
and module_alias = { ma_name : Name.t; mutable ma_module : mmt option; }
and module_parameter = {
mp_name : string;
mp_type : Types.module_type option;
mp_type_code : string;
mp_kind : module_type_kind;
}
and module_kind =
Module_struct of module_element list
| Module_alias of module_alias
| Module_functor of module_parameter * module_kind
| Module_apply of module_kind * module_kind
| Module_apply_unit of module_kind
| Module_with of module_type_kind * string
| Module_constraint of module_kind * module_type_kind
| Module_typeof of string
| Module_unpack of string * module_type_alias
and t_module = {
m_name : Name.t;
mutable m_type : Types.module_type;
mutable m_info : Odoc_types.info option;
m_is_interface : bool;
m_file : string;
mutable m_kind : module_kind;
mutable m_loc : Odoc_types.location;
mutable m_top_deps : Name.t list;
mutable m_code : string option;
mutable m_code_intf : string option;
m_text_only : bool;
}
and module_type_alias = {
mta_name : Name.t;
mutable mta_module : t_module_type option;
}
and module_type_kind =
Module_type_struct of module_element list
| Module_type_functor of module_parameter * module_type_kind
| Module_type_alias of module_type_alias
| Module_type_with of module_type_kind * string
| Module_type_typeof of string
and t_module_type = {
mt_name : Name.t;
mutable mt_info : Odoc_types.info option;
mutable mt_type : Types.module_type option;
mt_is_interface : bool;
mt_file : string;
mutable mt_kind : module_type_kind option;
mutable mt_loc : Odoc_types.location;
}
(** {1 Functions} *)
val values : module_element list -> Odoc_value.t_value list
(** Returns the list of values from a list of module_element. *)
val types : module_element list -> Odoc_type.t_type list
(** Returns the list of types from a list of module_element. *)
val type_extensions :
module_element list -> Odoc_extension.t_type_extension list
(** Returns the list of type extensions from a list of module_element. *)
val exceptions : module_element list -> Odoc_exception.t_exception list
(** Returns the list of exceptions from a list of module_element. *)
val classes : module_element list -> Odoc_class.t_class list
(** Returns the list of classes from a list of module_element. *)
val class_types : module_element list -> Odoc_class.t_class_type list
(** Returns the list of class types from a list of module_element. *)
val modules : module_element list -> t_module list
(** Returns the list of modules from a list of module_element. *)
val mod_types : module_element list -> t_module_type list
(** Returns the list of module types from a list of module_element. *)
val comments : module_element list -> Odoc_types.text list
(** Returns the list of module comment from a list of module_element. *)
val included_modules : module_element list -> included_module list
(** Returns the list of included modules from a list of module_element. *)
val module_type_elements :
?trans:bool -> t_module_type -> module_element list
(** Returns the list of elements of a module type.
@param trans indicates if, for aliased modules, we must perform a transitive search.*)
val module_elements : ?trans:bool -> t_module -> module_element list
(** Returns the list of elements of a module.
@param trans indicates if, for aliased modules, we must perform a transitive search.
*)
val module_values : ?trans:bool -> t_module -> Odoc_value.t_value list
(** Returns the list of values of a module.
@param trans indicates if, for aliased modules, we must perform a transitive search.*)
val module_functions : ?trans:bool -> t_module -> Odoc_value.t_value list
(** Returns the list of functional values of a module.
@param trans indicates if, for aliased modules, we must perform a transitive search.*)
val module_simple_values : ?trans:bool -> t_module -> Odoc_value.t_value list
(** Returns the list of non-functional values of a module.
@param trans indicates if, for aliased modules, we must perform a transitive search.*)
val module_types : ?trans:bool -> t_module -> Odoc_type.t_type list
(** Returns the list of types of a module.
@param trans indicates if, for aliased modules, we must perform a transitive search.*)
val module_type_extensions :
?trans:bool -> t_module -> Odoc_extension.t_type_extension list
(** Returns the list of type extensions of a module.
@param trans indicates if, for aliased modules, we must perform a transitive search.*)
val module_exceptions :
?trans:bool -> t_module -> Odoc_exception.t_exception list
(** Returns the list of exceptions of a module.
@param trans indicates if, for aliased modules, we must perform a transitive search.*)
val module_classes : ?trans:bool -> t_module -> Odoc_class.t_class list
(** Returns the list of classes of a module.
@param trans indicates if, for aliased modules, we must perform a transitive search.*)
val module_class_types :
?trans:bool -> t_module -> Odoc_class.t_class_type list
(** Returns the list of class types of a module.
@param trans indicates if, for aliased modules, we must perform a transitive search.*)
val module_modules : ?trans:bool -> t_module -> t_module list
(** Returns the list of modules of a module.
@param trans indicates if, for aliased modules, we must perform a transitive search.*)
val module_module_types : ?trans:bool -> t_module -> t_module_type list
(** Returns the list of module types of a module.
@param trans indicates if, for aliased modules, we must perform a transitive search.*)
val module_included_modules : ?trans:bool -> t_module -> included_module list
(** Returns the list of included module of a module.
@param trans indicates if, for aliased modules, we must perform a transitive search.*)
val module_comments : ?trans:bool -> t_module -> Odoc_types.text list
(** Returns the list of comments of a module.
@param trans indicates if, for aliased modules, we must perform a transitive search.*)
val module_type_parameters :
?trans:bool ->
t_module_type -> (module_parameter * Odoc_types.text option) list
(** Access to the parameters, for a functor type.
@param trans indicates if, for aliased modules, we must perform a transitive search.*)
val module_parameters :
?trans:bool -> t_module -> (module_parameter * Odoc_types.text option) list
(** Access to the parameters, for a functor.
@param trans indicates if, for aliased modules, we must perform a transitive search.*)
val module_all_submodules : ?trans:bool -> t_module -> t_module list
(** access to all submodules and submodules of submodules ... of the given module.
@param trans indicates if, for aliased modules, we must perform a transitive search.*)
val module_type_is_functor : t_module_type -> bool
(** The module type is a functor if it is defined as a functor or if it is an alias for a functor. *)
val module_is_functor : t_module -> bool
(** The module is a functor if it is defined as a functor or if it is an alias for a functor. *)
val module_type_values :
?trans:bool -> t_module_type -> Odoc_value.t_value list
(** Returns the list of values of a module type.
@param trans indicates if, for aliased modules, we must perform a transitive search.*)
val module_type_types : ?trans:bool -> t_module_type -> Odoc_type.t_type list
(** Returns the list of types of a module.
@param trans indicates if, for aliased modules, we must perform a transitive search.*)
val module_type_type_extensions :
?trans:bool -> t_module_type -> Odoc_extension.t_type_extension list
(** Returns the list of type extensions of a module.
@param trans indicates if, for aliased modules, we must perform a transitive search.*)
val module_type_exceptions :
?trans:bool -> t_module_type -> Odoc_exception.t_exception list
(** Returns the list of exceptions of a module.
@param trans indicates if, for aliased modules, we must perform a transitive search.*)
val module_type_classes :
?trans:bool -> t_module_type -> Odoc_class.t_class list
(** Returns the list of classes of a module.
@param trans indicates if, for aliased modules, we must perform a transitive search.*)
val module_type_class_types :
?trans:bool -> t_module_type -> Odoc_class.t_class_type list
(** Returns the list of class types of a module.
@param trans indicates if, for aliased modules, we must perform a transitive search.*)
val module_type_modules : ?trans:bool -> t_module_type -> t_module list
(** Returns the list of modules of a module.
@param trans indicates if, for aliased modules, we must perform a transitive search.*)
val module_type_module_types :
?trans:bool -> t_module_type -> t_module_type list
(** Returns the list of module types of a module.
@param trans indicates if, for aliased modules, we must perform a transitive search.*)
val module_type_included_modules :
?trans:bool -> t_module_type -> included_module list
(** Returns the list of included module of a module.
@param trans indicates if, for aliased modules, we must perform a transitive search.*)
val module_type_comments :
?trans:bool -> t_module_type -> Odoc_types.text list
(** Returns the list of comments of a module.
@param trans indicates if, for aliased modules, we must perform a transitive search.*)
val module_type_functions :
?trans:bool -> t_module_type -> Odoc_value.t_value list
(** Returns the list of functional values of a module type.
@param trans indicates if, for aliased modules, we must perform a transitive search.*)
val module_type_simple_values :
?trans:bool -> t_module_type -> Odoc_value.t_value list
(** Returns the list of non-functional values of a module type.
@param trans indicates if, for aliased modules, we must perform a transitive search.*)
(** {1 Functions for modules and module types} *)
val module_all_classes : ?trans:bool -> t_module -> Odoc_class.t_class list
(** The list of classes defined in this module and all its modules, functors, ....
@param trans indicates if, for aliased modules, we must perform a transitive search.*)
val module_type_all_classes :
?trans:bool -> t_module_type -> Odoc_class.t_class list
(** The list of classes defined in this module type and all its modules, functors, ....
@param trans indicates if, for aliased modules, we must perform a transitive search.*)
|