1(**************************************************************************) 2(* *) 3(* OCaml *) 4(* *) 5(* Maxence Guesdon, projet Cristal, INRIA Rocquencourt *) 6(* *) 7(* Copyright 2001 Institut National de Recherche en Informatique et *) 8(* en Automatique. *) 9(* *) 10(* All rights reserved. This file is distributed under the terms of *) 11(* the GNU Lesser General Public License version 2.1, with the *) 12(* special exception on linking described in the file LICENSE. *) 13(* *) 14(**************************************************************************) 15 16(** Interface to the information collected in source files. *) 17 18(** The differents kinds of element references. *) 19type ref_kind = Odoc_types.ref_kind = 20 RK_module 21 | RK_module_type 22 | RK_class 23 | RK_class_type 24 | RK_value 25 | RK_type 26 | RK_extension 27 | RK_exception 28 | RK_attribute 29 | RK_method 30 | RK_section of text 31 | RK_recfield 32 | RK_const 33 34and text_element = Odoc_types.text_element = 35 | Raw of string (** Raw text. *) 36 | Code of string (** The string is source code. *) 37 | CodePre of string (** The string is pre-formatted source code. *) 38 | Verbatim of string (** String 'as is'. *) 39 | Bold of text (** Text in bold style. *) 40 | Italic of text (** Text in italic. *) 41 | Emphasize of text (** Emphasized text. *) 42 | Center of text (** Centered text. *) 43 | Left of text (** Left alignment. *) 44 | Right of text (** Right alignment. *) 45 | List of text list (** A list. *) 46 | Enum of text list (** An enumerated list. *) 47 | Newline (** To force a line break. *) 48 | Block of text (** Like html's block quote. *) 49 | Title of int * string option * text 50 (** Style number, optional label, and text. *) 51 | Latex of string (** A string for latex. *) 52 | Link of string * text (** A reference string and the link text. *) 53 | Ref of string * ref_kind option * text option 54 (** A reference to an element. Complete name and kind. 55 An optional text can be given to display this text instead 56 of the element name.*) 57 | Superscript of text (** Superscripts. *) 58 | Subscript of text (** Subscripts. *) 59 | Module_list of string list 60 (** The table of the given modules with their abstract. *) 61 | Index_list (** The links to the various indexes (values, types, ...) *) 62 | Custom of string * text (** to extend \{foo syntax *) 63 | Target of string * string (** (target, code) : to specify code specific to a target format *) 64 65(** A text is a list of [text_element]. The order matters. *) 66and text = text_element list 67 68(** The different forms of references in \@see tags. *) 69type see_ref = Odoc_types.see_ref = 70 See_url of string 71 | See_file of string 72 | See_doc of string 73 74(** Raised when parsing string to build a {!Odoc_info.text} 75 structure. [(line, char, string)] *) 76exception Text_syntax of int * int * string 77 78(** The information in a \@see tag. *) 79type see = see_ref * text 80 81(** Parameter name and description. *) 82type param = (string * text) 83 84(** Raised exception name and description. *) 85type raised_exception = (string * text) 86 87(** Information in a special comment 88@before 3.12.0 \@before information was not present. 89*) 90type info = Odoc_types.info = { 91 i_desc : text option; (** The description text. *) 92 i_authors : string list; (** The list of authors in \@author tags. *) 93 i_version : string option; (** The string in the \@version tag. *) 94 i_sees : see list; (** The list of \@see tags. *) 95 i_since : string option; (** The string in the \@since tag. *) 96 i_before : (string * text) list ; (** the version number and text in \@before tag *) 97 i_deprecated : text option; (** The of the \@deprecated tag. *) 98 i_params : param list; (** The list of parameter descriptions. *) 99 i_raised_exceptions : raised_exception list; (** The list of raised exceptions. *) 100 i_return_value : text option; (** The description text of the return value. *) 101 i_custom : (string * text) list ; (** A text associated to a custom @-tag. *) 102 } 103 104(** Location of elements in implementation and interface files. *) 105type location = Odoc_types.location = { 106 loc_impl : Location.t option ; (** implementation location *) 107 loc_inter : Location.t option ; (** interface location *) 108 } 109 110(** A dummy location. *) 111val dummy_loc : location 112 113(** Representation of element names. *) 114module Name : 115 sig 116 type t = string 117 118 (** Access to the simple name. *) 119 val simple : t -> t 120 121 (** [concat t1 t2] returns the concatenation of [t1] and [t2].*) 122 val concat : t -> t -> t 123 124 (** Return the depth of the name, i.e. the numer of levels to the root. 125 Example : [depth "Toto.Tutu.name"] = [3]. *) 126 val depth : t -> int 127 128 (** Take two names n1 and n2 = n3.n4 and return n4 if n3=n1 or else n2. *) 129 val get_relative : t -> t -> t 130 131 (** Return the name of the 'father' (like [dirname] for a file name).*) 132 val father : t -> t 133 end 134 135(** Representation and manipulation of method / function / class / module parameters.*) 136module Parameter : 137 sig 138 (** {3 Types} *) 139 140 (** Representation of a simple parameter name *) 141 type simple_name = Odoc_parameter.simple_name = 142 { 143 sn_name : string ; 144 sn_type : Types.type_expr ; 145 mutable sn_text : text option ; 146 } 147 148 (** Representation of parameter names. We need it to represent parameter names in tuples. 149 The value [Tuple ([], t)] stands for an anonymous parameter.*) 150 type param_info = Odoc_parameter.param_info = 151 Simple_name of simple_name 152 | Tuple of param_info list * Types.type_expr 153 154 (** A parameter is just a param_info.*) 155 type parameter = param_info 156 157 (** {3 Functions} *) 158 159 (** Acces to the name as a string. For tuples, parenthesis and commas are added. *) 160 val complete_name : parameter -> string 161 162 (** Access to the complete type. *) 163 val typ : parameter -> Types.type_expr 164 165 (** Access to the list of names ; only one for a simple parameter, or 166 a list for a tuple. *) 167 val names : parameter -> string list 168 169 (** Access to the description of a specific name. 170 @raise Not_found if no description is associated to the given name. *) 171 val desc_by_name : parameter -> string -> text option 172 173 (** Access to the type of a specific name. 174 @raise Not_found if no type is associated to the given name. *) 175 val type_by_name : parameter -> string -> Types.type_expr 176 end 177 178(** Representation and manipulation of extensions. *) 179module Extension : 180 sig 181 type private_flag = Odoc_extension.private_flag = 182 Private | Public 183 184 (** Used when the extension is a rebind of another extension, 185 when we have [extension Xt = Target_xt].*) 186 type extension_alias = Odoc_extension.extension_alias = 187 { 188 xa_name : Name.t ; (** The complete name of the target extension. *) 189 mutable xa_xt : t_extension_constructor option ; (** The target extension, if we found it.*) 190 } 191 192 and t_extension_constructor = Odoc_extension.t_extension_constructor = 193 { 194 xt_name : Name.t ; 195 xt_args: Odoc_type.constructor_args; 196 xt_ret: Types.type_expr option ; (** the optional return type of the extension *) 197 xt_type_extension: t_type_extension ; (** the type extension containing this constructor *) 198 xt_alias: extension_alias option ; (** [None] when the extension is not a rebind. *) 199 mutable xt_loc: Odoc_types.location ; 200 mutable xt_text: Odoc_types.info option ; (** optional user description *) 201 } 202 203 and t_type_extension = Odoc_extension.t_type_extension = 204 { 205 mutable te_info : info option ; (** Information found in the optional associated comment. *) 206 te_type_name : Name.t ; (** The type of the extension *) 207 te_type_parameters : Types.type_expr list; 208 te_private : private_flag ; 209 mutable te_constructors: t_extension_constructor list; 210 mutable te_loc : location ; 211 mutable te_code : string option ; 212 } 213 214 (** Access to the extensions in a group. *) 215 val extension_constructors : t_type_extension -> t_extension_constructor list 216 217 end 218 219(** Representation and manipulation of exceptions. *) 220module Exception : 221 sig 222 (** Used when the exception is a rebind of another exception, 223 when we have [exception Ex = Target_ex].*) 224 type exception_alias = Odoc_exception.exception_alias = 225 { 226 ea_name : Name.t ; (** The complete name of the target exception. *) 227 mutable ea_ex : t_exception option ; (** The target exception, if we found it.*) 228 } 229 230 and t_exception = Odoc_exception.t_exception = 231 { 232 ex_name : Name.t ; 233 mutable ex_info : info option ; (** Information found in the optional associated comment. *) 234 ex_args : Odoc_type.constructor_args; 235 ex_ret : Types.type_expr option ; (** The the optional return type of the exception. *) 236 ex_alias : exception_alias option ; (** [None] when the exception is not a rebind. *) 237 mutable ex_loc : location ; 238 mutable ex_code : string option ; 239 } 240 end 241 242(** Representation and manipulation of types.*) 243module Type : 244 sig 245 type private_flag = Odoc_type.private_flag = 246 Private | Public 247 248 (** Description of a record type field. *) 249 type record_field = Odoc_type.record_field = 250 { 251 rf_name : string ; (** Name of the field. *) 252 rf_mutable : bool ; (** [true] if mutable. *) 253 rf_type : Types.type_expr ; (** Type of the field. *) 254 mutable rf_text : info option ; (** Optional description in the associated comment.*) 255 } 256 257 (** Description of a variant type constructor. *) 258 type constructor_args = Odoc_type.constructor_args = 259 | Cstr_record of record_field list 260 | Cstr_tuple of Types.type_expr list 261 262 type variant_constructor = Odoc_type.variant_constructor = 263 { 264 vc_name : string ; (** Name of the constructor. *) 265 vc_args : constructor_args; 266 vc_ret : Types.type_expr option ; 267 mutable vc_text : info option ; (** Optional description in the associated comment. *) 268 } 269 270 (** The various kinds of a type. *) 271 type type_kind = Odoc_type.type_kind = 272 Type_abstract (** Type is abstract, for example [type t]. *) 273 | Type_variant of variant_constructor list 274 (** constructors *) 275 | Type_record of record_field list 276 (** fields *) 277 | Type_open (** Type is open *) 278 279 type object_field = Odoc_type.object_field = { 280 of_name : string ; 281 of_type : Types.type_expr ; 282 mutable of_text : Odoc_types.info option ; (** optional user description *) 283 } 284 285 type type_manifest = Odoc_type.type_manifest = 286 | Other of Types.type_expr (** Type manifest directly taken from Typedtre. *) 287 | Object_type of object_field list 288 289 (** Representation of a type. *) 290 type t_type = Odoc_type.t_type = 291 { 292 ty_name : Name.t ; (** Complete name of the type. *) 293 mutable ty_info : info option ; (** Information found in the optional associated comment. *) 294 ty_parameters : (Types.type_expr * bool * bool) list ; 295 (** type parameters: (type, covariant, contravariant) *) 296 ty_kind : type_kind; (** Type kind. *) 297 ty_private : private_flag; (** Private or public type. *) 298 ty_manifest : type_manifest option ; 299 mutable ty_loc : location ; 300 mutable ty_code : string option; 301 } 302 303 end 304 305(** Representation and manipulation of values, class attributes and class methods. *) 306module Value : 307 sig 308 (** Representation of a value. *) 309 type t_value = Odoc_value.t_value = 310 { 311 val_name : Name.t ; (** Complete name of the value. *) 312 mutable val_info : info option ; (** Information found in the optional associated comment. *) 313 val_type : Types.type_expr ; (** Type of the value. *) 314 val_recursive : bool ; (** [true] if the value is recursive. *) 315 mutable val_parameters : Odoc_parameter.parameter list ; (** The parameters, if any. *) 316 mutable val_code : string option ; (** The code of the value, if we had the only the implementation file. *) 317 mutable val_loc : location ; 318 } 319 320 (** Representation of a class attribute. *) 321 type t_attribute = Odoc_value.t_attribute = 322 { 323 att_value : t_value ; (** an attribute has almost all the same information as a value *) 324 att_mutable : bool ; (** [true] if the attribute is mutable. *) 325 att_virtual : bool ; (** [true] if the attribute is virtual. *) 326 } 327 328 (** Representation of a class method. *) 329 type t_method = Odoc_value.t_method = 330 { 331 met_value : t_value ; (** a method has almost all the same information as a value *) 332 met_private : bool ; (** [true] if the method is private.*) 333 met_virtual : bool ; (** [true] if the method is virtual. *) 334 } 335 336 (** Return [true] if the value is a function, i.e. it has a functional type. *) 337 val is_function : t_value -> bool 338 339 (** Access to the description associated to the given parameter name.*) 340 val value_parameter_text_by_name : t_value -> string -> text option 341 end 342 343(** Representation and manipulation of classes and class types.*) 344module Class : 345 sig 346 (** {3 Types} *) 347 348 (** To keep the order of elements in a class. *) 349 type class_element = Odoc_class.class_element = 350 Class_attribute of Value.t_attribute 351 | Class_method of Value.t_method 352 | Class_comment of text 353 354 (** Used when we can reference a t_class or a t_class_type. *) 355 type cct = Odoc_class.cct = 356 Cl of t_class 357 | Cltype of t_class_type * Types.type_expr list (** Class type and type parameters. *) 358 359 and inherited_class = Odoc_class.inherited_class = 360 { 361 ic_name : Name.t ; (** Complete name of the inherited class. *) 362 mutable ic_class : cct option ; (** The associated t_class or t_class_type. *) 363 ic_text : text option ; (** The inheritance description, if any. *) 364 } 365 366 and class_apply = Odoc_class.class_apply = 367 { 368 capp_name : Name.t ; (** The complete name of the applied class. *) 369 mutable capp_class : t_class option; (** The associated t_class if we found it. *) 370 capp_params : Types.type_expr list; (** The type of expressions the class is applied to. *) 371 capp_params_code : string list ; (** The code of these exprssions. *) 372 } 373 374 and class_constr = Odoc_class.class_constr = 375 { 376 cco_name : Name.t ; (** The complete name of the applied class. *) 377 mutable cco_class : cct option; 378 (** The associated class or class type if we found it. *) 379 cco_type_parameters : Types.type_expr list; (** The type parameters of the class, if needed. *) 380 } 381 382 and class_kind = Odoc_class.class_kind = 383 Class_structure of inherited_class list * class_element list 384 (** An explicit class structure, used in implementation and interface. *) 385 | Class_apply of class_apply 386 (** Application/alias of a class, used in implementation only. *) 387 | Class_constr of class_constr 388 (** A class used to give the type of the defined class, 389 instead of a structure, used in interface only. 390 For example, it will be used with the name [M1.M2....bar] 391 when the class foo is defined like this : 392 [class foo : int -> bar] *) 393 | Class_constraint of class_kind * class_type_kind 394 (** A class definition with a constraint. *) 395 396 (** Representation of a class. *) 397 and t_class = Odoc_class.t_class = 398 { 399 cl_name : Name.t ; (** Complete name of the class. *) 400 mutable cl_info : info option ; (** Information found in the optional associated comment. *) 401 cl_type : Types.class_type ; (** Type of the class. *) 402 cl_type_parameters : Types.type_expr list ; (** Type parameters. *) 403 cl_virtual : bool ; (** [true] when the class is virtual. *) 404 mutable cl_kind : class_kind ; (** The way the class is defined. *) 405 mutable cl_parameters : Parameter.parameter list ; (** The parameters of the class. *) 406 mutable cl_loc : location ; 407 } 408 409 and class_type_alias = Odoc_class.class_type_alias = 410 { 411 cta_name : Name.t ; (** Complete name of the target class type. *) 412 mutable cta_class : cct option ; (** The target t_class or t_class_type, if we found it.*) 413 cta_type_parameters : Types.type_expr list ; (** The type parameters. FIXME : use strings? *) 414 } 415 416 and class_type_kind = Odoc_class.class_type_kind = 417 Class_signature of inherited_class list * class_element list 418 | Class_type of class_type_alias (** A class type eventually applied to type args. *) 419 420 (** Representation of a class type. *) 421 and t_class_type = Odoc_class.t_class_type = 422 { 423 clt_name : Name.t ; (** Complete name of the type. *) 424 mutable clt_info : info option ; (** Information found in the optional associated comment. *) 425 clt_type : Types.class_type ; 426 clt_type_parameters : Types.type_expr list ; (** Type parameters. *) 427 clt_virtual : bool ; (** [true] if the class type is virtual *) 428 mutable clt_kind : class_type_kind ; (** The way the class type is defined. *) 429 mutable clt_loc : location ; 430 } 431 432 (** {3 Functions} *) 433 434 (** Access to the elements of a class. *) 435 val class_elements : ?trans:bool -> t_class -> class_element list 436 437 (** Access to the list of class attributes. *) 438 val class_attributes : ?trans:bool -> t_class -> Value.t_attribute list 439 440 (** Access to the description associated to the given class parameter name. *) 441 val class_parameter_text_by_name : t_class -> string -> text option 442 443 (** Access to the methods of a class. *) 444 val class_methods : ?trans:bool -> t_class -> Value.t_method list 445 446 (** Access to the comments of a class. *) 447 val class_comments : ?trans:bool -> t_class -> text list 448 449 (** Access to the elements of a class type. *) 450 val class_type_elements : ?trans:bool -> t_class_type -> class_element list 451 452 (** Access to the list of class type attributes. *) 453 val class_type_attributes : ?trans:bool -> t_class_type -> Value.t_attribute list 454 455 (** Access to the description associated to the given class type parameter name. *) 456 val class_type_parameter_text_by_name : t_class_type -> string -> text option 457 458 (** Access to the methods of a class type. *) 459 val class_type_methods : ?trans:bool -> t_class_type -> Value.t_method list 460 461 (** Access to the comments of a class type. *) 462 val class_type_comments : ?trans:bool -> t_class_type -> text list 463 end 464 465(** Representation and manipulation of modules and module types. *) 466module Module : 467 sig 468 (** {3 Types} *) 469 470 (** To keep the order of elements in a module. *) 471 type module_element = Odoc_module.module_element = 472 Element_module of t_module 473 | Element_module_type of t_module_type 474 | Element_included_module of included_module 475 | Element_class of Class.t_class 476 | Element_class_type of Class.t_class_type 477 | Element_value of Value.t_value 478 | Element_type_extension of Extension.t_type_extension 479 | Element_exception of Exception.t_exception 480 | Element_type of Type.t_type 481 | Element_module_comment of text 482 483 (** Used where we can reference t_module or t_module_type. *) 484 and mmt = Odoc_module.mmt = 485 | Mod of t_module 486 | Modtype of t_module_type 487 488 and included_module = Odoc_module.included_module = 489 { 490 im_name : Name.t ; (** Complete name of the included module. *) 491 mutable im_module : mmt option ; (** The included module or module type, if we found it. *) 492 mutable im_info : Odoc_types.info option ; (** comment associated to the includ directive *) 493 } 494 495 and module_alias = Odoc_module.module_alias = 496 { 497 ma_name : Name.t ; (** Complete name of the target module. *) 498 mutable ma_module : mmt option ; (** The real module or module type if we could associate it. *) 499 } 500 501 and module_parameter = Odoc_module.module_parameter = { 502 mp_name : string ; (** the name *) 503 mp_type : Types.module_type option ; (** the type *) 504 mp_type_code : string ; (** the original code *) 505 mp_kind : module_type_kind ; (** the way the parameter was built *) 506 } 507 508 (** Different kinds of a module. *) 509 and module_kind = Odoc_module.module_kind = 510 | Module_struct of module_element list (** A complete module structure. *) 511 | Module_alias of module_alias (** Complete name and corresponding module if we found it *) 512 | Module_functor of module_parameter * module_kind 513 (** A functor, with its parameter and the rest of its definition *) 514 | Module_apply of module_kind * module_kind 515 (** A module defined by application of a functor. *) 516 | Module_with of module_type_kind * string 517 (** A module whose type is a with ... constraint. 518 Should appear in interface files only. *) 519 | Module_constraint of module_kind * module_type_kind 520 (** A module constraint by a module type. *) 521 | Module_typeof of string (** by now only the code of the module expression *) 522 | Module_unpack of string * module_type_alias (** code of the expression and module type alias *) 523 524 (** Representation of a module. *) 525 and t_module = Odoc_module.t_module = 526 { 527 m_name : Name.t ; (** Complete name of the module. *) 528 mutable m_type : Types.module_type ; (** The type of the module. *) 529 mutable m_info : info option ; (** Information found in the optional associated comment. *) 530 m_is_interface : bool ; (** [true] for modules read from interface files *) 531 m_file : string ; (** The file the module is defined in. *) 532 mutable m_kind : module_kind ; (** The way the module is defined. *) 533 mutable m_loc : location ; 534 mutable m_top_deps : Name.t list ; (** The toplevels module names this module depends on. *) 535 mutable m_code : string option ; (** The whole code of the module *) 536 mutable m_code_intf : string option ; (** The whole code of the interface of the module *) 537 m_text_only : bool ; (** [true] if the module comes from a text file *) 538 } 539 540 and module_type_alias = Odoc_module.module_type_alias = 541 { 542 mta_name : Name.t ; (** Complete name of the target module type. *) 543 mutable mta_module : t_module_type option ; (** The real module type if we could associate it. *) 544 } 545 546 (** Different kinds of module type. *) 547 and module_type_kind = Odoc_module.module_type_kind = 548 | Module_type_struct of module_element list (** A complete module signature. *) 549 | Module_type_functor of module_parameter * module_type_kind 550 (** A functor, with its parameter and the rest of its definition *) 551 | Module_type_alias of module_type_alias 552 (** Complete alias name and corresponding module type if we found it. *) 553 | Module_type_with of module_type_kind * string 554 (** The module type kind and the code of the with constraint. *) 555 | Module_type_typeof of string 556 (** by now only the code of the module expression *) 557 558 (** Representation of a module type. *) 559 and t_module_type = Odoc_module.t_module_type = 560 { 561 mt_name : Name.t ; (** Complete name of the module type. *) 562 mutable mt_info : info option ; (** Information found in the optional associated comment. *) 563 mutable mt_type : Types.module_type option ; (** [None] means that the module type is abstract. *) 564 mt_is_interface : bool ; (** [true] for modules read from interface files. *) 565 mt_file : string ; (** The file the module type is defined in. *) 566 mutable mt_kind : module_type_kind option ; 567 (** The way the module is defined. [None] means that module type is abstract. 568 It is always [None] when the module type was extracted from the implementation file. 569 That means module types are only analysed in interface files. *) 570 mutable mt_loc : location ; 571 } 572 573 (** {3 Functions for modules} *) 574 575 (** Access to the elements of a module. *) 576 val module_elements : ?trans:bool -> t_module -> module_element list 577 578 (** Access to the submodules of a module. *) 579 val module_modules : ?trans:bool -> t_module -> t_module list 580 581 (** Access to the module types of a module. *) 582 val module_module_types : ?trans:bool -> t_module -> t_module_type list 583 584 (** Access to the included modules of a module. *) 585 val module_included_modules : ?trans:bool-> t_module -> included_module list 586 587 (** Access to the type extensions of a module. *) 588 val module_type_extensions : ?trans:bool-> t_module -> Extension.t_type_extension list 589 590 (** Access to the exceptions of a module. *) 591 val module_exceptions : ?trans:bool-> t_module -> Exception.t_exception list 592 593 (** Access to the types of a module. *) 594 val module_types : ?trans:bool-> t_module -> Type.t_type list 595 596 (** Access to the values of a module. *) 597 val module_values : ?trans:bool -> t_module -> Value.t_value list 598 599 (** Access to functional values of a module. *) 600 val module_functions : ?trans:bool-> t_module -> Value.t_value list 601 602 (** Access to non-functional values of a module. *) 603 val module_simple_values : ?trans:bool-> t_module -> Value.t_value list 604 605 (** Access to the classes of a module. *) 606 val module_classes : ?trans:bool-> t_module -> Class.t_class list 607 608 (** Access to the class types of a module. *) 609 val module_class_types : ?trans:bool-> t_module -> Class.t_class_type list 610 611 (** The list of classes defined in this module and all its submodules and functors. *) 612 val module_all_classes : ?trans:bool-> t_module -> Class.t_class list 613 614 (** [true] if the module is functor. *) 615 val module_is_functor : t_module -> bool 616 617 (** The list of couples (module parameter, optional description). *) 618 val module_parameters : ?trans:bool-> t_module -> (module_parameter * text option) list 619 620 (** The list of module comments. *) 621 val module_comments : ?trans:bool-> t_module -> text list 622 623 (** {3 Functions for module types} *) 624 625 (** Access to the elements of a module type. *) 626 val module_type_elements : ?trans:bool-> t_module_type -> module_element list 627 628 (** Access to the submodules of a module type. *) 629 val module_type_modules : ?trans:bool-> t_module_type -> t_module list 630 631 (** Access to the module types of a module type. *) 632 val module_type_module_types : ?trans:bool-> t_module_type -> t_module_type list 633 634 (** Access to the included modules of a module type. *) 635 val module_type_included_modules : ?trans:bool-> t_module_type -> included_module list 636 637 (** Access to the exceptions of a module type. *) 638 val module_type_exceptions : ?trans:bool-> t_module_type -> Exception.t_exception list 639 640 (** Access to the types of a module type. *) 641 val module_type_types : ?trans:bool-> t_module_type -> Type.t_type list 642 643 (** Access to the values of a module type. *) 644 val module_type_values : ?trans:bool-> t_module_type -> Value.t_value list 645 646 (** Access to functional values of a module type. *) 647 val module_type_functions : ?trans:bool-> t_module_type -> Value.t_value list 648 649 (** Access to non-functional values of a module type. *) 650 val module_type_simple_values : ?trans:bool-> t_module_type -> Value.t_value list 651 652 (** Access to the classes of a module type. *) 653 val module_type_classes : ?trans:bool-> t_module_type -> Class.t_class list 654 655 (** Access to the class types of a module type. *) 656 val module_type_class_types : ?trans:bool-> t_module_type -> Class.t_class_type list 657 658 (** The list of classes defined in this module type and all its submodules and functors. *) 659 val module_type_all_classes : ?trans:bool-> t_module_type -> Class.t_class list 660 661 (** [true] if the module type is functor. *) 662 val module_type_is_functor : t_module_type -> bool 663 664 (** The list of couples (module parameter, optional description). *) 665 val module_type_parameters : ?trans:bool-> t_module_type -> (module_parameter * text option) list 666 667 (** The list of module comments. *) 668 val module_type_comments : ?trans:bool-> t_module_type -> text list 669 end 670 671 672(** {3 Getting strings from values} *) 673 674(** This function is used to reset the names of type variables. 675 It must be called when printing the whole type of a function, 676 but not when printing the type of its parameters. Same for 677 classes (call it) and methods and attributes (don't call it).*) 678val reset_type_names : unit -> unit 679 680(** [string_of_variance t (covariant, invariant)] returns ["+"] if 681 the given information means "covariant", ["-"] if the it means 682 "contravariant", orelse [""], and always [""] if the given 683 type is not an abstract type with no manifest (i.e. no need 684 for the variance to be printed.*) 685val string_of_variance : Type.t_type -> (bool * bool) -> string 686 687(** This function returns a string representing a Types.type_expr. *) 688val string_of_type_expr : Types.type_expr -> string 689 690(** @return a string to display the parameters of the given class, 691 in the same form as the compiler. *) 692val string_of_class_params : Class.t_class -> string 693 694(** This function returns a string to represent the given list of types, 695 with a given separator. *) 696val string_of_type_list : ?par: bool -> string -> Types.type_expr list -> string 697 698(** This function returns a string to represent the list of type parameters 699 for the given type. *) 700val string_of_type_param_list : Type.t_type -> string 701 702(** This function returns a string to represent the list of type parameters 703 for the given type extension. *) 704val string_of_type_extension_param_list : Extension.t_type_extension -> string 705 706(** This function returns a string to represent the given list of 707 type parameters of a class or class type, 708 with a given separator. *) 709val string_of_class_type_param_list : Types.type_expr list -> string 710 711(** This function returns a string representing a [Types.module_type]. 712 @param complete indicates if we must print complete signatures 713 or just [sig end]. Default if [false]. 714 @param code if [complete = false] and the type contains something else 715 than identificators and functors, then the given code is used. 716*) 717val string_of_module_type : ?code: string -> ?complete: bool -> Types.module_type -> string 718 719(** This function returns a string representing a [Types.class_type]. 720 @param complete indicates if we must print complete signatures 721 or just [object end]. Default if [false]. 722*) 723val string_of_class_type : ?complete: bool -> Types.class_type -> string 724 725 726(** Get a string from a text. *) 727val string_of_text : text -> string 728 729(** Get a string from an info structure. *) 730val string_of_info : info -> string 731 732(** @return a string to describe the given type. *) 733val string_of_type : Type.t_type -> string 734 735val string_of_record : Type.record_field list -> string 736 737(** @return a string to describe the given type extension. *) 738val string_of_type_extension : Extension.t_type_extension -> string 739 740(** @return a string to describe the given exception. *) 741val string_of_exception : Exception.t_exception -> string 742 743(** @return a string to describe the given value. *) 744val string_of_value : Value.t_value -> string 745 746(** @return a string to describe the given attribute. *) 747val string_of_attribute : Value.t_attribute -> string 748 749(** @return a string to describe the given method. *) 750val string_of_method : Value.t_method -> string 751 752(** {3 Miscelaneous functions} *) 753 754(** Return the first sentence (until the first dot followed by a blank 755 or the first blank line) of a text. 756 Don't stop in the middle of [Code], [CodePre], [Verbatim], [List], [Enum], 757 [Latex], [Link], [Ref], [Subscript] or [Superscript]. *) 758val first_sentence_of_text : text -> text 759 760(** Return the first sentence (until the first dot followed by a blank 761 or the first blank line) of a text, and the remaining text after. 762 Don't stop in the middle of [Code], [CodePre], [Verbatim], [List], [Enum], 763 [Latex], [Link], [Ref], [Subscript] or [Superscript].*) 764val first_sentence_and_rest_of_text : text -> text * text 765 766(** Return the given [text] without any title or list. *) 767val text_no_title_no_list : text -> text 768 769(** [concat sep l] concats the given list of text [l], each separated with 770 the text [sep]. *) 771val text_concat : Odoc_types.text -> Odoc_types.text list -> Odoc_types.text 772 773(** Return the list of titles in a [text]. 774 A title is a title level, an optional label and a text.*) 775val get_titles_in_text : text -> (int * string option * text) list 776 777(** Take a sorted list of elements, a function to get the name 778 of an element and return the list of list of elements, 779 where each list group elements beginning by the same letter. 780 Since the original list is sorted, elements whose name does not 781 begin with a letter should be in the first returned list.*) 782val create_index_lists : 'a list -> ('a -> string) -> 'a list list 783 784(** Take a type and remove the option top constructor. This is 785 useful when printing labels, we we then remove the top option contructor 786 for optional labels.*) 787val remove_option : Types.type_expr -> Types.type_expr 788 789(** Return [true] if the given label is optional.*) 790val is_optional : Asttypes.arg_label -> bool 791 792(** Return the label name for the given label, 793 i.e. removes the beginning '?' if present.*) 794val label_name : Asttypes.arg_label -> string 795 796(** Return the given name where the module name or 797 part of it was removed, according to the list of modules 798 which must be hidden (cf {!Odoc_args.hidden_modules})*) 799val use_hidden_modules : Name.t -> Name.t 800 801(** Print the given string if the verbose mode is activated. *) 802val verbose : string -> unit 803 804(** Print a warning message to stderr. 805 If warnings must be treated as errors, then the 806 error counter is incremented. *) 807val warning : string -> unit 808 809(** A flag to indicate whether ocamldoc warnings must be printed or not. *) 810val print_warnings : bool ref 811 812(** Increment this counter when an error is encountered. 813 The ocamldoc tool will print the number of errors 814 encountered exit with code 1 if this number is greater 815 than 0. *) 816val errors : int ref 817 818(** Apply a function to an optional value. *) 819val apply_opt : ('a -> 'b) -> 'a option -> 'b option 820 821(** Apply a function to a first value if it is 822 not different from a second value. If the two values 823 are different, return the second one.*) 824val apply_if_equal : ('a -> 'a) -> 'a -> 'a -> 'a 825 826(** [text_of_string s] returns the text structure from the 827 given string. 828 @raise Text_syntax if a syntax error is encountered. *) 829val text_of_string : string -> text 830 831(** [text_string_of_text text] returns the string representing 832 the given [text]. This string can then be parsed again 833 by {!Odoc_info.text_of_string}.*) 834val text_string_of_text : text -> string 835 836(** [info_of_string s] parses the given string 837 like a regular ocamldoc comment and return an 838 {!Odoc_info.info} structure. 839 @return an empty structure if there was a syntax error. TODO: change this 840*) 841val info_of_string : string -> info 842 843(** [info_string_of_info info] returns the string representing 844 the given [info]. This string can then be parsed again 845 by {!Odoc_info.info_of_string}.*) 846val info_string_of_info : info -> string 847 848(** [info_of_comment_file file] parses the given file 849 and return an {!Odoc_info.info} structure. The content of the 850 file must have the same syntax as the content of a special comment. 851 The given module list is used for cross reference. 852 @raise Failure is the file could not be opened or there is a 853 syntax error. 854*) 855val info_of_comment_file : Module.t_module list -> string -> info 856 857(** [remove_ending_newline s] returns [s] without the optional ending newline. *) 858val remove_ending_newline : string -> string 859 860(** Research in elements *) 861module Search : 862 sig 863 type result_element = Odoc_search.result_element = 864 Res_module of Module.t_module 865 | Res_module_type of Module.t_module_type 866 | Res_class of Class.t_class 867 | Res_class_type of Class.t_class_type 868 | Res_value of Value.t_value 869 | Res_type of Type.t_type 870 | Res_extension of Extension.t_extension_constructor 871 | Res_exception of Exception.t_exception 872 | Res_attribute of Value.t_attribute 873 | Res_method of Value.t_method 874 | Res_section of string * text 875 | Res_recfield of Type.t_type * Type.record_field 876 | Res_const of Type.t_type * Type.variant_constructor 877 878 (** The type representing a research result.*) 879 type search_result = result_element list 880 881 (** Research of the elements whose name matches the given regular expression.*) 882 val search_by_name : Module.t_module list -> Str.regexp -> search_result 883 884 (** A function to search all the values in a list of modules. *) 885 val values : Module.t_module list -> Value.t_value list 886 887 (** A function to search all the extensions in a list of modules. *) 888 val extensions : Module.t_module list -> Extension.t_extension_constructor list 889 890 (** A function to search all the exceptions in a list of modules. *) 891 val exceptions : Module.t_module list -> Exception.t_exception list 892 893 (** A function to search all the types in a list of modules. *) 894 val types : Module.t_module list -> Type.t_type list 895 896 (** A function to search all the class attributes in a list of modules. *) 897 val attributes : Module.t_module list -> Value.t_attribute list 898 899 (** A function to search all the class methods in a list of modules. *) 900 val methods : Module.t_module list -> Value.t_method list 901 902 (** A function to search all the classes in a list of modules. *) 903 val classes : Module.t_module list -> Class.t_class list 904 905 (** A function to search all the class types in a list of modules. *) 906 val class_types : Module.t_module list -> Class.t_class_type list 907 908 (** A function to search all the modules in a list of modules. *) 909 val modules : Module.t_module list -> Module.t_module list 910 911 (** A function to search all the module types in a list of modules. *) 912 val module_types : Module.t_module list -> Module.t_module_type list 913 914 end 915 916(** Scanning of collected information *) 917module Scan : 918 sig 919 class scanner : 920 object 921 922 method scan_value : Value.t_value -> unit 923 924 method scan_type_pre : Type.t_type -> bool 925 method scan_type_const : Type.t_type -> Type.variant_constructor -> unit 926 method scan_type_recfield : Type.t_type -> Type.record_field -> unit 927 method scan_type : Type.t_type -> unit 928 method scan_extension_constructor : Extension.t_extension_constructor -> unit 929 method scan_exception : Exception.t_exception -> unit 930 method scan_attribute : Value.t_attribute -> unit 931 method scan_method : Value.t_method -> unit 932 method scan_included_module : Module.included_module -> unit 933 934 (** Scan of a type extension *) 935 936 (** Overide this method to perform controls on the extension's type, 937 private and info. This method is called before scanning the 938 extension's constructors. 939 @return true if the extension's constructors must be scanned.*) 940 method scan_type_extension_pre : Extension.t_type_extension -> bool 941 942 (** This method scans the constructors of the given type extension. *) 943 method scan_type_extension_constructors : Extension.t_type_extension -> unit 944 945 (** Scan of a type extension. Should not be overridden. It calls [scan_type_extension_pre] 946 and if [scan_type_extension_pre] returns [true], then it calls scan_type_extension_constructors.*) 947 method scan_type_extension : Extension.t_type_extension -> unit 948 949 (** Scan of a class. *) 950 951 (** Scan of a comment inside a class. *) 952 method scan_class_comment : text -> unit 953 954 (** Override this method to perform controls on the class comment 955 and params. This method is called before scanning the class elements. 956 @return true if the class elements must be scanned.*) 957 method scan_class_pre : Class.t_class -> bool 958 959 (** This method scan the elements of the given class. *) 960 method scan_class_elements : Class.t_class -> unit 961 962 (** Scan of a class. Should not be overridden. It calls [scan_class_pre] 963 and if [scan_class_pre] returns [true], then it calls scan_class_elements.*) 964 method scan_class : Class.t_class -> unit 965 966 (** Scan of a class type. *) 967 968 (** Scan of a comment inside a class type. *) 969 method scan_class_type_comment : text -> unit 970 971 (** Override this method to perform controls on the class type comment 972 and form. This method is called before scanning the class type elements. 973 @return true if the class type elements must be scanned.*) 974 method scan_class_type_pre : Class.t_class_type -> bool 975 976 (** This method scan the elements of the given class type. *) 977 method scan_class_type_elements : Class.t_class_type -> unit 978 979 (** Scan of a class type. Should not be overridden. It calls [scan_class_type_pre] 980 and if [scan_class_type_pre] returns [true], then it calls scan_class_type_elements.*) 981 method scan_class_type : Class.t_class_type -> unit 982 983 (** Scan of modules. *) 984 985 (** Scan of a comment inside a module. *) 986 method scan_module_comment : text -> unit 987 988 (** Override this method to perform controls on the module comment 989 and form. This method is called before scanning the module elements. 990 @return true if the module elements must be scanned.*) 991 method scan_module_pre : Module.t_module -> bool 992 993 (** This method scan the elements of the given module. *) 994 method scan_module_elements : Module.t_module -> unit 995 996 (** Scan of a module. Should not be overridden. It calls [scan_module_pre] 997 and if [scan_module_pre] returns [true], then it calls scan_module_elements.*) 998 method scan_module : Module.t_module -> unit 999 1000 (** Scan of module types. *) 1001 1002 (** Scan of a comment inside a module type. *) 1003 method scan_module_type_comment : text -> unit 1004 1005 (** Override this method to perform controls on the module type comment 1006 and form. This method is called before scanning the module type elements. 1007 @return true if the module type elements must be scanned. *) 1008 method scan_module_type_pre : Module.t_module_type -> bool 1009 1010 (** This method scan the elements of the given module type. *) 1011 method scan_module_type_elements : Module.t_module_type -> unit 1012 1013 (** Scan of a module type. Should not be overridden. It calls [scan_module_type_pre] 1014 and if [scan_module_type_pre] returns [true], then it calls scan_module_type_elements.*) 1015 method scan_module_type : Module.t_module_type -> unit 1016 1017 (** Main scanning method. *) 1018 1019 (** Scan a list of modules. *) 1020 method scan_module_list : Module.t_module list -> unit 1021 end 1022 end 1023 1024(** Computation of dependencies. *) 1025module Dep : 1026 sig 1027 (** Modify the modules depencies of the given list of modules, 1028 to get the minimum transitivity kernel. *) 1029 val kernel_deps_of_modules : Module.t_module list -> unit 1030 1031 (** Return the list of dependencies between the given types, 1032 in the form of a list [(type name, names of types it depends on)]. 1033 @param kernel indicates if we must keep only the transitivity kernel 1034 of the dependencies. Default is [false]. 1035 *) 1036 val deps_of_types : ?kernel: bool -> Type.t_type list -> (Type.t_type * (Name.t list)) list 1037 end 1038 1039(** {2 Some global variables} *) 1040 1041module Global : 1042 sig 1043 val errors : int ref 1044 val warn_error : bool ref 1045 1046 (** The file used by the generators outputting only one file. *) 1047 val out_file : string ref 1048 1049 (** Verbose mode or not. *) 1050 val verbose : bool ref 1051 1052 (** The directory where files have to be generated. *) 1053 val target_dir : string ref 1054 1055 (** The optional title to use in the generated documentation. *) 1056 val title : string option ref 1057 1058 (** The optional file whose content can be used as intro text. *) 1059 val intro_file : string option ref 1060 1061 (** The flag which indicates if we must generate a table of contents. *) 1062 val with_toc : bool ref 1063 1064 (** The flag which indicates if we must generate an index. *) 1065 val with_index : bool ref 1066 1067 (** The flag which indicates if we must generate a header.*) 1068 val with_header : bool ref 1069 1070 (** The flag which indicates if we must generate a trailer.*) 1071 val with_trailer : bool ref 1072end 1073 1074(** Analysis of the given source files. 1075 @param init is the list of modules already known from a previous analysis. 1076 @return the list of analysed top modules. *) 1077val analyse_files : 1078 ?merge_options:Odoc_types.merge_option list -> 1079 ?include_dirs:string list -> 1080 ?labels:bool -> 1081 ?sort_modules:bool -> 1082 ?no_stop:bool -> 1083 ?init: Odoc_module.t_module list -> 1084 Odoc_global.source_file list -> 1085 Module.t_module list 1086 1087(** Dump of a list of modules into a file. 1088 @raise Failure if an error occurs.*) 1089val dump_modules : string -> Odoc_module.t_module list -> unit 1090 1091(** Load of a list of modules from a file. 1092 @raise Failure if an error occurs.*) 1093val load_modules : string -> Odoc_module.t_module list 1094