package ocaml-base-compiler
Representation and manipulation of modules and module types.
Types
type module_element = Odoc_module.module_element =
| Element_module of t_module
| Element_module_type of t_module_type
| Element_included_module of included_module
| Element_class of Class.t_class
| Element_class_type of Class.t_class_type
| Element_value of Value.t_value
| Element_type_extension of Extension.t_type_extension
| Element_exception of Exception.t_exception
| Element_type of Type.t_type
| Element_module_comment of text
To keep the order of elements in a module.
Used where we can reference t_module or t_module_type.
and included_module = Odoc_module.included_module = {
im_name : Name.t;
(*Complete name of the included module.
*)mutable im_module : mmt option;
(*The included module or module type, if we found it.
*)mutable im_info : Odoc_types.info option;
(*comment associated with the include directive
*)
}
and module_alias = Odoc_module.module_alias = {
ma_name : Name.t;
(*Complete name of the target module.
*)mutable ma_module : mmt option;
(*The real module or module type if we could associate it.
*)
}
and module_parameter = Odoc_module.module_parameter = {
mp_name : string;
(*the name
*)mp_type : Types.module_type option;
(*the type
*)mp_type_code : string;
(*the original code
*)mp_kind : module_type_kind;
(*the way the parameter was built
*)
}
and module_kind = Odoc_module.module_kind =
| Module_struct of module_element list
(*A complete module structure.
*)| Module_alias of module_alias
(*Complete name and corresponding module if we found it
*)| Module_functor of module_parameter * module_kind
(*A functor, with its parameter and the rest of its definition
*)| Module_apply of module_kind * module_kind
(*A module defined by application of a functor.
*)| Module_with of module_type_kind * string
(*A module whose type is a with ... constraint. Should appear in interface files only.
*)| Module_constraint of module_kind * module_type_kind
(*A module constraint by a module type.
*)| Module_typeof of string
(*by now only the code of the module expression
*)| Module_unpack of string * module_type_alias
(*code of the expression and module type alias
*)
Different kinds of a module.
and t_module = Odoc_module.t_module = {
m_name : Name.t;
(*Complete name of the module.
*)mutable m_type : Types.module_type;
(*The type of the module.
*)mutable m_info : info option;
(*Information found in the optional associated comment.
*)m_is_interface : bool;
(*
*)true
for modules read from interface filesm_file : string;
(*The file the module is defined in.
*)mutable m_kind : module_kind;
(*The way the module is defined.
*)mutable m_loc : location;
mutable m_top_deps : Name.t list;
(*The toplevels module names this module depends on.
*)mutable m_code : string option;
(*The whole code of the module
*)mutable m_code_intf : string option;
(*The whole code of the interface of the module
*)m_text_only : bool;
(*
*)true
if the module comes from a text file
}
Representation of a module.
and module_type_alias = Odoc_module.module_type_alias = {
mta_name : Name.t;
(*Complete name of the target module type.
*)mutable mta_module : t_module_type option;
(*The real module type if we could associate it.
*)
}
and module_type_kind = Odoc_module.module_type_kind =
| Module_type_struct of module_element list
(*A complete module signature.
*)| Module_type_functor of module_parameter * module_type_kind
(*A functor, with its parameter and the rest of its definition
*)| Module_type_alias of module_type_alias
(*Complete alias name and corresponding module type if we found it.
*)| Module_type_with of module_type_kind * string
(*The module type kind and the code of the with constraint.
*)| Module_type_typeof of string
(*by now only the code of the module expression
*)
Different kinds of module type.
and t_module_type = Odoc_module.t_module_type = {
mt_name : Name.t;
(*Complete name of the module type.
*)mutable mt_info : info option;
(*Information found in the optional associated comment.
*)mutable mt_type : Types.module_type option;
(*
*)None
means that the module type is abstract.mt_is_interface : bool;
(*
*)true
for modules read from interface files.mt_file : string;
(*The file the module type is defined in.
*)mutable mt_kind : module_type_kind option;
(*The way the module is defined.
*)None
means that module type is abstract. It is alwaysNone
when the module type was extracted from the implementation file. That means module types are only analysed in interface files.mutable mt_loc : location;
}
Representation of a module type.
Functions for modules
val module_elements : ?trans:bool -> t_module -> module_element list
Access to the elements of a module.
val module_module_types : ?trans:bool -> t_module -> t_module_type list
Access to the module types of a module.
val module_included_modules : ?trans:bool -> t_module -> included_module list
Access to the included modules of a module.
val module_type_extensions :
?trans:bool ->
t_module ->
Extension.t_type_extension list
Access to the type extensions of a module.
val module_exceptions : ?trans:bool -> t_module -> Exception.t_exception list
Access to the exceptions of a module.
val module_types : ?trans:bool -> t_module -> Type.t_type list
Access to the types of a module.
val module_values : ?trans:bool -> t_module -> Value.t_value list
Access to the values of a module.
val module_functions : ?trans:bool -> t_module -> Value.t_value list
Access to functional values of a module.
val module_simple_values : ?trans:bool -> t_module -> Value.t_value list
Access to non-functional values of a module.
val module_classes : ?trans:bool -> t_module -> Class.t_class list
Access to the classes of a module.
val module_class_types : ?trans:bool -> t_module -> Class.t_class_type list
Access to the class types of a module.
val module_all_classes : ?trans:bool -> t_module -> Class.t_class list
The list of classes defined in this module and all its submodules and functors.
val module_is_functor : t_module -> bool
true
if the module is functor.
val module_parameters :
?trans:bool ->
t_module ->
(module_parameter * text option) list
The list of couples (module parameter, optional description).
Functions for module types
val module_type_elements : ?trans:bool -> t_module_type -> module_element list
Access to the elements of a module type.
val module_type_modules : ?trans:bool -> t_module_type -> t_module list
Access to the submodules of a module type.
val module_type_module_types :
?trans:bool ->
t_module_type ->
t_module_type list
Access to the module types of a module type.
val module_type_included_modules :
?trans:bool ->
t_module_type ->
included_module list
Access to the included modules of a module type.
val module_type_exceptions :
?trans:bool ->
t_module_type ->
Exception.t_exception list
Access to the exceptions of a module type.
val module_type_types : ?trans:bool -> t_module_type -> Type.t_type list
Access to the types of a module type.
val module_type_values : ?trans:bool -> t_module_type -> Value.t_value list
Access to the values of a module type.
val module_type_functions : ?trans:bool -> t_module_type -> Value.t_value list
Access to functional values of a module type.
val module_type_simple_values :
?trans:bool ->
t_module_type ->
Value.t_value list
Access to non-functional values of a module type.
val module_type_classes : ?trans:bool -> t_module_type -> Class.t_class list
Access to the classes of a module type.
val module_type_class_types :
?trans:bool ->
t_module_type ->
Class.t_class_type list
Access to the class types of a module type.
val module_type_all_classes :
?trans:bool ->
t_module_type ->
Class.t_class list
The list of classes defined in this module type and all its submodules and functors.
val module_type_is_functor : t_module_type -> bool
true
if the module type is functor.
val module_type_parameters :
?trans:bool ->
t_module_type ->
(module_parameter * text option) list
The list of couples (module parameter, optional description).
val module_type_comments : ?trans:bool -> t_module_type -> text list
The list of module comments.