summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ocamldoc/Changes.txt6
-rw-r--r--ocamldoc/Makefile1
-rw-r--r--ocamldoc/odoc_ast.ml20
-rw-r--r--ocamldoc/odoc_html.ml166
-rw-r--r--ocamldoc/odoc_info.mli27
-rw-r--r--ocamldoc/odoc_latex.ml63
-rw-r--r--ocamldoc/odoc_module.ml116
-rw-r--r--ocamldoc/odoc_parameter.ml11
-rw-r--r--ocamldoc/odoc_sig.ml34
-rw-r--r--ocamldoc/odoc_to_text.ml13
10 files changed, 264 insertions, 193 deletions
diff --git a/ocamldoc/Changes.txt b/ocamldoc/Changes.txt
index 45ce12207..5ebd21f0f 100644
--- a/ocamldoc/Changes.txt
+++ b/ocamldoc/Changes.txt
@@ -44,7 +44,11 @@ OK - fix: bad display of type parameters for class and class types
TODO:
- need to fix display of type parameters for inherited classes/class types
-
+OK - add the kind to module parameters (the way the parameter was build in the parsetree)
+ - generate html from module_kind rather than from module_type
+ + pareil pour les classes et class types
+OK + utilisation de blocs div pour indenter
+ - latex: style latex pour indenter dans les module kind
======
diff --git a/ocamldoc/Makefile b/ocamldoc/Makefile
index 4eae3b525..2c7f3db50 100644
--- a/ocamldoc/Makefile
+++ b/ocamldoc/Makefile
@@ -324,6 +324,7 @@ test_latex: dummy
test_latex_simple: dummy
$(MKDIR) $@
$(OCAMLDOC_RUN) -latex -sort -o $@/test.tex -d $@ $(INCLUDES) \
+ -latextitle 6,subsection -latextitle 7,subsubection \
../stdlib/hashtbl.mli \
../stdlib/arg.mli \
../otherlibs/unix/unix.mli \
diff --git a/ocamldoc/odoc_ast.ml b/ocamldoc/odoc_ast.ml
index e433025ac..253ccc739 100644
--- a/ocamldoc/odoc_ast.ml
+++ b/ocamldoc/odoc_ast.ml
@@ -1425,14 +1425,20 @@ module Analyser =
let loc_start = pmodule_type.Parsetree.pmty_loc.Location.loc_start.Lexing.pos_cnum in
let loc_end = pmodule_type.Parsetree.pmty_loc.Location.loc_end.Lexing.pos_cnum in
let mp_type_code = get_string_of_file loc_start loc_end in
- print_DEBUG (Printf.sprintf "mp_type_code=%s" mp_type_code);
+ print_DEBUG (Printf.sprintf "mp_type_code=%s" mp_type_code);
+ let mp_name = Name.from_ident ident in
+ let mp_kind = Sig.analyse_module_type_kind env
+ current_module_name pmodule_type mtyp
+ in
let param =
{
- mp_name = Name.from_ident ident ;
+ mp_name = mp_name ;
mp_type = Odoc_env.subst_module_type env mtyp ;
- mp_type_code = mp_type_code ;
+ mp_type_code = mp_type_code ;
+ mp_kind = mp_kind ;
}
in
+ (* TODO: A VOIR CE __ *)
let dummy_complete_name = Name.concat "__" param.mp_name in
let new_env = Odoc_env.add_module env dummy_complete_name in
let m_base2 = analyse_module
@@ -1443,12 +1449,8 @@ module Analyser =
p_module_expr2
tt_module_expr2
in
- let kind =
- match m_base2.m_kind with
- Module_functor (params, k) -> Module_functor (param :: params, m_base2.m_kind)
- | k -> Module_functor ([param], k)
- in
- { m_base with m_kind = kind }
+ let kind = m_base2.m_kind in
+ { m_base with m_kind = Module_functor (param, kind) }
| (Parsetree.Pmod_apply (p_module_expr1, p_module_expr2),
Typedtree.Tmod_apply (tt_module_expr1, tt_module_expr2, _))
diff --git a/ocamldoc/odoc_html.ml b/ocamldoc/odoc_html.ml
index d81138ba0..fa368e446 100644
--- a/ocamldoc/odoc_html.ml
+++ b/ocamldoc/odoc_html.ml
@@ -670,6 +670,8 @@ class html =
"tr { background-color : White }" ;
"td.typefieldcomment { background-color : #FFFFFF }" ;
"pre { margin-bottom: 4px }" ;
+
+ "div.sig_block {margin-left: 2em}" ;
]
(** The style file for all pages. *)
@@ -1034,6 +1036,115 @@ class html =
bs b (self#create_fully_qualified_module_idents_links m_name s);
bs b "</code>"
+ (** Print html code to display the given module kind. *)
+ method html_of_module_kind b father ?modu kind =
+ match kind with
+ Module_struct eles ->
+ self#html_of_text b [Code "sig"];
+ (
+ match modu with
+ None ->
+ bs b "<div class=\"sig_block\">";
+ List.iter (self#html_of_module_element b father) eles;
+ bs b "</div>"
+ | Some m ->
+ let (html_file, _) = Naming.html_files m.m_name in
+ bp b " <a href=\"%s\">..</a> " html_file
+ );
+ self#html_of_text b [Code "end"]
+ | Module_alias a ->
+ bs b "<code class=\"type\">";
+ bs b (self#create_fully_qualified_module_idents_links father a.ma_name);
+ bs b "</code>"
+ | Module_functor (p, k) ->
+ bs b "<div class=\"sig_block\">";
+ self#html_of_module_parameter b father p;
+ self#html_of_module_kind b father ?modu k;
+ bs b "</div>"
+ | Module_apply (k1, k2) ->
+ (* TODO: l'application n'est pas correcte dans un .mli.
+ Que faire ? -> afficher le module_type du typedtree *)
+ self#html_of_module_kind b father k1;
+ self#html_of_text b [Code "("];
+ self#html_of_module_kind b father k2;
+ self#html_of_text b [Code ")"]
+ | Module_with (k, s) ->
+ (* TODO: à modifier quand Module_with sera plus détaillé *)
+ self#html_of_module_type_kind b father ?modu k;
+ bs b "<code class=\"type\"> ";
+ bs b (self#create_fully_qualified_module_idents_links father s);
+ bs b "</code>"
+ | Module_constraint (k, tk) ->
+ (* TODO: on affiche quoi ? *)
+ self#html_of_module_kind b father ?modu k
+
+ method html_of_module_parameter b father p =
+ self#html_of_text b
+ [
+ Code "functor (";
+ Code p.mp_name ;
+ Code " : ";
+ ] ;
+ self#html_of_module_type_kind b father p.mp_kind;
+ self#html_of_text b [ Code ") -> "]
+
+ method html_of_module_element b father ele =
+ match ele with
+ Element_module m ->
+ self#html_of_module b ~complete: false m
+ | Element_module_type mt ->
+ self#html_of_modtype b ~complete: false mt
+ | Element_included_module im ->
+ self#html_of_included_module b im
+ | Element_class c ->
+ self#html_of_class b ~complete: false c
+ | Element_class_type ct ->
+ self#html_of_class_type b ~complete: false ct
+ | Element_value v ->
+ self#html_of_value b v
+ | Element_exception e ->
+ self#html_of_exception b e
+ | Element_type t ->
+ self#html_of_type b t
+ | Element_module_comment text ->
+ self#html_of_module_comment b text
+
+ (** Print html code to display the given module type kind. *)
+ method html_of_module_type_kind b father ?modu ?mt kind =
+ match kind with
+ Module_type_struct eles ->
+ self#html_of_text b [Code "sig"];
+ (
+ match mt with
+ None ->
+ (
+ match modu with
+ None ->
+ bs b "<div class=\"sig_block\">";
+ List.iter (self#html_of_module_element b father) eles;
+ bs b "</div>"
+ | Some m ->
+ let (html_file, _) = Naming.html_files m.m_name in
+ bp b " <a href=\"%s\">..</a> " html_file
+ )
+ | Some mt ->
+ let (html_file, _) = Naming.html_files mt.mt_name in
+ bp b " <a href=\"%s\">..</a> " html_file
+ );
+ self#html_of_text b [Code "end"]
+ | Module_type_functor (p, k) ->
+ self#html_of_module_parameter b father p;
+ self#html_of_module_type_kind b father ?modu ?mt k
+ | Module_type_alias a ->
+ bs b "<code class=\"type\">";
+ bs b (self#create_fully_qualified_module_idents_links father a.mta_name);
+ bs b "</code>"
+ | Module_type_with (k, s) ->
+ self#html_of_module_type_kind b father ?modu ?mt k;
+ bs b "<code class=\"type\"> ";
+ bs b (self#create_fully_qualified_module_idents_links father s);
+ bs b "</code>"
+
(** Print html code to display the type of a module parameter.. *)
method html_of_module_parameter_type b m_name p =
self#html_of_module_type b m_name ~code: p.mp_type_code p.mp_type
@@ -1415,7 +1526,7 @@ class html =
bs b (Name.simple m.m_name)
);
bs b ": ";
- self#html_of_module_type b father m.m_type;
+ self#html_of_module_kind b father ~modu: m m.m_kind;
bs b "</pre>";
if info then
(
@@ -1439,11 +1550,11 @@ class html =
else
bs b (Name.simple mt.mt_name)
);
- (match mt.mt_type with
+ (match mt.mt_kind with
None -> ()
- | Some mtyp ->
+ | Some k ->
bs b " = ";
- self#html_of_module_type b father mtyp
+ self#html_of_module_type_kind b father ~mt k
);
bs b "</pre>";
if info then
@@ -1873,28 +1984,8 @@ class html =
(* a horizontal line *)
bs b "<hr width=\"100%\">\n";
(* module elements *)
- List.iter
- (fun ele ->
- match ele with
- Element_module m ->
- self#html_of_module b ~complete: false m
- | Element_module_type mt ->
- self#html_of_modtype b ~complete: false mt
- | Element_included_module im ->
- self#html_of_included_module b im
- | Element_class c ->
- self#html_of_class b ~complete: false c
- | Element_class_type ct ->
- self#html_of_class_type b ~complete: false ct
- | Element_value v ->
- self#html_of_value b v
- | Element_exception e ->
- self#html_of_exception b e
- | Element_type t ->
- self#html_of_type b t
- | Element_module_comment text ->
- self#html_of_module_comment b text
- )
+ List.iter
+ (self#html_of_module_element b (Name.father mt.mt_name))
(Module.module_type_elements mt);
bs b "</body></html>";
@@ -1971,28 +2062,7 @@ class html =
(* module elements *)
List.iter
- (fun ele ->
- print_DEBUG "html#generate_for_module : ele ->";
- match ele with
- Element_module m ->
- self#html_of_module b ~complete: false m
- | Element_module_type mt ->
- self#html_of_modtype b ~complete: false mt
- | Element_included_module im ->
- self#html_of_included_module b im
- | Element_class c ->
- self#html_of_class b ~complete: false c
- | Element_class_type ct ->
- self#html_of_class_type b ~complete: false ct
- | Element_value v ->
- self#html_of_value b v
- | Element_exception e ->
- self#html_of_exception b e
- | Element_type t ->
- self#html_of_type b t
- | Element_module_comment text ->
- self#html_of_module_comment b text
- )
+ (self#html_of_module_element b (Name.father modu.m_name))
(Module.module_elements modu);
bs b "</body></html>";
diff --git a/ocamldoc/odoc_info.mli b/ocamldoc/odoc_info.mli
index 63300bdd4..74c8d59d3 100644
--- a/ocamldoc/odoc_info.mli
+++ b/ocamldoc/odoc_info.mli
@@ -138,14 +138,6 @@ module Parameter :
(** A parameter is just a param_info.*)
type parameter = param_info
- (** A module parameter is just a name and a module type.*)
- type module_parameter = Odoc_parameter.module_parameter =
- {
- mp_name : string ;
- mp_type : Types.module_type ;
- mp_type_code : string ;
- }
-
(** {3 Functions} *)
(** Acces to the name as a string. For tuples, parenthesis and commas are added. *)
val complete_name : parameter -> string
@@ -423,12 +415,19 @@ module 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 ; (** the type *)
+ mp_type_code : string ; (** the original code *)
+ mp_kind : module_type_kind ; (** the way the parameter was built *)
+ }
+
(** Different kinds of a module. *)
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 (Parameter.module_parameter list) * module_kind
- (** A functor, with {e all} its parameters and the rest of its definition *)
+ | 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
@@ -461,8 +460,8 @@ module Module :
(** Different kinds of module type. *)
and module_type_kind = Odoc_module.module_type_kind =
| Module_type_struct of module_element list (** A complete module signature. *)
- | Module_type_functor of (Odoc_parameter.module_parameter list) * module_type_kind
- (** A functor, with {e all} its parameters and the rest of its definition *)
+ | 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
@@ -525,7 +524,7 @@ module Module :
val module_is_functor : t_module -> bool
(** The list of couples (module parameter, optional description). *)
- val module_parameters : ?trans:bool-> t_module -> (Parameter.module_parameter * text option) list
+ val module_parameters : ?trans:bool-> t_module -> (module_parameter * text option) list
(** The list of module comments. *)
val module_comments : ?trans:bool-> t_module -> text list
@@ -572,7 +571,7 @@ module Module :
val module_type_is_functor : t_module_type -> bool
(** The list of couples (module parameter, optional description). *)
- val module_type_parameters : ?trans:bool-> t_module_type -> (Parameter.module_parameter * text option) list
+ val module_type_parameters : ?trans:bool-> t_module_type -> (module_parameter * text option) list
(** The list of module comments. *)
val module_type_comments : ?trans:bool-> t_module_type -> text list
diff --git a/ocamldoc/odoc_latex.ml b/ocamldoc/odoc_latex.ml
index 5eb63df1e..39d1c9c73 100644
--- a/ocamldoc/odoc_latex.ml
+++ b/ocamldoc/odoc_latex.ml
@@ -214,11 +214,11 @@ class text =
(** Return latex code for the ref to a given label. *)
method make_ref label = "\\ref{"^label^"}"
- (** Return the LaTeX code corresponding to the [text] parameter.*)
+ (** Print the LaTeX code corresponding to the [text] parameter.*)
method latex_of_text fmt t =
List.iter (self#latex_of_text_element fmt) t
- (** Return the LaTeX code for the [text_element] in parameter. *)
+ (** Print the LaTeX code for the [text_element] in parameter. *)
method latex_of_text_element fmt te =
match te with
| Odoc_info.Raw s -> self#latex_of_Raw fmt s
@@ -388,7 +388,7 @@ class virtual info =
(** The method used to get a [text] from an optionel info structure. *)
method virtual text_of_info : ?block: bool -> Odoc_info.info option -> Odoc_info.text
- (** Return LaTeX code for a description, except for the [i_params] field. *)
+ (** Print LaTeX code for a description, except for the [i_params] field. *)
method latex_of_info fmt info_opt =
self#latex_of_text fmt
(self#text_of_info ~block: false info_opt)
@@ -419,7 +419,7 @@ class latex =
let (_, rest) = Odoc_info.first_sentence_and_rest_of_text (self#text_of_info ~block: false i_opt) in
(Odoc_info.text_no_title_no_list first, rest)
- (** Return LaTeX code for a value. *)
+ (** Print LaTeX code for a value. *)
method latex_of_value fmt v =
Odoc_info.reset_type_names () ;
let label = self#value_label v.val_name in
@@ -428,19 +428,19 @@ class latex =
((Latex latex) ::
(to_text#text_of_value v))
- (** Return LaTeX code for a class attribute. *)
+ (** Print LaTeX code for a class attribute. *)
method latex_of_attribute fmt a =
self#latex_of_text fmt
((Latex (self#make_label (self#attribute_label a.att_value.val_name))) ::
(to_text#text_of_attribute a))
- (** Return LaTeX code for a class method. *)
+ (** Print LaTeX code for a class method. *)
method latex_of_method fmt m =
self#latex_of_text fmt
((Latex (self#make_label (self#method_label m.met_value.val_name))) ::
(to_text#text_of_method m))
- (** Return LaTeX code for the parameters of a type. *)
+ (** Print LaTeX code for the parameters of a type. *)
method latex_of_type_params fmt m_name t =
let print_one (p, co, cn) =
ps fmt (Odoc_info.string_of_variance t (co,cn));
@@ -454,7 +454,7 @@ class latex =
print_concat fmt ", " print_one t.ty_parameters;
ps fmt ")"
- (** Return LaTeX code for a type. *)
+ (** Print LaTeX code for a type. *)
method latex_of_type fmt t =
let s_name = Name.simple t.ty_name in
let text =
@@ -564,25 +564,22 @@ class latex =
self#latex_of_text fmt
((Latex (self#make_label (self#type_label t.ty_name))) :: text)
- (** Return LaTeX code for an exception. *)
+ (** Print LaTeX code for an exception. *)
method latex_of_exception fmt e =
Odoc_info.reset_type_names () ;
self#latex_of_text fmt
((Latex (self#make_label (self#exception_label e.ex_name))) ::
(to_text#text_of_exception e))
- method latex_of_module_parameter_list fmt m_name l =
- let f p =
- self#latex_of_text fmt
- [
- Code "functor (";
- Code p.mp_name ;
- Code " : ";
- Code (self#normal_module_type ~code: p.mp_type_code m_name p.mp_type);
- Code ") -> "
- ]
- in
- List.iter f l
+ method latex_of_module_parameter fmt m_name p =
+ self#latex_of_text fmt
+ [
+ Code "functor (";
+ Code p.mp_name ;
+ Code " : ";
+ ] ;
+ self#latex_of_module_type_kind fmt m_name p.mp_kind;
+ self#latex_of_text fmt [ Code ") -> "]
method latex_of_module_type_kind fmt father kind =
@@ -591,8 +588,8 @@ class latex =
self#latex_of_text fmt [Code "sig\n"];
List.iter (self#latex_of_module_element fmt father) eles;
self#latex_of_text fmt [Code "end"]
- | Module_type_functor (l, k) ->
- self#latex_of_module_parameter_list fmt father l;
+ | Module_type_functor (p, k) ->
+ self#latex_of_module_parameter fmt father p;
self#latex_of_module_type_kind fmt father k
| Module_type_alias a ->
self#latex_of_text fmt
@@ -613,8 +610,8 @@ class latex =
| Module_alias a ->
self#latex_of_text fmt
[Code (self#relative_module_idents father a.ma_name)]
- | Module_functor (l, k) ->
- self#latex_of_module_parameter_list fmt father l;
+ | Module_functor (p, k) ->
+ self#latex_of_module_parameter fmt father p;
self#latex_of_module_kind fmt father k
| Module_apply (k1, k2) ->
(* TODO: l'application n'est pas correcte dans un .mli.
@@ -732,7 +729,7 @@ class latex =
method latex_for_class_type_label fmt ct =
ps fmt (self#make_label (self#class_type_label ct.clt_name))
- (** Return the LaTeX code for the given module. *)
+ (** Print the LaTeX code for the given module. *)
method latex_of_module fmt m =
let father = Name.father m.m_name in
let t =
@@ -780,7 +777,7 @@ class latex =
p fmt "@]";
- (** Return the LaTeX code for the given module type. *)
+ (** Print the LaTeX code for the given module type. *)
method latex_of_module_type fmt mt =
let father = Name.father mt.mt_name in
let t =
@@ -835,7 +832,7 @@ class latex =
self#latex_of_info fmt mt.mt_info;
p fmt "@]";
- (** Return the LaTeX code for the given included module. *)
+ (** Print the LaTeX code for the given included module. *)
method latex_of_included_module fmt im =
self#latex_of_text fmt
((Code "include ") ::
@@ -848,7 +845,7 @@ class latex =
(self#text_of_info im.im_info)
)
- (** Return the LaTeX code for the given class. *)
+ (** Print the LaTeX code for the given class. *)
method latex_of_class fmt c =
Odoc_info.reset_type_names () ;
let father = Name.father c.cl_name in
@@ -879,7 +876,7 @@ class latex =
self#latex_of_info fmt c.cl_info;
p fmt "@]"
- (** Return the LaTeX code for the given class type. *)
+ (** Print the LaTeX code for the given class type. *)
method latex_of_class_type fmt ct =
Odoc_info.reset_type_names () ;
let father = Name.father ct.clt_name in
@@ -910,7 +907,7 @@ class latex =
self#latex_of_info fmt ct.clt_info;
p fmt "@]"
- (** Return the LaTeX code for the given class element. *)
+ (** Print the LaTeX code for the given class element. *)
method latex_of_class_element fmt class_name class_ele =
self#latex_of_text fmt [Newline];
match class_ele with
@@ -922,7 +919,7 @@ class latex =
| (Title (_,_,_)) :: _ -> self#latex_of_text fmt t
| _ -> self#latex_of_text fmt [ Title ((Name.depth class_name) + 2, None, t) ]
- (** Return the LaTeX code for the given module element. *)
+ (** Print the LaTeX code for the given module element. *)
method latex_of_module_element fmt module_name module_ele =
self#latex_of_text fmt [Newline];
match module_ele with
@@ -1022,7 +1019,7 @@ class latex =
)
(Module.module_elements ~trans: false m)
- (** Return the header of the TeX document. *)
+ (** Print the header of the TeX document. *)
method latex_header fmt =
ps fmt "\\documentclass[11pt]{article} \n";
ps fmt "\\usepackage[latin1]{inputenc} \n";
diff --git a/ocamldoc/odoc_module.ml b/ocamldoc/odoc_module.ml
index c3a0a6af9..a12545b23 100644
--- a/ocamldoc/odoc_module.ml
+++ b/ocamldoc/odoc_module.ml
@@ -45,11 +45,18 @@ and module_alias = {
mutable ma_module : mmt option ; (** the real module or module type if we could associate it *)
}
+and module_parameter = {
+ mp_name : string ; (** the name *)
+ mp_type : Types.module_type ; (** the type *)
+ mp_type_code : string ; (** the original code *)
+ mp_kind : module_type_kind ; (** the way the parameter was built *)
+ }
+
(** Different kinds of module. *)
and module_kind =
| Module_struct of module_element list
| Module_alias of module_alias (** complete name and corresponding module if we found it *)
- | Module_functor of (Odoc_parameter.module_parameter list) * module_kind
+ | Module_functor of module_parameter * module_kind
| Module_apply of module_kind * module_kind
| Module_with of module_type_kind * string
| Module_constraint of module_kind * module_type_kind
@@ -76,7 +83,7 @@ and module_type_alias = {
(** Different kinds of module type. *)
and module_type_kind =
| Module_type_struct of module_element list
- | Module_type_functor of (Odoc_parameter.module_parameter list) * module_type_kind
+ | Module_type_functor of module_parameter * module_type_kind
| Module_type_alias of module_type_alias (** complete 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 *)
@@ -313,25 +320,21 @@ let module_comments ?(trans=true) m = comments (module_elements ~trans m)
let rec module_type_parameters ?(trans=true) mt =
let rec iter k =
match k with
- Some (Module_type_functor (params, _)) ->
- (
- (* we create the couple (parameter, description opt), using
- the description of the parameter if we can find it in the comment.*)
- match mt.mt_info with
- None ->
- List.map (fun p -> (p, None)) params
- | Some i ->
- List.map
- (fun p ->
- try
- let d = List.assoc p.Odoc_parameter.mp_name i.Odoc_types.i_params in
- (p, Some d)
- with
- Not_found ->
- (p, None)
- )
- params
- )
+ Some (Module_type_functor (p, k2)) ->
+ let param =
+ (* we create the couple (parameter, description opt), using
+ the description of the parameter if we can find it in the comment.*)
+ match mt.mt_info with
+ None -> (p, None)
+ | Some i ->
+ try
+ let d = List.assoc p.mp_name i.Odoc_types.i_params in
+ (p, Some d)
+ with
+ Not_found ->
+ (p, None)
+ in
+ param :: (iter (Some k2))
| Some (Module_type_alias mta) ->
if trans then
match mta.mta_module with
@@ -352,45 +355,44 @@ let rec module_type_parameters ?(trans=true) mt =
iter mt.mt_kind
(** Access to the parameters, for a functor.
- @param trans indicates if, for aliased modules, we must perform a transitive search.*)
+ @param trans indicates if, for aliased modules, we must perform a transitive search.*)
and module_parameters ?(trans=true) m =
- match m.m_kind with
- Module_functor (params, _) ->
- (
- (* we create the couple (parameter, description opt), using
- the description of the parameter if we can find it in the comment.*)
- match m.m_info with
- None ->
- List.map (fun p -> (p, None)) params
- | Some i ->
- List.map
- (fun p ->
- try
- let d = List.assoc p.Odoc_parameter.mp_name i.Odoc_types.i_params in
- (p, Some d)
+ let rec iter = function
+ Module_functor (p, k) ->
+ let param =
+ (* we create the couple (parameter, description opt), using
+ the description of the parameter if we can find it in the comment.*)
+ match m.m_info with
+ None ->(p, None)
+ | Some i ->
+ try
+ let d = List.assoc p.mp_name i.Odoc_types.i_params in
+ (p, Some d)
with
- Not_found ->
+ Not_found ->
(p, None)
- )
- params
- )
- | Module_alias ma ->
- if trans then
- match ma.ma_module with
- None -> []
- | Some (Mod m) -> module_parameters ~trans m
- | Some (Modtype mt) -> module_type_parameters ~trans mt
- else
- []
- | Module_constraint (k, tk) ->
- module_type_parameters ~trans: trans
- { mt_name = "" ; mt_info = None ; mt_type = None ;
- mt_is_interface = false ; mt_file = "" ; mt_kind = Some tk ;
- mt_loc = Odoc_types.dummy_loc }
- | Module_struct _
- | Module_apply _
- | Module_with _ ->
- []
+ in
+ param :: (iter k)
+
+ | Module_alias ma ->
+ if trans then
+ match ma.ma_module with
+ None -> []
+ | Some (Mod m) -> module_parameters ~trans m
+ | Some (Modtype mt) -> module_type_parameters ~trans mt
+ else
+ []
+ | Module_constraint (k, tk) ->
+ module_type_parameters ~trans: trans
+ { mt_name = "" ; mt_info = None ; mt_type = None ;
+ mt_is_interface = false ; mt_file = "" ; mt_kind = Some tk ;
+ mt_loc = Odoc_types.dummy_loc }
+ | Module_struct _
+ | Module_apply _
+ | Module_with _ ->
+ []
+ in
+ iter m.m_kind
(** access to all submodules and sudmobules of submodules ... of the given module.
@param trans indicates if, for aliased modules, we must perform a transitive search.*)
diff --git a/ocamldoc/odoc_parameter.ml b/ocamldoc/odoc_parameter.ml
index 9b30f3181..ba7ff1de3 100644
--- a/ocamldoc/odoc_parameter.ml
+++ b/ocamldoc/odoc_parameter.ml
@@ -11,8 +11,7 @@
(* $Id$ *)
-(** Representation and manipulation of method / function / class parameters,
- and module parameters.*)
+(** Representation and manipulation of method / function / class parameters. *)
let print_DEBUG s = print_string s ; print_newline ()
@@ -34,14 +33,6 @@ type param_info =
(** A parameter is just a param_info.*)
type parameter = param_info
-(** A module parameter is just a name and a module type.*)
-type module_parameter = {
- mp_name : string ;
- mp_type : Types.module_type ;
- mp_type_code : string ;
- }
-
-
(** Functions *)
(** acces to the name as a string. For tuples, parenthesis and commas are added. *)
diff --git a/ocamldoc/odoc_sig.ml b/ocamldoc/odoc_sig.ml
index c8fd543ea..a320161d7 100644
--- a/ocamldoc/odoc_sig.ml
+++ b/ocamldoc/odoc_sig.ml
@@ -1085,20 +1085,23 @@ module Analyser =
print_DEBUG (Printf.sprintf "mp_type_code=%s" mp_type_code);
match sig_module_type with
Types.Tmty_functor (ident, param_module_type, body_module_type) ->
+ let mp_kind = analyse_module_type_kind env
+ current_module_name pmodule_type2 param_module_type
+ in
let param =
{
mp_name = Name.from_ident ident ;
mp_type = Odoc_env.subst_module_type env param_module_type ;
mp_type_code = mp_type_code ;
+ mp_kind = mp_kind ;
}
in
- (
- match analyse_module_type_kind env current_module_name module_type2 body_module_type with
- Module_type_functor (params, k) ->
- Module_type_functor (param :: params, k)
- | k ->
- Module_type_functor ([param], k)
- )
+ let k = analyse_module_type_kind env
+ current_module_name
+ module_type2
+ body_module_type
+ in
+ Module_type_functor (param, k)
| _ ->
(* if we're here something's wrong *)
@@ -1153,20 +1156,23 @@ module Analyser =
let loc_end = pmodule_type2.Parsetree.pmty_loc.Location.loc_end.Lexing.pos_cnum in
let mp_type_code = get_string_of_file loc_start loc_end in
print_DEBUG (Printf.sprintf "mp_type_code=%s" mp_type_code);
+ let mp_kind = analyse_module_type_kind env
+ current_module_name pmodule_type2 param_module_type
+ in
let param =
{
mp_name = Name.from_ident ident ;
mp_type = Odoc_env.subst_module_type env param_module_type ;
mp_type_code = mp_type_code ;
+ mp_kind = mp_kind ;
}
in
- (
- match analyse_module_kind env current_module_name module_type2 body_module_type with
- Module_functor (params, k) ->
- Module_functor (param :: params, k)
- | k ->
- Module_functor ([param], k)
- )
+ let k = analyse_module_kind env
+ current_module_name
+ module_type2
+ body_module_type
+ in
+ Module_functor (param, k)
| _ ->
(* if we're here something's wrong *)
diff --git a/ocamldoc/odoc_to_text.ml b/ocamldoc/odoc_to_text.ml
index d24de81cc..426432a65 100644
--- a/ocamldoc/odoc_to_text.ml
+++ b/ocamldoc/odoc_to_text.ml
@@ -519,25 +519,24 @@ class virtual to_text =
[Code ((if with_def_syntax then " : " else "")^
Odoc_messages.struct_end^" ")]
- | Module_functor (_, k) ->
+ | Module_functor (p, k) ->
(if with_def_syntax then [Code " : "] else []) @
[Code "functor ... "] @
[Code " -> "] @
(self#text_of_module_kind ~with_def_syntax: false k)
- (** Return html code for a [module_type_kind]. *)
+ (** Return html code for a [module_type_kind].*)
method text_of_module_type_kind ?(with_def_syntax=true) tk =
match tk with
| Module_type_struct _ ->
[Code ((if with_def_syntax then " = " else "")^Odoc_messages.sig_end)]
- | Module_type_functor (params, k) ->
- let f p =
- [Code ("("^p.mp_name^" : ")] @
- (self#text_of_module_type p.mp_type) @
+ | Module_type_functor (p, k) ->
+ let t1 =
+ [Code ("("^p.mp_name^" : ")] @
+ (self#text_of_module_type_kind p.mp_kind) @
[Code ") -> "]
in
- let t1 = List.flatten (List.map f params) in
let t2 = self#text_of_module_type_kind ~with_def_syntax: false k in
(if with_def_syntax then [Code " = "] else []) @ t1 @ t2