summaryrefslogtreecommitdiff
path: root/ocamldoc/odoc_sig.ml
diff options
context:
space:
mode:
Diffstat (limited to 'ocamldoc/odoc_sig.ml')
-rw-r--r--ocamldoc/odoc_sig.ml151
1 files changed, 98 insertions, 53 deletions
diff --git a/ocamldoc/odoc_sig.ml b/ocamldoc/odoc_sig.ml
index c895d0f850..b695338e2a 100644
--- a/ocamldoc/odoc_sig.ml
+++ b/ocamldoc/odoc_sig.ml
@@ -491,10 +491,11 @@ module Analyser =
| [] -> acc
| types -> take_item (Parsetree.Psig_type (rf, types)))
| Parsetree.Psig_modsubst _ -> acc
- | Parsetree.Psig_module ({Parsetree.pmd_name=name;
+ | Parsetree.Psig_module {Parsetree.pmd_name={ txt = None }} -> acc
+ | Parsetree.Psig_module ({Parsetree.pmd_name={txt = Some name };
pmd_type=module_type} as r)
as m ->
- begin match Name.Map.find name.txt erased with
+ begin match Name.Map.find name erased with
| exception Not_found -> take_item m
| `Removed -> acc
| `Constrained constraints ->
@@ -507,9 +508,15 @@ module Analyser =
| Parsetree.Psig_modtype {Parsetree.pmtd_name=name} as m ->
if is_erased name.txt erased then acc else take_item m
| Parsetree.Psig_recmodule mods ->
- (match List.filter (fun pmd -> not (is_erased pmd.Parsetree.pmd_name.txt erased)) mods with
- | [] -> acc
- | mods -> take_item (Parsetree.Psig_recmodule mods)))
+ (match List.filter
+ (fun pmd ->
+ match pmd.Parsetree.pmd_name.txt with
+ | None -> false
+ | Some name -> not (is_erased name erased))
+ mods
+ with
+ | [] -> acc
+ | mods -> take_item (Parsetree.Psig_recmodule mods)))
signature []
(** Analysis of the elements of a class, from the information in the parsetree and in the class
@@ -1141,13 +1148,16 @@ module Analyser =
| Parsetree.Psig_modsubst _ -> (* FIXME *)
(0, env, [])
- | Parsetree.Psig_module {Parsetree.pmd_name=name; pmd_type=module_type} ->
- let complete_name = Name.concat current_module_name name.txt in
+ | Parsetree.Psig_module {Parsetree.pmd_name={txt=None}} ->
+ (0, env, [])
+
+ | Parsetree.Psig_module {Parsetree.pmd_name={txt=Some name}; pmd_type=module_type} ->
+ let complete_name = Name.concat current_module_name name in
(* get the module type in the signature by the module name *)
let sig_module_type =
- try Signature_search.search_module table name.txt
+ try Signature_search.search_module table name
with Not_found ->
- raise (Failure (Odoc_messages.module_not_found current_module_name name.txt))
+ raise (Failure (Odoc_messages.module_not_found current_module_name name))
in
let module_kind = analyse_module_kind env complete_name module_type sig_module_type in
let code_intf =
@@ -1193,31 +1203,60 @@ module Analyser =
let new_env =
List.fold_left
(fun acc_env {Parsetree.pmd_name={txt=name}} ->
- let complete_name = Name.concat current_module_name name in
- let e = Odoc_env.add_module acc_env complete_name in
- (* get the information for the module in the signature *)
- let sig_module_type =
- try Signature_search.search_module table name
- with Not_found ->
- raise (Failure (Odoc_messages.module_not_found current_module_name name))
- in
- match sig_module_type with
- (* FIXME : can this be a Tmty_ident? in this case, we wouldn't have the signature *)
- Types.Mty_signature s ->
- Odoc_env.add_signature e complete_name ~rel: name s
- | _ ->
- print_DEBUG "not a Tmty_signature";
- e
- )
- env
- decls
+ match name with
+ | None -> acc_env
+ | Some name ->
+ let complete_name = Name.concat current_module_name name in
+ let e = Odoc_env.add_module acc_env complete_name in
+ (* get the information for the module in the signature *)
+ let sig_module_type =
+ try Signature_search.search_module table name
+ with Not_found ->
+ raise (Failure (Odoc_messages.module_not_found current_module_name name))
+ in
+ match sig_module_type with
+ (* FIXME : can this be a Tmty_ident? in this case, we wouldn't have the signature *)
+ Types.Mty_signature s ->
+ Odoc_env.add_signature e complete_name ~rel: name s
+ | _ ->
+ print_DEBUG "not a Tmty_signature";
+ e
+ )
+ env
+ decls
in
let rec f ?(first=false) acc_maybe_more last_pos name_mtype_list =
match name_mtype_list with
[] ->
(acc_maybe_more, [])
- | {Parsetree.pmd_name=name; pmd_type=modtype} :: q ->
- let complete_name = Name.concat current_module_name name.txt in
+ | {Parsetree.pmd_name={txt = None}; pmd_type=modtype} :: q ->
+ let loc = modtype.Parsetree.pmty_loc in
+ let loc_start = Loc.start loc in
+ let loc_end = Loc.end_ loc in
+ let _, ele_comments =
+ if first then (None, [])
+ else get_comments_in_module last_pos loc_start
+ in
+ let pos_limit2 =
+ match q with
+ [] -> pos_limit
+ | _ :: _ -> Loc.start loc
+ in
+ let (maybe_more, _) =
+ My_ir.just_after_special
+ !file_name
+ (get_string_of_file loc_end pos_limit2)
+ in
+
+ let (maybe_more2, eles) = f
+ maybe_more
+ (loc_end + maybe_more)
+ q
+ in
+ (maybe_more2, ele_comments @ eles)
+
+ | {Parsetree.pmd_name={txt = Some name}; pmd_type=modtype} :: q ->
+ let complete_name = Name.concat current_module_name name in
let loc = modtype.Parsetree.pmty_loc in
let loc_start = Loc.start loc in
let loc_end = Loc.end_ loc in
@@ -1236,9 +1275,9 @@ module Analyser =
in
(* get the information for the module in the signature *)
let sig_module_type =
- try Signature_search.search_module table name.txt
+ try Signature_search.search_module table name
with Not_found ->
- raise (Failure (Odoc_messages.module_not_found current_module_name name.txt))
+ raise (Failure (Odoc_messages.module_not_found current_module_name name))
in
(* associate the comments to each constructor and build the [Type.t_type] *)
let module_kind = analyse_module_kind new_env complete_name modtype sig_module_type in
@@ -1543,28 +1582,31 @@ module Analyser =
raise (Failure "Parsetree.Pmty_signature signature but not Types.Mty_signature signat")
)
- | Parsetree.Pmty_functor (_, pmodule_type2, module_type2) ->
+ | Parsetree.Pmty_functor (param2, module_type2) ->
(
- let loc = match pmodule_type2 with None -> Location.none
- | Some pmty -> pmty.Parsetree.pmty_loc in
+ let loc = match param2 with Parsetree.Unit -> Location.none
+ | Parsetree.Named (_, pmty) -> pmty.Parsetree.pmty_loc in
let loc_start = Loc.start loc in
let loc_end = Loc.end_ loc 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);
match sig_module_type with
- Types.Mty_functor (ident, param_module_type, body_module_type) ->
- let mp_kind =
- match pmodule_type2, param_module_type with
- Some pmty, Some mty ->
+ Types.Mty_functor (param, body_module_type) ->
+ let mp_name, mp_kind =
+ match param2, param with
+ Parsetree.Named (_, pmty), Types.Named (Some ident, mty) ->
+ Name.from_ident ident,
analyse_module_type_kind env current_module_name pmty mty
- | _ -> Module_type_struct []
+ | _ -> "*", Module_type_struct []
in
let param =
{
- mp_name = Name.from_ident ident ;
+ mp_name = mp_name;
mp_type =
- Option.map (Odoc_env.subst_module_type env)
- param_module_type;
+ (match param with
+ | Types.Unit -> None
+ | Types.Named (_, mty) ->
+ Some (Odoc_env.subst_module_type env mty));
mp_type_code = mp_type_code ;
mp_kind = mp_kind ;
}
@@ -1638,27 +1680,30 @@ module Analyser =
(* if we're here something's wrong *)
raise (Failure "Parsetree.Pmty_signature signature but not Types.Mty_signature signat")
)
- | Parsetree.Pmty_functor (_, pmodule_type2,module_type2) (* of string * module_type * module_type *) ->
+ | Parsetree.Pmty_functor (param2,module_type2) (* of string * module_type * module_type *) ->
(
match sig_module_type with
- Types.Mty_functor (ident, param_module_type, body_module_type) ->
- let loc = match pmodule_type2 with None -> Location.none
- | Some pmty -> pmty.Parsetree.pmty_loc in
+ Types.Mty_functor (param, body_module_type) ->
+ let loc = match param2 with Parsetree.Unit -> Location.none
+ | Parsetree.Named (_, pmty) -> pmty.Parsetree.pmty_loc in
let loc_start = Loc.start loc in
let loc_end = Loc.end_ loc 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 =
- match pmodule_type2, param_module_type with
- Some pmty, Some mty ->
+ let mp_name, mp_kind =
+ match param2, param with
+ Parsetree.Named (_, pmty), Types.Named (Some ident, mty) ->
+ Name.from_ident ident,
analyse_module_type_kind env current_module_name pmty mty
- | _ -> Module_type_struct []
+ | _ -> "*", Module_type_struct []
in
let param =
{
- mp_name = Name.from_ident ident ;
- mp_type = Option.map
- (Odoc_env.subst_module_type env) param_module_type ;
+ mp_name;
+ mp_type =
+ (match param with
+ | Types.Unit -> None
+ | Types.Named(_, mty) -> Some (Odoc_env.subst_module_type env mty));
mp_type_code = mp_type_code ;
mp_kind = mp_kind ;
}