2002-03-27 08:20:32 -08:00
|
|
|
(***********************************************************************)
|
2012-08-01 05:09:31 -07:00
|
|
|
(* *)
|
2002-03-27 08:20:32 -08:00
|
|
|
(* OCamldoc *)
|
|
|
|
(* *)
|
|
|
|
(* Maxence Guesdon, projet Cristal, INRIA Rocquencourt *)
|
|
|
|
(* *)
|
|
|
|
(* Copyright 2001 Institut National de Recherche en Informatique et *)
|
|
|
|
(* en Automatique. All rights reserved. This file is distributed *)
|
|
|
|
(* under the terms of the Q Public License version 1.0. *)
|
|
|
|
(* *)
|
|
|
|
(***********************************************************************)
|
|
|
|
|
|
|
|
(** Text generation.
|
|
|
|
|
2008-07-23 01:55:36 -07:00
|
|
|
This module contains the class [to_text] with methods used to transform
|
2002-03-27 08:20:32 -08:00
|
|
|
information about elements to a [text] structure.*)
|
|
|
|
|
2008-07-23 01:55:36 -07:00
|
|
|
open Odoc_info
|
2002-03-27 08:20:32 -08:00
|
|
|
open Exception
|
|
|
|
open Type
|
|
|
|
open Value
|
|
|
|
open Module
|
|
|
|
open Class
|
|
|
|
open Parameter
|
|
|
|
|
|
|
|
(** A class used to get a [text] for info structures. *)
|
|
|
|
class virtual info =
|
|
|
|
object (self)
|
|
|
|
(** The list of pairs [(tag, f)] where [f] is a function taking
|
2008-07-23 01:55:36 -07:00
|
|
|
the [text] associated to [tag] and returning a [text].
|
2002-03-27 08:20:32 -08:00
|
|
|
Add a pair here to handle a tag.*)
|
|
|
|
val mutable tag_functions = ([] : (string * (Odoc_info.text -> Odoc_info.text)) list)
|
|
|
|
|
|
|
|
(** @return [etxt] value for an authors list. *)
|
|
|
|
method text_of_author_list l =
|
|
|
|
match l with
|
2002-07-23 07:12:03 -07:00
|
|
|
[] ->
|
|
|
|
[]
|
2002-03-27 08:20:32 -08:00
|
|
|
| _ ->
|
2002-07-23 07:12:03 -07:00
|
|
|
[ Bold [Raw (Odoc_messages.authors^": ")] ;
|
|
|
|
Raw (String.concat ", " l) ;
|
2008-07-23 01:55:36 -07:00
|
|
|
Newline
|
|
|
|
]
|
2002-03-27 08:20:32 -08:00
|
|
|
|
|
|
|
(** @return [text] value for the given optional version information.*)
|
|
|
|
method text_of_version_opt v_opt =
|
|
|
|
match v_opt with
|
2002-07-23 07:12:03 -07:00
|
|
|
None -> []
|
2002-03-27 08:20:32 -08:00
|
|
|
| Some v -> [ Bold [Raw (Odoc_messages.version^": ")] ;
|
2002-07-23 07:12:03 -07:00
|
|
|
Raw v ;
|
|
|
|
Newline
|
|
|
|
]
|
2002-03-27 08:20:32 -08:00
|
|
|
|
|
|
|
(** @return [text] value for the given optional since information.*)
|
|
|
|
method text_of_since_opt s_opt =
|
|
|
|
match s_opt with
|
2002-07-23 07:12:03 -07:00
|
|
|
None -> []
|
2002-03-27 08:20:32 -08:00
|
|
|
| Some s -> [ Bold [Raw (Odoc_messages.since^": ")] ;
|
2002-07-23 07:12:03 -07:00
|
|
|
Raw s ;
|
2008-07-23 01:55:36 -07:00
|
|
|
Newline
|
2002-07-23 07:12:03 -07:00
|
|
|
]
|
2002-03-27 08:20:32 -08:00
|
|
|
|
2010-05-31 04:52:13 -07:00
|
|
|
(** @return [text] value to represent the list of "before" information. *)
|
|
|
|
method text_of_before = function
|
|
|
|
[] -> []
|
|
|
|
| l ->
|
|
|
|
let f (v, text) =
|
|
|
|
(Bold [Raw (Printf.sprintf "%s %s " Odoc_messages.before v) ]) ::
|
|
|
|
text @
|
|
|
|
[Newline]
|
|
|
|
in
|
|
|
|
List.flatten (List.map f l)
|
|
|
|
|
2002-03-27 08:20:32 -08:00
|
|
|
(** @return [text] value for the given list of raised exceptions.*)
|
|
|
|
method text_of_raised_exceptions l =
|
|
|
|
match l with
|
2002-07-23 07:12:03 -07:00
|
|
|
[] -> []
|
2008-07-23 01:55:36 -07:00
|
|
|
| (s, t) :: [] ->
|
2002-07-23 07:12:03 -07:00
|
|
|
[ Bold [ Raw Odoc_messages.raises ] ;
|
|
|
|
Raw " " ;
|
|
|
|
Code s ;
|
|
|
|
Raw " "
|
2008-07-23 01:55:36 -07:00
|
|
|
]
|
2002-07-23 07:12:03 -07:00
|
|
|
@ t
|
|
|
|
@ [ Newline ]
|
2002-03-27 08:20:32 -08:00
|
|
|
| _ ->
|
2002-07-23 07:12:03 -07:00
|
|
|
[ Bold [ Raw Odoc_messages.raises ] ;
|
|
|
|
Raw " " ;
|
|
|
|
List
|
|
|
|
(List.map
|
|
|
|
(fun (ex, desc) ->(Code ex) :: (Raw " ") :: desc )
|
|
|
|
l
|
|
|
|
) ;
|
|
|
|
Newline
|
2008-07-23 01:55:36 -07:00
|
|
|
]
|
2002-03-27 08:20:32 -08:00
|
|
|
|
|
|
|
(** Return [text] value for the given "see also" reference. *)
|
|
|
|
method text_of_see (see_ref, t) =
|
2008-07-23 01:55:36 -07:00
|
|
|
let t_ref =
|
2002-07-23 07:12:03 -07:00
|
|
|
match see_ref with
|
|
|
|
Odoc_info.See_url s -> [ Odoc_info.Link (s, t) ]
|
|
|
|
| Odoc_info.See_file s -> (Odoc_info.Code s) :: (Odoc_info.Raw " ") :: t
|
|
|
|
| Odoc_info.See_doc s -> (Odoc_info.Italic [Odoc_info.Raw s]) :: (Odoc_info.Raw " ") :: t
|
2002-03-27 08:20:32 -08:00
|
|
|
in
|
|
|
|
t_ref
|
2008-07-23 01:55:36 -07:00
|
|
|
|
2002-03-27 08:20:32 -08:00
|
|
|
(** Return [text] value for the given list of "see also" references.*)
|
|
|
|
method text_of_sees l =
|
|
|
|
match l with
|
2002-07-23 07:12:03 -07:00
|
|
|
[] -> []
|
2008-07-23 01:55:36 -07:00
|
|
|
| see :: [] ->
|
|
|
|
(Bold [ Raw Odoc_messages.see_also ]) ::
|
|
|
|
(Raw " ") ::
|
2002-07-23 07:12:03 -07:00
|
|
|
(self#text_of_see see) @ [ Newline ]
|
2002-03-27 08:20:32 -08:00
|
|
|
| _ ->
|
2008-07-23 01:55:36 -07:00
|
|
|
(Bold [ Raw Odoc_messages.see_also ]) ::
|
2002-07-23 07:12:03 -07:00
|
|
|
[ List
|
|
|
|
(List.map
|
|
|
|
(fun see -> self#text_of_see see)
|
|
|
|
l
|
|
|
|
);
|
|
|
|
Newline
|
|
|
|
]
|
2002-03-27 08:20:32 -08:00
|
|
|
|
|
|
|
(** @return [text] value for the given optional return information.*)
|
|
|
|
method text_of_return_opt return_opt =
|
|
|
|
match return_opt with
|
2002-07-23 07:12:03 -07:00
|
|
|
None -> []
|
2002-03-27 08:20:32 -08:00
|
|
|
| Some t -> (Bold [Raw (Odoc_messages.returns^" ")]) :: t @ [ Newline ]
|
|
|
|
|
|
|
|
(** Return a [text] for the given list of custom tagged texts. *)
|
|
|
|
method text_of_custom l =
|
2008-07-23 01:55:36 -07:00
|
|
|
List.fold_left
|
2002-07-23 07:12:03 -07:00
|
|
|
(fun acc -> fun (tag, text) ->
|
|
|
|
try
|
|
|
|
let f = List.assoc tag tag_functions in
|
|
|
|
match acc with
|
|
|
|
[] -> f text
|
|
|
|
| _ -> acc @ (Newline :: (f text))
|
|
|
|
with
|
|
|
|
Not_found ->
|
|
|
|
Odoc_info.warning (Odoc_messages.tag_not_handled tag) ;
|
|
|
|
acc
|
|
|
|
)
|
|
|
|
[]
|
|
|
|
l
|
2002-03-27 08:20:32 -08:00
|
|
|
|
|
|
|
(** @return [text] value for a description, except for the i_params field. *)
|
|
|
|
method text_of_info ?(block=true) info_opt =
|
|
|
|
match info_opt with
|
2002-07-23 07:12:03 -07:00
|
|
|
None ->
|
|
|
|
[]
|
2002-03-27 08:20:32 -08:00
|
|
|
| Some info ->
|
2008-07-23 01:55:36 -07:00
|
|
|
let t =
|
2002-07-23 07:12:03 -07:00
|
|
|
(match info.i_deprecated with
|
|
|
|
None -> []
|
|
|
|
| Some t -> ( Italic [Raw (Odoc_messages.deprecated^" ")] ) :: t
|
|
|
|
) @
|
|
|
|
(match info.i_desc with
|
|
|
|
None -> []
|
|
|
|
| Some t when t = [Odoc_info.Raw ""] -> []
|
|
|
|
| Some t -> t @ [ Newline ]
|
|
|
|
) @
|
|
|
|
(self#text_of_author_list info.i_authors) @
|
|
|
|
(self#text_of_version_opt info.i_version) @
|
2010-05-31 04:52:13 -07:00
|
|
|
(self#text_of_before info.i_before) @
|
2002-07-23 07:12:03 -07:00
|
|
|
(self#text_of_since_opt info.i_since) @
|
|
|
|
(self#text_of_raised_exceptions info.i_raised_exceptions) @
|
|
|
|
(self#text_of_return_opt info.i_return_value) @
|
|
|
|
(self#text_of_sees info.i_sees) @
|
|
|
|
(self#text_of_custom info.i_custom)
|
|
|
|
in
|
|
|
|
if block then
|
2008-07-23 01:55:36 -07:00
|
|
|
[Block t]
|
|
|
|
else
|
2002-07-23 07:12:03 -07:00
|
|
|
t
|
2002-03-27 08:20:32 -08:00
|
|
|
end
|
|
|
|
|
|
|
|
(** This class defines methods to generate a [text] structure from elements. *)
|
|
|
|
class virtual to_text =
|
|
|
|
object (self)
|
|
|
|
inherit info
|
|
|
|
|
|
|
|
method virtual label : ?no_: bool -> string -> string
|
|
|
|
|
2008-07-23 01:55:36 -07:00
|
|
|
(** Take a string and return the string where fully qualified idents
|
2002-03-27 08:20:32 -08:00
|
|
|
have been replaced by idents relative to the given module name.
|
|
|
|
Also remove the "hidden modules".*)
|
|
|
|
method relative_idents m_name s =
|
2008-07-23 01:55:36 -07:00
|
|
|
let f str_t =
|
2002-07-23 07:12:03 -07:00
|
|
|
let match_s = Str.matched_string str_t in
|
|
|
|
let rel = Name.get_relative m_name match_s in
|
|
|
|
Odoc_info.apply_if_equal Odoc_info.use_hidden_modules match_s rel
|
2002-03-27 08:20:32 -08:00
|
|
|
in
|
|
|
|
let s2 = Str.global_substitute
|
2002-07-23 07:12:03 -07:00
|
|
|
(Str.regexp "\\([A-Z]\\([a-zA-Z_'0-9]\\)*\\.\\)+\\([a-z][a-zA-Z_'0-9]*\\)")
|
|
|
|
f
|
|
|
|
s
|
2002-03-27 08:20:32 -08:00
|
|
|
in
|
|
|
|
s2
|
|
|
|
|
2008-07-23 01:55:36 -07:00
|
|
|
(** Take a string and return the string where fully qualified idents
|
2004-03-26 07:57:03 -08:00
|
|
|
have been replaced by idents relative to the given module name.
|
|
|
|
Also remove the "hidden modules".*)
|
|
|
|
method relative_module_idents m_name s =
|
2008-07-23 01:55:36 -07:00
|
|
|
let f str_t =
|
2004-03-26 07:57:03 -08:00
|
|
|
let match_s = Str.matched_string str_t in
|
|
|
|
let rel = Name.get_relative m_name match_s in
|
|
|
|
Odoc_info.apply_if_equal Odoc_info.use_hidden_modules match_s rel
|
|
|
|
in
|
|
|
|
let s2 = Str.global_substitute
|
|
|
|
(Str.regexp "\\([A-Z]\\([a-zA-Z_'0-9]\\)*\\.\\)+\\([A-Z][a-zA-Z_'0-9]*\\)")
|
|
|
|
f
|
|
|
|
s
|
|
|
|
in
|
|
|
|
s2
|
|
|
|
|
2002-04-05 01:20:29 -08:00
|
|
|
(** Get a string for a [Types.class_type] where all idents are relative. *)
|
|
|
|
method normal_class_type m_name t =
|
2004-08-20 10:04:35 -07:00
|
|
|
self#relative_idents m_name (Odoc_info.string_of_class_type t)
|
2002-04-05 01:20:29 -08:00
|
|
|
|
|
|
|
(** Get a string for a [Types.module_type] where all idents are relative. *)
|
2004-03-26 07:57:03 -08:00
|
|
|
method normal_module_type ?code m_name t =
|
2004-08-20 10:04:35 -07:00
|
|
|
self#relative_module_idents m_name (Odoc_info.string_of_module_type ?code t)
|
2002-04-05 01:20:29 -08:00
|
|
|
|
2002-03-27 08:20:32 -08:00
|
|
|
(** Get a string for a type where all idents are relative. *)
|
|
|
|
method normal_type m_name t =
|
2004-08-20 10:04:35 -07:00
|
|
|
self#relative_idents m_name (Odoc_info.string_of_type_expr t)
|
2002-03-27 08:20:32 -08:00
|
|
|
|
|
|
|
(** Get a string for a list of types where all idents are relative. *)
|
2004-03-22 07:06:31 -08:00
|
|
|
method normal_type_list ?par m_name sep t =
|
2004-08-20 10:04:35 -07:00
|
|
|
self#relative_idents m_name (Odoc_info.string_of_type_list ?par sep t)
|
2002-03-27 08:20:32 -08:00
|
|
|
|
2014-10-14 08:51:30 -07:00
|
|
|
method normal_cstr_args ?par m_name = function
|
|
|
|
| Cstr_tuple l -> self#normal_type_list ?par m_name " * " l
|
|
|
|
| Cstr_record _ -> "{...}" (* TODO *)
|
|
|
|
|
2003-10-17 08:30:47 -07:00
|
|
|
(** Get a string for a list of class or class type type parameters
|
|
|
|
where all idents are relative. *)
|
|
|
|
method normal_class_type_param_list m_name t =
|
2004-08-20 10:04:35 -07:00
|
|
|
self#relative_idents m_name (Odoc_info.string_of_class_type_param_list t)
|
|
|
|
|
|
|
|
(** Get a string for the parameters of a class (with arrows) where all idents are relative. *)
|
|
|
|
method normal_class_params m_name c =
|
|
|
|
let s = Odoc_info.string_of_class_params c in
|
2008-07-23 01:55:36 -07:00
|
|
|
self#relative_idents m_name
|
2010-01-22 04:48:24 -08:00
|
|
|
(Odoc_info.remove_ending_newline s)
|
2003-10-17 08:30:47 -07:00
|
|
|
|
2002-03-27 08:20:32 -08:00
|
|
|
(** @return [text] value to represent a [Types.type_expr].*)
|
|
|
|
method text_of_type_expr module_name t =
|
2008-07-23 01:55:36 -07:00
|
|
|
let t = List.flatten
|
2002-07-23 07:12:03 -07:00
|
|
|
(List.map
|
|
|
|
(fun s -> [Code s ; Newline ])
|
2008-07-23 01:55:36 -07:00
|
|
|
(Str.split (Str.regexp "\n")
|
2002-07-23 07:12:03 -07:00
|
|
|
(self#normal_type module_name t))
|
|
|
|
)
|
2002-03-27 08:20:32 -08:00
|
|
|
in
|
|
|
|
t
|
|
|
|
|
|
|
|
(** Return [text] value for a given short [Types.type_expr].*)
|
2008-07-23 01:55:36 -07:00
|
|
|
method text_of_short_type_expr module_name t =
|
2002-03-27 08:20:32 -08:00
|
|
|
[ Code (self#normal_type module_name t) ]
|
|
|
|
|
|
|
|
(** Return [text] value or the given list of [Types.type_expr], with
|
|
|
|
the given separator. *)
|
|
|
|
method text_of_type_expr_list module_name sep l =
|
2008-07-23 01:55:36 -07:00
|
|
|
[ Code (self#normal_type_list module_name sep l) ]
|
2002-03-27 08:20:32 -08:00
|
|
|
|
2008-07-23 01:55:36 -07:00
|
|
|
(** Return [text] value or the given list of [Types.type_expr],
|
2003-10-17 08:30:47 -07:00
|
|
|
as type parameters of a class of class type. *)
|
|
|
|
method text_of_class_type_param_expr_list module_name l =
|
2008-07-23 01:55:36 -07:00
|
|
|
[ Code (self#normal_class_type_param_list module_name l) ]
|
2003-10-17 08:30:47 -07:00
|
|
|
|
2004-08-20 10:04:35 -07:00
|
|
|
(** @return [text] value to represent parameters of a class (with arraows).*)
|
|
|
|
method text_of_class_params module_name c =
|
2008-07-23 01:55:36 -07:00
|
|
|
let t = Odoc_info.text_concat
|
2010-01-22 04:48:24 -08:00
|
|
|
[Newline]
|
2004-08-20 10:04:35 -07:00
|
|
|
(List.map
|
|
|
|
(fun s -> [Code s])
|
2010-01-22 04:48:24 -08:00
|
|
|
(Str.split (Str.regexp "\n")
|
2004-08-20 10:04:35 -07:00
|
|
|
(self#normal_class_params module_name c))
|
2010-01-22 04:48:24 -08:00
|
|
|
)
|
2004-08-20 10:04:35 -07:00
|
|
|
in
|
|
|
|
t
|
2002-03-27 08:20:32 -08:00
|
|
|
|
|
|
|
(** @return [text] value to represent a [Types.module_type]. *)
|
|
|
|
method text_of_module_type t =
|
|
|
|
let s = String.concat "\n"
|
2002-07-23 07:12:03 -07:00
|
|
|
(Str.split (Str.regexp "\n") (Odoc_info.string_of_module_type t))
|
2002-03-27 08:20:32 -08:00
|
|
|
in
|
|
|
|
[ Code s ]
|
2008-07-23 01:55:36 -07:00
|
|
|
|
2002-03-27 08:20:32 -08:00
|
|
|
(** @return [text] value for a value. *)
|
|
|
|
method text_of_value v =
|
2004-03-26 07:57:03 -08:00
|
|
|
let name = v.val_name in
|
|
|
|
let s_name = Name.simple name in
|
2008-07-23 01:55:36 -07:00
|
|
|
let s =
|
2010-01-22 04:48:24 -08:00
|
|
|
Format.fprintf Format.str_formatter "@[<hov 2>val %s :@ %s"
|
2003-09-12 17:40:31 -07:00
|
|
|
s_name
|
|
|
|
(self#normal_type (Name.father v.val_name) v.val_type);
|
2010-01-22 04:48:24 -08:00
|
|
|
Format.flush_str_formatter ()
|
2002-03-27 08:20:32 -08:00
|
|
|
in
|
2008-07-23 01:55:36 -07:00
|
|
|
[ CodePre s ] @
|
2004-07-13 05:25:21 -07:00
|
|
|
[Latex ("\\index{"^(self#label s_name)^"@\\verb`"^(self#label ~no_:false s_name)^"`}\n")] @
|
2002-03-27 08:20:32 -08:00
|
|
|
(self#text_of_info v.val_info)
|
|
|
|
|
|
|
|
(** @return [text] value for a class attribute. *)
|
|
|
|
method text_of_attribute a =
|
|
|
|
let s_name = Name.simple a.att_value.val_name in
|
|
|
|
let mod_name = Name.father a.att_value.val_name in
|
2008-07-23 01:55:36 -07:00
|
|
|
let s =
|
2010-01-22 04:48:24 -08:00
|
|
|
Format.fprintf Format.str_formatter "@[<hov 2>val %s%s%s :@ %s"
|
2008-07-23 01:55:36 -07:00
|
|
|
(if a.att_virtual then "virtual " else "")
|
2003-09-12 17:40:31 -07:00
|
|
|
(if a.att_mutable then "mutable " else "")
|
|
|
|
s_name
|
2010-01-22 04:48:24 -08:00
|
|
|
(self#normal_type mod_name a.att_value.val_type);
|
|
|
|
Format.flush_str_formatter ()
|
2003-09-12 17:40:31 -07:00
|
|
|
in
|
2008-07-23 01:55:36 -07:00
|
|
|
(CodePre s) ::
|
2002-03-27 08:20:32 -08:00
|
|
|
[Latex ("\\index{"^(self#label s_name)^"@\\verb`"^(self#label ~no_:false s_name)^"`}\n")] @
|
|
|
|
(self#text_of_info a.att_value.val_info)
|
|
|
|
|
|
|
|
(** @return [text] value for a class method. *)
|
|
|
|
method text_of_method m =
|
|
|
|
let s_name = Name.simple m.met_value.val_name in
|
|
|
|
let mod_name = Name.father m.met_value.val_name in
|
2008-07-23 01:55:36 -07:00
|
|
|
let s =
|
2010-01-22 04:48:24 -08:00
|
|
|
Format.fprintf Format.str_formatter "@[<hov 2>method %s%s%s :@ %s"
|
2003-09-12 17:40:31 -07:00
|
|
|
(if m.met_private then "private " else "")
|
|
|
|
(if m.met_virtual then "virtual " else "")
|
2008-07-23 01:55:36 -07:00
|
|
|
s_name
|
2010-01-22 04:48:24 -08:00
|
|
|
(self#normal_type mod_name m.met_value.val_type);
|
|
|
|
Format.flush_str_formatter ()
|
2003-09-12 17:40:31 -07:00
|
|
|
in
|
2002-03-27 08:20:32 -08:00
|
|
|
(CodePre s) ::
|
|
|
|
[Latex ("\\index{"^(self#label s_name)^"@\\verb`"^(self#label ~no_:false s_name)^"`}\n")] @
|
|
|
|
(self#text_of_info m.met_value.val_info)
|
|
|
|
|
|
|
|
|
|
|
|
(** @return [text] value for an exception. *)
|
|
|
|
method text_of_exception e =
|
|
|
|
let s_name = Name.simple e.ex_name in
|
2014-05-04 16:08:45 -07:00
|
|
|
let father = Name.father e.ex_name in
|
2002-03-27 08:20:32 -08:00
|
|
|
Format.fprintf Format.str_formatter "@[<hov 2>exception %s" s_name ;
|
2014-05-04 16:08:45 -07:00
|
|
|
(match e.ex_args, e.ex_ret with
|
2014-10-14 08:51:30 -07:00
|
|
|
Cstr_tuple [], None -> ()
|
|
|
|
| Cstr_tuple l, None ->
|
2014-05-04 16:08:45 -07:00
|
|
|
Format.fprintf Format.str_formatter " %s@ %s"
|
|
|
|
"of"
|
|
|
|
(self#normal_type_list ~par: false father " * " l)
|
2014-10-14 08:51:30 -07:00
|
|
|
| Cstr_tuple [], Some r ->
|
2014-05-04 16:08:45 -07:00
|
|
|
Format.fprintf Format.str_formatter " %s@ %s"
|
|
|
|
":"
|
|
|
|
(self#normal_type father r)
|
2014-10-14 08:51:30 -07:00
|
|
|
| Cstr_tuple l, Some r ->
|
2014-05-04 16:08:45 -07:00
|
|
|
Format.fprintf Format.str_formatter " %s@ %s@ %s@ %s"
|
|
|
|
":"
|
|
|
|
(self#normal_type_list ~par: false father " * " l)
|
|
|
|
"->"
|
|
|
|
(self#normal_type father r)
|
2014-10-14 08:51:30 -07:00
|
|
|
| Cstr_record _, _ ->
|
|
|
|
assert false
|
2014-05-04 16:08:45 -07:00
|
|
|
);
|
|
|
|
(match e.ex_alias with
|
|
|
|
None -> ()
|
|
|
|
| Some ea ->
|
|
|
|
Format.fprintf Format.str_formatter " = %s"
|
|
|
|
(
|
|
|
|
match ea.ea_ex with
|
|
|
|
None -> ea.ea_name
|
|
|
|
| Some e -> e.ex_name
|
|
|
|
)
|
|
|
|
);
|
|
|
|
let s2 = Format.flush_str_formatter () in
|
2002-03-27 08:20:32 -08:00
|
|
|
[ CodePre s2 ] @
|
|
|
|
[Latex ("\\index{"^(self#label s_name)^"@\\verb`"^(self#label ~no_:false s_name)^"`}\n")] @
|
|
|
|
(self#text_of_info e.ex_info)
|
|
|
|
|
|
|
|
(** Return [text] value for the description of a function parameter. *)
|
|
|
|
method text_of_parameter_description p =
|
|
|
|
match Parameter.names p with
|
2002-07-23 07:12:03 -07:00
|
|
|
[] -> []
|
2002-03-27 08:20:32 -08:00
|
|
|
| name :: [] ->
|
2002-07-23 07:12:03 -07:00
|
|
|
(
|
2002-03-27 08:20:32 -08:00
|
|
|
(* Only one name, no need for label for the description. *)
|
2002-07-23 07:12:03 -07:00
|
|
|
match Parameter.desc_by_name p name with
|
|
|
|
None -> []
|
|
|
|
| Some t -> t
|
|
|
|
)
|
2002-03-27 08:20:32 -08:00
|
|
|
| l ->
|
|
|
|
(* A list of names, we display those with a description. *)
|
2002-07-23 07:12:03 -07:00
|
|
|
let l2 = List.filter (fun n -> (Parameter.desc_by_name p n) <> None) l in
|
|
|
|
match l2 with
|
|
|
|
[] -> []
|
|
|
|
| _ ->
|
|
|
|
[List
|
|
|
|
(List.map
|
|
|
|
(fun n ->
|
|
|
|
match Parameter.desc_by_name p n with
|
|
|
|
None -> [] (* should not occur *)
|
|
|
|
| Some t -> [Code (n^" ") ; Raw ": "] @ t
|
|
|
|
)
|
|
|
|
l2
|
|
|
|
)
|
2008-07-23 01:55:36 -07:00
|
|
|
]
|
2002-03-27 08:20:32 -08:00
|
|
|
|
|
|
|
|
|
|
|
(** Return [text] value for a list of parameters. *)
|
|
|
|
method text_of_parameter_list m_name l =
|
|
|
|
match l with
|
2002-07-23 07:12:03 -07:00
|
|
|
[] ->
|
|
|
|
[]
|
2002-03-27 08:20:32 -08:00
|
|
|
| _ ->
|
2002-07-23 07:12:03 -07:00
|
|
|
[ Bold [Raw Odoc_messages.parameters] ;
|
|
|
|
Raw ":" ;
|
|
|
|
List
|
|
|
|
(List.map
|
|
|
|
(fun p ->
|
|
|
|
(match Parameter.complete_name p with
|
|
|
|
"" -> Code "?"
|
|
|
|
| s -> Code s
|
|
|
|
) ::
|
|
|
|
[Code " : "] @
|
2008-07-23 01:55:36 -07:00
|
|
|
(self#text_of_short_type_expr m_name (Parameter.typ p)) @
|
2002-07-23 07:12:03 -07:00
|
|
|
[Newline] @
|
|
|
|
(self#text_of_parameter_description p)
|
|
|
|
)
|
|
|
|
l
|
|
|
|
)
|
2008-07-23 01:55:36 -07:00
|
|
|
]
|
2002-03-27 08:20:32 -08:00
|
|
|
|
|
|
|
(** Return [text] value for a list of module parameters. *)
|
|
|
|
method text_of_module_parameter_list l =
|
|
|
|
match l with
|
2002-07-23 07:12:03 -07:00
|
|
|
[] ->
|
|
|
|
[]
|
2002-03-27 08:20:32 -08:00
|
|
|
| _ ->
|
2008-07-23 01:55:36 -07:00
|
|
|
[ Newline ;
|
2002-07-23 07:12:03 -07:00
|
|
|
Bold [Raw Odoc_messages.parameters] ;
|
|
|
|
Raw ":" ;
|
|
|
|
List
|
|
|
|
(List.map
|
|
|
|
(fun (p, desc_opt) ->
|
2013-12-16 19:52:50 -08:00
|
|
|
begin match p.mp_type with None -> [Raw ""]
|
|
|
|
| Some mty ->
|
|
|
|
[Code (p.mp_name^" : ")] @
|
|
|
|
(self#text_of_module_type mty)
|
|
|
|
end @
|
2002-07-23 07:12:03 -07:00
|
|
|
(match desc_opt with
|
|
|
|
None -> []
|
|
|
|
| Some t -> (Raw " ") :: t)
|
|
|
|
)
|
|
|
|
l
|
|
|
|
)
|
2008-07-23 01:55:36 -07:00
|
|
|
]
|
2002-03-27 08:20:32 -08:00
|
|
|
|
2002-04-05 01:20:29 -08:00
|
|
|
(**/**)
|
|
|
|
|
2002-03-27 08:20:32 -08:00
|
|
|
(** Return [text] value for the given [class_kind].*)
|
2002-04-03 04:56:09 -08:00
|
|
|
method text_of_class_kind father ckind =
|
2002-03-27 08:20:32 -08:00
|
|
|
match ckind with
|
2008-07-23 01:55:36 -07:00
|
|
|
Class_structure _ ->
|
2002-07-23 07:12:03 -07:00
|
|
|
[Code Odoc_messages.object_end]
|
|
|
|
|
|
|
|
| Class_apply capp ->
|
2008-07-23 01:55:36 -07:00
|
|
|
[Code
|
2002-07-23 07:12:03 -07:00
|
|
|
(
|
|
|
|
(
|
|
|
|
match capp.capp_class with
|
|
|
|
None -> capp.capp_name
|
|
|
|
| Some cl -> cl.cl_name
|
|
|
|
)^
|
|
|
|
" "^
|
|
|
|
(String.concat " "
|
|
|
|
(List.map
|
|
|
|
(fun s -> "("^s^")")
|
|
|
|
capp.capp_params_code))
|
|
|
|
)
|
2008-07-23 01:55:36 -07:00
|
|
|
]
|
|
|
|
|
2002-07-23 07:12:03 -07:00
|
|
|
| Class_constr cco ->
|
|
|
|
(
|
|
|
|
match cco.cco_type_parameters with
|
|
|
|
[] -> []
|
2008-07-23 01:55:36 -07:00
|
|
|
| l ->
|
2002-07-23 07:12:03 -07:00
|
|
|
(Code "[")::
|
|
|
|
(self#text_of_type_expr_list father ", " l)@
|
|
|
|
[Code "] "]
|
|
|
|
)@
|
|
|
|
[Code (
|
|
|
|
match cco.cco_class with
|
|
|
|
None -> cco.cco_name
|
|
|
|
| Some (Cl cl) -> Name.get_relative father cl.cl_name
|
|
|
|
| Some (Cltype (clt,_)) -> Name.get_relative father clt.clt_name
|
|
|
|
)
|
2008-07-23 01:55:36 -07:00
|
|
|
]
|
2002-07-23 07:12:03 -07:00
|
|
|
|
|
|
|
| Class_constraint (ck, ctk) ->
|
|
|
|
[Code "( "] @
|
|
|
|
(self#text_of_class_kind father ck) @
|
|
|
|
[Code " : "] @
|
|
|
|
(self#text_of_class_type_kind father ctk) @
|
|
|
|
[Code " )"]
|
2002-03-27 08:20:32 -08:00
|
|
|
|
|
|
|
|
|
|
|
(** Return [text] value for the given [class_type_kind].*)
|
2002-04-03 04:56:09 -08:00
|
|
|
method text_of_class_type_kind father ctkind =
|
2002-03-27 08:20:32 -08:00
|
|
|
match ctkind with
|
2008-07-23 01:55:36 -07:00
|
|
|
Class_type cta ->
|
2002-07-23 07:12:03 -07:00
|
|
|
(
|
|
|
|
match cta.cta_type_parameters with
|
|
|
|
[] -> []
|
2008-07-23 01:55:36 -07:00
|
|
|
| l ->
|
2002-07-23 07:12:03 -07:00
|
|
|
(Code "[") ::
|
2003-10-17 08:30:47 -07:00
|
|
|
(self#text_of_class_type_param_expr_list father l) @
|
2002-07-23 07:12:03 -07:00
|
|
|
[Code "] "]
|
|
|
|
) @
|
|
|
|
(
|
|
|
|
match cta.cta_class with
|
|
|
|
None -> [ Code cta.cta_name ]
|
2008-07-23 01:55:36 -07:00
|
|
|
| Some (Cltype (clt, _)) ->
|
|
|
|
let rel = Name.get_relative father clt.clt_name in
|
2002-07-23 07:12:03 -07:00
|
|
|
[Code rel]
|
2008-07-23 01:55:36 -07:00
|
|
|
| Some (Cl cl) ->
|
2002-07-23 07:12:03 -07:00
|
|
|
let rel = Name.get_relative father cl.cl_name in
|
|
|
|
[Code rel]
|
|
|
|
)
|
|
|
|
| Class_signature _ ->
|
|
|
|
[Code Odoc_messages.object_end]
|
2008-07-23 01:55:36 -07:00
|
|
|
|
2002-03-27 08:20:32 -08:00
|
|
|
(** Return [text] value for a [module_kind]. *)
|
|
|
|
method text_of_module_kind ?(with_def_syntax=true) k =
|
|
|
|
match k with
|
2002-07-23 07:12:03 -07:00
|
|
|
Module_alias m_alias ->
|
|
|
|
(match m_alias.ma_module with
|
|
|
|
None ->
|
|
|
|
[Code ((if with_def_syntax then " = " else "")^m_alias.ma_name)]
|
|
|
|
| Some (Mod m) ->
|
|
|
|
[Code ((if with_def_syntax then " = " else "")^m.m_name)]
|
|
|
|
| Some (Modtype mt) ->
|
|
|
|
[Code ((if with_def_syntax then " = " else "")^mt.mt_name)]
|
|
|
|
)
|
2002-03-27 08:20:32 -08:00
|
|
|
| Module_apply (k1, k2) ->
|
2002-07-23 07:12:03 -07:00
|
|
|
(if with_def_syntax then [Code " = "] else []) @
|
|
|
|
(self#text_of_module_kind ~with_def_syntax: false k1) @
|
|
|
|
[Code " ( "] @
|
|
|
|
(self#text_of_module_kind ~with_def_syntax: false k2) @
|
|
|
|
[Code " ) "]
|
2008-07-23 01:55:36 -07:00
|
|
|
|
2002-03-27 08:20:32 -08:00
|
|
|
| Module_with (tk, code) ->
|
2002-07-23 07:12:03 -07:00
|
|
|
(if with_def_syntax then [Code " : "] else []) @
|
|
|
|
(self#text_of_module_type_kind ~with_def_syntax: false tk) @
|
|
|
|
[Code code]
|
2008-07-23 01:55:36 -07:00
|
|
|
|
2002-03-27 08:20:32 -08:00
|
|
|
| Module_constraint (k, tk) ->
|
2002-07-23 07:12:03 -07:00
|
|
|
(if with_def_syntax then [Code " : "] else []) @
|
|
|
|
[Code "( "] @
|
|
|
|
(self#text_of_module_kind ~with_def_syntax: false k) @
|
|
|
|
[Code " : "] @
|
|
|
|
(self#text_of_module_type_kind ~with_def_syntax: false tk) @
|
|
|
|
[Code " )"]
|
2008-07-23 01:55:36 -07:00
|
|
|
|
2002-03-27 08:20:32 -08:00
|
|
|
| Module_struct _ ->
|
2002-07-23 07:12:03 -07:00
|
|
|
[Code ((if with_def_syntax then " : " else "")^
|
|
|
|
Odoc_messages.struct_end^" ")]
|
2002-03-27 08:20:32 -08:00
|
|
|
|
2004-04-02 07:10:58 -08:00
|
|
|
| Module_functor (p, k) ->
|
2002-07-23 07:12:03 -07:00
|
|
|
(if with_def_syntax then [Code " : "] else []) @
|
|
|
|
[Code "functor ... "] @
|
|
|
|
[Code " -> "] @
|
|
|
|
(self#text_of_module_kind ~with_def_syntax: false k)
|
2002-03-27 08:20:32 -08:00
|
|
|
|
2010-04-19 09:48:42 -07:00
|
|
|
| Module_typeof s ->
|
|
|
|
let code = Printf.sprintf "%smodule type of %s"
|
|
|
|
(if with_def_syntax then " : " else "")
|
|
|
|
s
|
|
|
|
in
|
|
|
|
[Code code]
|
2010-05-03 08:06:17 -07:00
|
|
|
| Module_unpack (code, _) ->
|
|
|
|
let code = Printf.sprintf "%s%s"
|
|
|
|
(if with_def_syntax then " : " else "")
|
|
|
|
code
|
|
|
|
in
|
|
|
|
[Code code]
|
2010-04-19 09:48:42 -07:00
|
|
|
|
2004-04-02 07:10:58 -08:00
|
|
|
(** Return html code for a [module_type_kind].*)
|
2002-03-27 08:20:32 -08:00
|
|
|
method text_of_module_type_kind ?(with_def_syntax=true) tk =
|
|
|
|
match tk with
|
|
|
|
| Module_type_struct _ ->
|
2002-07-23 07:12:03 -07:00
|
|
|
[Code ((if with_def_syntax then " = " else "")^Odoc_messages.sig_end)]
|
2002-03-27 08:20:32 -08:00
|
|
|
|
2004-04-02 07:10:58 -08:00
|
|
|
| Module_type_functor (p, k) ->
|
|
|
|
let t1 =
|
2010-01-22 04:48:24 -08:00
|
|
|
[Code ("("^p.mp_name^" : ")] @
|
2004-04-02 07:10:58 -08:00
|
|
|
(self#text_of_module_type_kind p.mp_kind) @
|
2002-07-23 07:12:03 -07:00
|
|
|
[Code ") -> "]
|
|
|
|
in
|
|
|
|
let t2 = self#text_of_module_type_kind ~with_def_syntax: false k in
|
|
|
|
(if with_def_syntax then [Code " = "] else []) @ t1 @ t2
|
2008-07-23 01:55:36 -07:00
|
|
|
|
|
|
|
| Module_type_with (tk2, code) ->
|
2002-07-23 07:12:03 -07:00
|
|
|
let t = self#text_of_module_type_kind ~with_def_syntax: false tk2 in
|
|
|
|
(if with_def_syntax then [Code " = "] else []) @
|
|
|
|
t @ [Code code]
|
2002-03-27 08:20:32 -08:00
|
|
|
|
|
|
|
| Module_type_alias mt_alias ->
|
2002-07-23 07:12:03 -07:00
|
|
|
[Code ((if with_def_syntax then " = " else "")^
|
|
|
|
(match mt_alias.mta_module with
|
|
|
|
None -> mt_alias.mta_name
|
|
|
|
| Some mt -> mt.mt_name))
|
2008-07-23 01:55:36 -07:00
|
|
|
]
|
2002-03-27 08:20:32 -08:00
|
|
|
|
2010-04-19 09:34:13 -07:00
|
|
|
| Odoc_module.Module_type_typeof s ->
|
|
|
|
let code = Printf.sprintf "%smodule type of %s"
|
|
|
|
(if with_def_syntax then " = " else "") s
|
|
|
|
in
|
|
|
|
[ Code code ]
|
2002-03-27 08:20:32 -08:00
|
|
|
end
|