diff --git a/src/document/comment.ml b/src/document/comment.ml index b9ed0e39ec..b1e11c4376 100644 --- a/src/document/comment.ml +++ b/src/document/comment.ml @@ -34,8 +34,6 @@ module Reference = struct | `Alias (_, r) -> render_resolved (r :> t) | `AliasModuleType (_, r) -> render_resolved (r :> t) | `Module (r, s) -> render_resolved (r :> t) ^ "." ^ ModuleName.to_string s - | `Canonical (_, `Resolved r) -> render_resolved (r :> t) - | `Canonical (p, _) -> render_resolved (p :> t) | `Hidden p -> render_resolved (p :> t) | `ModuleType (r, s) -> render_resolved (r :> t) ^ "." ^ ModuleTypeName.to_string s diff --git a/src/document/generator.ml b/src/document/generator.ml index 0907bf83f2..f246c7f947 100644 --- a/src/document/generator.ml +++ b/src/document/generator.ml @@ -1615,18 +1615,19 @@ module Make (Syntax : SYNTAX) = struct in let status = if decl_hidden then `Inline else t.status in - let include_decl = - match t.decl with - | Odoc_model.Lang.Include.Alias mod_path -> - Link.from_path (mod_path :> Paths.Path.t) - | ModuleType mt -> umty mt - in - let _, content = signature t.expansion.content in let summary = - O.render - (O.keyword "include" ++ O.txt " " ++ include_decl - ++ if Syntax.Mod.include_semicolon then O.keyword ";" else O.noop) + if decl_hidden then O.render (O.keyword "include" ++ O.txt " ...") + else + let include_decl = + match t.decl with + | Odoc_model.Lang.Include.Alias mod_path -> + Link.from_path (mod_path :> Paths.Path.t) + | ModuleType mt -> umty mt + in + O.render + (O.keyword "include" ++ O.txt " " ++ include_decl + ++ if Syntax.Mod.include_semicolon then O.keyword ";" else O.noop) in let content = { Include.content; status; summary } in let attr = [ "include" ] in diff --git a/src/html/generator.ml b/src/html/generator.ml index 3000d2502c..6d9ab72bc1 100644 --- a/src/html/generator.ml +++ b/src/html/generator.ml @@ -295,12 +295,12 @@ and items ~resolve l : item Html.elt list = | Include { attr; anchor; doc; content = { summary; status; content } } :: rest -> let doc = spec_doc_div ~resolve doc in - let included_html = (items content :> any Html.elt list) in + let included_html = (items content :> item Html.elt list) in let a_class = if List.length content = 0 then [ "odoc-include"; "shadowed-include" ] else [ "odoc-include" ] in - let content = + let content : item Html.elt list = let details ~open' = let open' = if open' then [ Html.a_open () ] else [] in let summary = @@ -308,16 +308,21 @@ and items ~resolve l : item Html.elt list = let a = spec_class (attr @ extra_class) @ extra_attr in Html.summary ~a @@ anchor_link @ source (inline ~resolve) summary in - [ Html.details ~a:open' summary included_html ] + let inner = + [ + Html.details ~a:open' summary + (included_html :> any Html.elt list); + ] + in + [ Html.div ~a:[ Html.a_class a_class ] (doc @ inner) ] in match status with - | `Inline -> included_html + | `Inline -> doc @ included_html | `Closed -> details ~open':false | `Open -> details ~open':true | `Default -> details ~open':!Tree.open_details in - let inc = [ Html.div ~a:[ Html.a_class a_class ] (doc @ content) ] in - (continue_with [@tailcall]) rest inc + (continue_with [@tailcall]) rest content | Declaration { Item.attr; anchor; content; doc } :: rest -> let extra_attr, extra_class, anchor_link = mk_anchor anchor in let a = spec_class (attr @ extra_class) @ extra_attr in diff --git a/src/loader/cmt.ml b/src/loader/cmt.ml index f607feaa0c..7704635fae 100644 --- a/src/loader/cmt.ml +++ b/src/loader/cmt.ml @@ -546,22 +546,14 @@ and read_include env parent incl = umty_of_mty mty in let content, shadowed = Cmi.read_signature_noenv env parent (Odoc_model.Compat.signature incl.incl_type) in - let rec contains_signature = function - | ModuleType.U.Signature _ -> true - | Path _ -> false - | With (_, w_expr) -> contains_signature w_expr - | TypeOf _ -> false - in + let expansion = { content; shadowed; } in match decl_modty with - | Some m when not (contains_signature m) -> + | Some m -> let decl = ModuleType m in - let expansion = { content; shadowed; } in [Include {parent; doc; decl; expansion; status; strengthened=None; loc }] - | Some (ModuleType.U.Signature { items; _ }) -> - items - | _ -> + | _ -> content.items - + and read_open env parent o = let container = (parent : Identifier.Signature.t :> Identifier.LabelParent.t) in let doc = Doc_attr.attached_no_tag container o.open_attributes in diff --git a/src/loader/cmti.ml b/src/loader/cmti.ml index cac916ff17..a13a7a786b 100644 --- a/src/loader/cmti.ml +++ b/src/loader/cmti.ml @@ -269,11 +269,15 @@ let read_type_declarations env parent rec_flag decls = let open Signature in List.fold_left (fun (acc, recursive) decl -> - let comments = - Doc_attr.standalone_multiple container decl.typ_attributes in - let comments = List.map (fun com -> Comment com) comments in - let decl = read_type_declaration env parent decl in - ((Type (recursive, decl)) :: (List.rev_append comments acc), And)) + if Btype.is_row_name (Ident.name decl.typ_id) + then (acc, recursive) + else begin + let comments = + Doc_attr.standalone_multiple container decl.typ_attributes in + let comments = List.map (fun com -> Comment com) comments in + let decl = read_type_declaration env parent decl in + ((Type (recursive, decl)) :: (List.rev_append comments acc), And) + end) ([], rec_flag) decls |> fst in @@ -743,29 +747,12 @@ and read_include env parent incl = let doc, status = Doc_attr.attached Odoc_model.Semantics.Expect_status container incl.incl_attributes in let content, shadowed = Cmi.read_signature_noenv env parent (Odoc_model.Compat.signature incl.incl_type) in let expr = read_module_type env parent container incl.incl_mod in - let rec contains_signature = function - | ModuleType.U.Signature _ -> true - | Path _ -> false - | With (_, w_expr) -> contains_signature w_expr - | TypeOf _ -> false - in - (* inline type or module substitution is tricky to inline, because the - scope of the substitution is to the end of the signature being inlined. - If we've got one of those, we fall back to inlining the compiler-computed signature *) - let is_inlinable items = - not (List.exists - (function - | Signature.TypeSubstitution _ -> true - | ModuleSubstitution _ -> true - | _ -> false) items) - in - match Odoc_model.Lang.umty_of_mty expr with - | Some uexpr when not (contains_signature uexpr) -> + let umty = Odoc_model.Lang.umty_of_mty expr in + let expansion = { content; shadowed; } in + match umty with + | Some uexpr -> let decl = Include.ModuleType uexpr in - let expansion = { content; shadowed; } in [Include {parent; doc; decl; expansion; status; strengthened=None; loc }] - | Some ModuleType.U.Signature { items; _ } when is_inlinable items -> - items | _ -> content.items diff --git a/src/loader/ident_env.cppo.ml b/src/loader/ident_env.cppo.ml index 562c479a7f..369e46b7d1 100644 --- a/src/loader/ident_env.cppo.ml +++ b/src/loader/ident_env.cppo.ml @@ -156,6 +156,12 @@ let extract_extended_open o = #endif +let filter_map f x = + List.rev + @@ List.fold_left + (fun acc x -> match f x with Some x -> x :: acc | None -> acc) + [] x + let rec extract_signature_tree_items hide_item items = let open Typedtree in match items with @@ -164,7 +170,10 @@ let rec extract_signature_tree_items hide_item items = #else | { sig_desc = Tsig_type (_, decls); _} :: rest -> #endif - List.map (fun decl -> `Type (decl.typ_id, hide_item)) + filter_map (fun decl -> + if Btype.is_row_name (Ident.name decl.typ_id) + then None + else Some (`Type (decl.typ_id, hide_item))) decls @ extract_signature_tree_items hide_item rest #if OCAML_VERSION >= (4,10,0) diff --git a/src/model/paths.ml b/src/model/paths.ml index e0edafdcf9..6873b50071 100644 --- a/src/model/paths.ml +++ b/src/model/paths.ml @@ -914,10 +914,6 @@ module Reference = struct else (Path.Resolved.ModuleType.identifier sub :> Identifier.Signature.t) | `Module (m, n) -> `Module (parent_signature_identifier m, n) - | `Canonical (_, `Resolved r) -> - parent_signature_identifier (r : module_ :> signature) - | `Canonical (r, _) -> - parent_signature_identifier (r : module_ :> signature) | `ModuleType (m, s) -> `ModuleType (parent_signature_identifier m, s) and parent_type_identifier : datatype -> Identifier.DataType.t = function @@ -932,8 +928,8 @@ module Reference = struct and parent_identifier : parent -> Identifier.Parent.t = function | `Identifier id -> id - | ( `Hidden _ | `Alias _ | `AliasModuleType _ | `Module _ | `Canonical _ - | `ModuleType _ ) as sg -> + | (`Hidden _ | `Alias _ | `AliasModuleType _ | `Module _ | `ModuleType _) + as sg -> (parent_signature_identifier sg :> Identifier.Parent.t) | `Type _ as t -> (parent_type_identifier t :> Identifier.Parent.t) | (`Class _ | `ClassType _) as c -> @@ -942,14 +938,14 @@ module Reference = struct and label_parent_identifier : label_parent -> Identifier.LabelParent.t = function | `Identifier id -> id - | ( `Hidden _ | `Alias _ | `AliasModuleType _ | `Module _ | `Canonical _ - | `ModuleType _ | `Type _ | `Class _ | `ClassType _ ) as r -> + | ( `Hidden _ | `Alias _ | `AliasModuleType _ | `Module _ | `ModuleType _ + | `Type _ | `Class _ | `ClassType _ ) as r -> (parent_identifier r :> Identifier.LabelParent.t) and identifier : t -> Identifier.t = function | `Identifier id -> id - | ( `Alias _ | `AliasModuleType _ | `Module _ | `Canonical _ | `Hidden _ - | `Type _ | `Class _ | `ClassType _ | `ModuleType _ ) as r -> + | ( `Alias _ | `AliasModuleType _ | `Module _ | `Hidden _ | `Type _ + | `Class _ | `ClassType _ | `ModuleType _ ) as r -> (label_parent_identifier r :> Identifier.t) | `Field (p, n) -> `Field (parent_identifier p, n) | `Constructor (s, n) -> `Constructor (parent_type_identifier s, n) diff --git a/src/model/paths_types.ml b/src/model/paths_types.ml index 469193ea0d..242f846fc6 100644 --- a/src/model/paths_types.ml +++ b/src/model/paths_types.ml @@ -590,8 +590,7 @@ and Resolved_reference : sig [ `Identifier of Identifier.path_module | `Hidden of module_ | `Alias of Resolved_path.module_ * module_ - | `Module of signature * ModuleName.t - | `Canonical of module_ * Reference.module_ ] + | `Module of signature * ModuleName.t ] (** @canonical Odoc_model.Paths.Reference.Resolved.Module.t *) (* Signature is [ module | moduletype ] *) @@ -600,7 +599,6 @@ and Resolved_reference : sig | `Hidden of module_ | `Alias of Resolved_path.module_ * module_ | `Module of signature * ModuleName.t - | `Canonical of module_ * Reference.module_ | `ModuleType of signature * ModuleTypeName.t | `AliasModuleType of Resolved_path.module_type * module_type ] (** @canonical Odoc_model.Paths.Reference.Resolved.Signature.t *) @@ -618,7 +616,6 @@ and Resolved_reference : sig | `AliasModuleType of Resolved_path.module_type * module_type | `Module of signature * ModuleName.t | `Hidden of module_ - | `Canonical of module_ * Reference.module_ | `ModuleType of signature * ModuleTypeName.t | `Class of signature * ClassName.t | `ClassType of signature * ClassTypeName.t @@ -633,7 +630,6 @@ and Resolved_reference : sig | `AliasModuleType of Resolved_path.module_type * module_type | `Module of signature * ModuleName.t | `Hidden of module_ - | `Canonical of module_ * Reference.module_ | `ModuleType of signature * ModuleTypeName.t | `Class of signature * ClassName.t | `ClassType of signature * ClassTypeName.t @@ -716,7 +712,6 @@ and Resolved_reference : sig | `AliasModuleType of Resolved_path.module_type * module_type | `Module of signature * ModuleName.t | `Hidden of module_ - | `Canonical of module_ * Reference.module_ | `ModuleType of signature * ModuleTypeName.t | `Type of signature * TypeName.t | `Constructor of datatype * ConstructorName.t diff --git a/src/model_desc/paths_desc.ml b/src/model_desc/paths_desc.ml index eca4c6ae37..ead78c4f52 100644 --- a/src/model_desc/paths_desc.ml +++ b/src/model_desc/paths_desc.ml @@ -298,11 +298,6 @@ module General_paths = struct and resolved_reference : rr t = Variant (function - | `Canonical (x1, x2) -> - C - ( "`Canonical", - ((x1 :> rr), (x2 :> r)), - Pair (resolved_reference, reference) ) | `Class (x1, x2) -> C ( "`Class", diff --git a/src/xref2/component.ml b/src/xref2/component.ml index a0fb029a91..37aaf76fe0 100644 --- a/src/xref2/component.ml +++ b/src/xref2/component.ml @@ -1398,11 +1398,6 @@ module Fmt = struct (x :> Odoc_model.Paths.Path.Resolved.t) model_resolved_reference (y :> Odoc_model.Paths.Reference.Resolved.t) - | `Canonical (x, y) -> - Format.fprintf ppf "canonical(%a,%a)" model_resolved_reference - (x :> t) - model_reference - (y :> Odoc_model.Paths.Reference.t) | `Label (parent, name) -> Format.fprintf ppf "%a.%s" model_resolved_reference (parent :> t) @@ -2328,12 +2323,12 @@ module Of_Lang = struct and module_of_module_substitution ident_map (t : Odoc_model.Lang.ModuleSubstitution.t) = let manifest = module_path ident_map t.manifest in - let canonical = Some manifest in + let canonical = None in { Module.doc = docs ident_map t.doc; type_ = Alias (manifest, None); canonical; - hidden = true; + hidden = false; } and signature : _ -> Odoc_model.Lang.Signature.t -> Signature.t = diff --git a/src/xref2/cpath.ml b/src/xref2/cpath.ml index 09594985e3..ff844587b7 100644 --- a/src/xref2/cpath.ml +++ b/src/xref2/cpath.ml @@ -191,11 +191,11 @@ and is_resolved_module_hidden : | `Identifier _ -> false | `Hidden _ -> true | `Canonical (_, `Resolved _) -> false - | `Canonical (p, _) -> weak_canonical_test || inner p - | `Substituted p | `Apply (p, _) -> inner p + | `Canonical (p, _) -> (not weak_canonical_test) && inner p + | `Substituted p -> inner p | `Module (p, _) -> is_resolved_parent_hidden ~weak_canonical_test p | `Subst (p1, p2) -> is_resolved_module_type_hidden p1 || inner p2 - | `Alias (p1, p2) -> inner p1 || inner p2 + | `Alias (p1, p2) | `Apply (p1, p2) -> inner p1 || inner p2 | `OpaqueModule m -> inner m in inner @@ -281,15 +281,11 @@ let rec resolved_module_of_resolved_module_reference : | `Identifier i -> `Identifier i | `Alias (_m1, _m2) -> failwith "gah" | `Hidden s -> `Hidden (resolved_module_of_resolved_module_reference s) - | `Canonical (m1, m2) -> - `Canonical - ( resolved_module_of_resolved_module_reference m1, - module_of_module_reference m2 ) and resolved_module_of_resolved_signature_reference : Reference.Resolved.Signature.t -> Resolved.module_ = function | `Identifier (#Identifier.Module.t as i) -> `Identifier i - | (`Alias _ | `Canonical _ | `Module _ | `Hidden _) as r' -> + | (`Alias _ | `Module _ | `Hidden _) as r' -> resolved_module_of_resolved_module_reference r' | `ModuleType (_, n) -> failwith ("Not a module reference: " ^ ModuleTypeName.to_string n) diff --git a/src/xref2/env.ml b/src/xref2/env.ml index de0fb1d1df..05abdc748c 100644 --- a/src/xref2/env.ml +++ b/src/xref2/env.ml @@ -119,14 +119,23 @@ end = struct let remove id t = let id = (id :> Identifier.t) in let name = Identifier.name id in - let l = StringMap.find name t in + let l = + try StringMap.find name t + with e -> + Format.eprintf "Failed to find %s\n%!" name; + raise e + in match List.filter (fun e -> not (Identifier.equal id (Component.Element.identifier e.elem))) l with - | [] -> StringMap.remove name t + | [] -> ( + try StringMap.remove name t + with Not_found -> + Format.eprintf "Failed to find %s\n%!" name; + raise Not_found) | xs -> StringMap.add name xs (StringMap.remove name t) let find_by_name f name t = diff --git a/src/xref2/ident.ml b/src/xref2/ident.ml index 88e4055a04..3f12e7e5e4 100644 --- a/src/xref2/ident.ml +++ b/src/xref2/ident.ml @@ -228,6 +228,8 @@ module Name = struct let module_ m = ModuleName.to_string (module' m) + let unsafe_module m = ModuleName.to_string_unsafe (module' m) + let path_module : path_module -> string = function | `LRoot (n, _) -> ModuleName.to_string n | `LModule (n, _) -> ModuleName.to_string n @@ -264,11 +266,16 @@ module Name = struct let class_ c = ClassName.to_string (class' c) + let unsafe_class c = ClassName.to_string_unsafe (class' c) + let typed_class : class_ -> ClassName.t = function `LClass (n, _) -> n let module_type : module_type -> string = function | `LModuleType (n, _) -> ModuleTypeName.to_string n + let unsafe_module_type : module_type -> string = function + | `LModuleType (n, _) -> ModuleTypeName.to_string_unsafe n + let typed_module_type : module_type -> ModuleTypeName.t = function | `LModuleType (n, _) -> n @@ -281,6 +288,8 @@ module Name = struct let class_type c = ClassTypeName.to_string (class_type' c) + let unsafe_class_type c = ClassTypeName.to_string_unsafe (class_type' c) + let typed_class_type : class_type -> ClassTypeName.t = function | `LClassType (n, _) -> n diff --git a/src/xref2/lang_of.ml b/src/xref2/lang_of.ml index 63222a60e8..0ecd6ab99f 100644 --- a/src/xref2/lang_of.ml +++ b/src/xref2/lang_of.ml @@ -296,7 +296,7 @@ module ExtractIDs = struct open Component let rec type_decl parent map id = - let name = Ident.Name.type_ id in + let name = Ident.Name.unsafe_type id in let identifier = if List.mem name map.shadowed.s_types then `Type (parent, Odoc_model.Names.TypeName.internal_of_string name) @@ -313,7 +313,7 @@ module ExtractIDs = struct } and module_ parent map id = - let name = Ident.Name.module_ id in + let name = Ident.Name.unsafe_module id in let identifier = if List.mem name map.shadowed.s_modules then `Module (parent, ModuleName.internal_of_string name) @@ -322,7 +322,7 @@ module ExtractIDs = struct { map with module_ = Component.ModuleMap.add id identifier map.module_ } and module_type parent map id = - let name = Ident.Name.module_type id in + let name = Ident.Name.unsafe_module_type id in let identifier = if List.mem name map.shadowed.s_module_types then `ModuleType (parent, ModuleTypeName.internal_of_string name) @@ -334,7 +334,7 @@ module ExtractIDs = struct } and class_ parent map id = - let name = Ident.Name.class_ id in + let name = Ident.Name.unsafe_class id in let identifier = if List.mem name map.shadowed.s_classes then `Class (parent, ClassName.internal_of_string name) @@ -356,7 +356,7 @@ module ExtractIDs = struct } and class_type parent map (id : Ident.class_type) = - let name = Ident.Name.class_type id in + let name = Ident.Name.unsafe_class_type id in let identifier = if List.mem name map.shadowed.s_class_types then `ClassType (parent, ClassTypeName.internal_of_string name) diff --git a/src/xref2/tools.ml b/src/xref2/tools.ml index 8f706e4df9..188501e12a 100644 --- a/src/xref2/tools.ml +++ b/src/xref2/tools.ml @@ -1094,22 +1094,24 @@ and handle_canonical_module env p2 = match m.type_ with | Component.Module.Alias (_, Some _) -> true | Alias (`Resolved p, None) -> - (* check for an alias chain with a canonical in it... *) - let rec check (m, p) = + (* we're an alias - check to see if we're marked as the canonical path. + If not, check for an alias chain with us as canonical in it... *) + let rec check m = match m.Component.Module.canonical with | Some p -> p = p2 (* The canonical path is the same one we're trying to resolve *) | None -> ( - match lookup_module ~mark_substituted:false env p with - | Error _ -> false - | Ok m -> ( - let m = Component.Delayed.get m in - match m.type_ with - | Alias (`Resolved p, _) -> check (m, p) - | _ -> false)) + match m.type_ with + | Component.Module.Alias (`Resolved p, _) -> ( + match lookup_module ~mark_substituted:false env p with + | Error _ -> false + | Ok m -> + let m = Component.Delayed.get m in + check m) + | _ -> false) in - let self_canonical () = check (m, p) in + let self_canonical () = check m in let hidden = Cpath.is_resolved_module_hidden ~weak_canonical_test:true p in diff --git a/test/generators/html/Include.html b/test/generators/html/Include.html index fd98420248..ad8b36c376 100644 --- a/test/generators/html/Include.html +++ b/test/generators/html/Include.html @@ -57,12 +57,10 @@

Module Include

-
-
-
- - type u -
+
+
+ + type u
diff --git a/test/generators/html/Include_sections.html b/test/generators/html/Include_sections.html index 3a1fccfda0..b6dc5ad6b1 100644 --- a/test/generators/html/Include_sections.html +++ b/test/generators/html/Include_sections.html @@ -52,17 +52,15 @@

Module Include_sections

Something once

-
-

- Something 1 -

foo

-

- Something 2 -

-

- Something 1-bis -

Some text.

-
+

+ Something 1 +

foo

+

+ Something 2 +

+

+ Something 1-bis +

Some text.

Second include

@@ -71,31 +69,27 @@

Something a second time: the heading level should be shift here.

-
-

- Something 1 -

foo

-

- Something 2 -

-

- Something 1-bis -

Some text.

-
+

+ Something 1 +

foo

+

+ Something 2 +

+

+ Something 1-bis +

Some text.

Third include

Shifted some more.

-
-

- Something 1 -

foo

-
- Something 2 -
-

- Something 1-bis -

Some text.

-
+

+ Something 1 +

foo

+
+ Something 2 +
+

+ Something 1-bis +

Some text.

And let's include it again, but without inlining it this time: the ToC shouldn't grow.

diff --git a/test/generators/html/Ocamlary-module-type-RecollectionModule.html b/test/generators/html/Ocamlary-module-type-RecollectionModule.html index 1ea17107e7..4574465e30 100644 --- a/test/generators/html/Ocamlary-module-type-RecollectionModule.html +++ b/test/generators/html/Ocamlary-module-type-RecollectionModule.html @@ -15,68 +15,80 @@

Module type Ocamlary.RecollectionModule

-
-
- - type collection - = - - - CollectionModule.element - list +
+
+ + + include + sig ... end - - -
-
-
-
- - type element - = - - CollectionModule.collection - - - -
-
-
-
- - - module - - InnerModuleA - - - : sig ... - end - - -
-
-

This comment is for InnerModuleA.

-
-
-
-
- - - module - type InnerModuleTypeA - - = - InnerModuleA.InnerModuleTypeA' - - - -
-
-

This comment is for InnerModuleTypeA.

-
+
+ +
+
+ + type collection + = + + + CollectionModule.element + list + + + +
+
+
+
+ + type element + = + + CollectionModule.collection + + + +
+
+
+
+ + + module + + InnerModuleA + + + : sig ... + end + + +
+
+

This comment is for InnerModuleA.

+
+
+
+
+ + + module + type InnerModuleTypeA + + = + InnerModuleA.InnerModuleTypeA' + + + +
+
+

This comment is for InnerModuleTypeA.

+
+
+
diff --git a/test/generators/html/Recent-X.html b/test/generators/html/Recent-X.html index 481a4c9932..77b502870b 100644 --- a/test/generators/html/Recent-X.html +++ b/test/generators/html/Recent-X.html @@ -28,8 +28,7 @@

Module Recent.X

type t - = - int Z.Y.X.t + = int L.X.t
@@ -48,7 +47,7 @@

Module Recent.X

type v = u - Z.Y.X.t + L.X.t diff --git a/test/generators/html/Toplevel_comments-Include_inline'.html b/test/generators/html/Toplevel_comments-Include_inline'.html index 9dba44586d..35125037b2 100644 --- a/test/generators/html/Toplevel_comments-Include_inline'.html +++ b/test/generators/html/Toplevel_comments-Include_inline'.html @@ -17,13 +17,11 @@

Module Toplevel_comments.Include_inline'

Doc of Include_inline, part 1.

Doc of Include_inline, part 2.

-
-

part 3

-
-
- - type t -
+

part 3

+
+
+ + type t
diff --git a/test/generators/html/Toplevel_comments-Include_inline.html b/test/generators/html/Toplevel_comments-Include_inline.html index 7921ce5859..bae5834034 100644 --- a/test/generators/html/Toplevel_comments-Include_inline.html +++ b/test/generators/html/Toplevel_comments-Include_inline.html @@ -17,12 +17,10 @@

Module Toplevel_comments.Include_inline

Doc of T, part 2.

-
-
-
- - type t -
+
+
+ + type t
diff --git a/test/generators/html/Toplevel_comments-module-type-Include_inline_T'.html b/test/generators/html/Toplevel_comments-module-type-Include_inline_T'.html index d57ed15b98..a57664fe27 100644 --- a/test/generators/html/Toplevel_comments-module-type-Include_inline_T'.html +++ b/test/generators/html/Toplevel_comments-module-type-Include_inline_T'.html @@ -18,13 +18,11 @@

Module type

Doc of Include_inline_T', part 1.

Doc of Include_inline_T', part 2.

-
-

part 3

-
-
- - type t -
+

part 3

+
+
+ + type t
diff --git a/test/generators/html/Toplevel_comments-module-type-Include_inline_T.html b/test/generators/html/Toplevel_comments-module-type-Include_inline_T.html index 3318bf979a..f3a0598110 100644 --- a/test/generators/html/Toplevel_comments-module-type-Include_inline_T.html +++ b/test/generators/html/Toplevel_comments-module-type-Include_inline_T.html @@ -18,12 +18,10 @@

Module type

Doc of T, part 2.

-
-
-
- - type t -
+
+
+ + type t
diff --git a/test/generators/html/Type.html b/test/generators/html/Type.html index 9c5849931a..a9c2f28dee 100644 --- a/test/generators/html/Type.html +++ b/test/generators/html/Type.html @@ -454,18 +454,10 @@

Module Type

]
-
-
- - - type private_extenion#row - -
-
- and private_extenion + type private_extenion = private [> diff --git a/test/generators/latex/Ocamlary.tex b/test/generators/latex/Ocamlary.tex index f19fe7398c..391deab4ec 100644 --- a/test/generators/latex/Ocamlary.tex +++ b/test/generators/latex/Ocamlary.tex @@ -279,7 +279,7 @@ \subsubsection{Advanced Module Stuff\label{advanced-module-stuff}}% \label{module-Ocamlary-module-type-RECOLLECTION}\ocamlcodefragment{\ocamltag{keyword}{module} \ocamltag{keyword}{type} \hyperref[module-Ocamlary-module-type-RECOLLECTION]{\ocamlinlinecode{RECOLLECTION}}}\ocamlcodefragment{ = \ocamltag{keyword}{sig}}\begin{ocamlindent}\label{module-Ocamlary-module-type-RECOLLECTION-module-C}\ocamlcodefragment{\ocamltag{keyword}{module} C = \hyperref[module-Ocamlary-module-Recollection]{\ocamlinlinecode{Recollection(CollectionModule)}}}\\ \end{ocamlindent}% \ocamlcodefragment{\ocamltag{keyword}{end}}\\ -\label{module-Ocamlary-module-type-RecollectionModule}\ocamlcodefragment{\ocamltag{keyword}{module} \ocamltag{keyword}{type} \hyperref[module-Ocamlary-module-type-RecollectionModule]{\ocamlinlinecode{RecollectionModule}}}\ocamlcodefragment{ = \ocamltag{keyword}{sig}}\begin{ocamlindent}\label{module-Ocamlary-module-type-RecollectionModule-type-collection}\ocamlcodefragment{\ocamltag{keyword}{type} collection = \hyperref[module-Ocamlary-module-CollectionModule-type-element]{\ocamlinlinecode{CollectionModule.\allowbreak{}element}} list}\\ +\label{module-Ocamlary-module-type-RecollectionModule}\ocamlcodefragment{\ocamltag{keyword}{module} \ocamltag{keyword}{type} \hyperref[module-Ocamlary-module-type-RecollectionModule]{\ocamlinlinecode{RecollectionModule}}}\ocamlcodefragment{ = \ocamltag{keyword}{sig}}\begin{ocamlindent}\ocamltag{keyword}{include} \ocamltag{keyword}{sig} .\allowbreak{}.\allowbreak{}.\allowbreak{} \ocamltag{keyword}{end}\label{module-Ocamlary-module-type-RecollectionModule-type-collection}\ocamlcodefragment{\ocamltag{keyword}{type} collection = \hyperref[module-Ocamlary-module-CollectionModule-type-element]{\ocamlinlinecode{CollectionModule.\allowbreak{}element}} list}\\ \label{module-Ocamlary-module-type-RecollectionModule-type-element}\ocamlcodefragment{\ocamltag{keyword}{type} element = \hyperref[module-Ocamlary-module-CollectionModule-type-collection]{\ocamlinlinecode{CollectionModule.\allowbreak{}collection}}}\\ \label{module-Ocamlary-module-type-RecollectionModule-module-InnerModuleA}\ocamlcodefragment{\ocamltag{keyword}{module} \hyperref[module-Ocamlary-module-type-RecollectionModule-module-InnerModuleA]{\ocamlinlinecode{InnerModuleA}}}\ocamlcodefragment{ : \ocamltag{keyword}{sig}}\begin{ocamlindent}\label{module-Ocamlary-module-type-RecollectionModule-module-InnerModuleA-type-t}\ocamlcodefragment{\ocamltag{keyword}{type} t = \hyperref[module-Ocamlary-module-type-RecollectionModule-type-collection]{\ocamlinlinecode{collection}}}\begin{ocamlindent}This comment is for \ocamlinlinecode{t}.\end{ocamlindent}% \medbreak diff --git a/test/generators/latex/Recent.tex b/test/generators/latex/Recent.tex index cf707164d4..beb2fe4456 100644 --- a/test/generators/latex/Recent.tex +++ b/test/generators/latex/Recent.tex @@ -61,9 +61,9 @@ \subsubsection{Signature\label{signature}}% \end{ocamlindent}% \ocamlcodefragment{\ocamltag{keyword}{end}}\\ \label{module-Recent-module-X}\ocamlcodefragment{\ocamltag{keyword}{module} \hyperref[module-Recent-module-X]{\ocamlinlinecode{X}}}\ocamlcodefragment{ : \ocamltag{keyword}{sig}}\begin{ocamlindent}\label{module-Recent-module-X-module-L}\ocamlcodefragment{\ocamltag{keyword}{module} L := \hyperref[module-Recent-module-Z-module-Y]{\ocamlinlinecode{Z.\allowbreak{}Y}}}\\ -\label{module-Recent-module-X-type-t}\ocamlcodefragment{\ocamltag{keyword}{type} t = int \hyperref[module-Recent-module-Z-module-Y-module-X-type-t]{\ocamlinlinecode{Z.\allowbreak{}Y.\allowbreak{}X.\allowbreak{}t}}}\\ +\label{module-Recent-module-X-type-t}\ocamlcodefragment{\ocamltag{keyword}{type} t = int \hyperref[module-Recent-module-Z-module-Y-module-X-type-t]{\ocamlinlinecode{L.\allowbreak{}X.\allowbreak{}t}}}\\ \label{module-Recent-module-X-type-u}\ocamlcodefragment{\ocamltag{keyword}{type} u := int}\\ -\label{module-Recent-module-X-type-v}\ocamlcodefragment{\ocamltag{keyword}{type} v = \hyperref[module-Recent-module-X-type-u]{\ocamlinlinecode{u}} \hyperref[module-Recent-module-Z-module-Y-module-X-type-t]{\ocamlinlinecode{Z.\allowbreak{}Y.\allowbreak{}X.\allowbreak{}t}}}\\ +\label{module-Recent-module-X-type-v}\ocamlcodefragment{\ocamltag{keyword}{type} v = \hyperref[module-Recent-module-X-type-u]{\ocamlinlinecode{u}} \hyperref[module-Recent-module-Z-module-Y-module-X-type-t]{\ocamlinlinecode{L.\allowbreak{}X.\allowbreak{}t}}}\\ \end{ocamlindent}% \ocamlcodefragment{\ocamltag{keyword}{end}}\\ \label{module-Recent-module-type-PolyS}\ocamlcodefragment{\ocamltag{keyword}{module} \ocamltag{keyword}{type} \hyperref[module-Recent-module-type-PolyS]{\ocamlinlinecode{PolyS}}}\ocamlcodefragment{ = \ocamltag{keyword}{sig}}\begin{ocamlindent}\label{module-Recent-module-type-PolyS-type-t}\ocamlcodefragment{\ocamltag{keyword}{type} t = [ }\\ diff --git a/test/generators/latex/Type.tex b/test/generators/latex/Type.tex index 3d02ecc029..1241357f25 100644 --- a/test/generators/latex/Type.tex +++ b/test/generators/latex/Type.tex @@ -86,8 +86,7 @@ \section{Module \ocamlinlinecode{Type}}\label{module-Type}% \end{ocamltabular}% \\ \ocamlcodefragment{ ]}\\ -\label{module-Type-type-private+u+extenion#row}\ocamlcodefragment{\ocamltag{keyword}{type} private\_\allowbreak{}extenion\#row}\\ -\label{module-Type-type-private+u+extenion}\ocamlcodefragment{\ocamltag{keyword}{and} private\_\allowbreak{}extenion = \ocamltag{keyword}{private} [> }\\ +\label{module-Type-type-private+u+extenion}\ocamlcodefragment{\ocamltag{keyword}{type} private\_\allowbreak{}extenion = \ocamltag{keyword}{private} [> }\\ \begin{ocamltabular}{p{1.000\textwidth}}\ocamlinlinecode{| }\ocamlinlinecode{\hyperref[module-Type-type-polymorphic+u+variant]{\ocamlinlinecode{polymorphic\_\allowbreak{}variant}}}\label{module-Type-type-private+u+extenion.polymorphic+u+variant}\\ \end{ocamltabular}% \\ diff --git a/test/generators/man/Recent.X.3o b/test/generators/man/Recent.X.3o index 06f2abc730..fb9012f354 100644 --- a/test/generators/man/Recent.X.3o +++ b/test/generators/man/Recent.X.3o @@ -13,8 +13,8 @@ Recent\.X .nf \f[CB]module\fR L := Z\.Y .sp -\f[CB]type\fR t = int Z\.Y\.X\.t +\f[CB]type\fR t = int L\.X\.t .sp \f[CB]type\fR u := int .sp -\f[CB]type\fR v = u Z\.Y\.X\.t +\f[CB]type\fR v = u L\.X\.t diff --git a/test/generators/man/Type.3o b/test/generators/man/Type.3o index 457e5456dc..4effb74d90 100644 --- a/test/generators/man/Type.3o +++ b/test/generators/man/Type.3o @@ -177,9 +177,7 @@ e : 'a\. \f[CB]'a\fR; .br ] .sp -\f[CB]type\fR private_extenion#row -.sp -\f[CB]and\fR private_extenion = \f[CB]private\fR [> +\f[CB]type\fR private_extenion = \f[CB]private\fR [> .br .ti +2 | polymorphic_variant diff --git a/test/xref2/cpath/cpath_test.md b/test/xref2/cpath/cpath_test.md new file mode 100644 index 0000000000..5a5a7acfbc --- /dev/null +++ b/test/xref2/cpath/cpath_test.md @@ -0,0 +1,27 @@ +### Hidden paths + +Tests for `weak_canonical_test`. When calling `is_resolved_module_hidden`, we normally would have `weak_canonical_test` false, and we'll check to see whether the canonical part of a path is hidden or not. When `weak_canonical_test` is true, we'll _assume_ that the canonical part will resolve to be a non-hidden path. + +In the following test, we create a path with an unresolved canonical +```ocaml env=e1 +# let m = `Hidden (`Local (`LModule (Odoc_model.Names.ModuleName.internal_of_string "M", 1)));; +val m : + [> `Hidden of + [> `Local of [> `LModule of Odoc_model.Names.ModuleName.t * int ] ] ] = + `Hidden (`Local (`LModule ({M}1, 1))) +# let cm = `Root "Foo";; +val cm : [> `Root of string ] = `Root "Foo" +# let p = `Canonical(m, cm);; +val p : + [> `Canonical of + [> `Hidden of + [> `Local of [> `LModule of Odoc_model.Names.ModuleName.t * int ] + ] ] * + [> `Root of string ] ] = + `Canonical (`Hidden (`Local (`LModule ({M}1, 1))), `Root "Foo") +# let r1 = Cpath.is_resolved_module_hidden ~weak_canonical_test:false p;; +val r1 : bool = true +# let r2 = Cpath.is_resolved_module_hidden ~weak_canonical_test:true p;; +val r2 : bool = false +``` + diff --git a/test/xref2/cpath/dune b/test/xref2/cpath/dune new file mode 100644 index 0000000000..62eca50d80 --- /dev/null +++ b/test/xref2/cpath/dune @@ -0,0 +1,16 @@ +(rule + (targets cpath_test.output) + (enabled_if + (>= %{ocaml_version} 4.08)) + (deps + (package odoc)) + (action + (run ocaml-mdx-test --prelude=%{dep:../lib/prelude.ml} -o %{targets} + %{dep:cpath_test.md}))) + +(rule + (alias runmdx) + (enabled_if + (>= %{ocaml_version} 4.08)) + (action + (diff cpath_test.md cpath_test.output))) diff --git a/test/xref2/dune b/test/xref2/dune index 58b4a18415..3525c38641 100644 --- a/test/xref2/dune +++ b/test/xref2/dune @@ -22,7 +22,7 @@ ; 4.08.0 and above (cram - (applies_to github_issue_587) + (applies_to github_issue_587 shadow) (enabled_if (>= %{ocaml_version} 4.08.0))) diff --git a/test/xref2/include_struct.t/a.mli b/test/xref2/include_struct.t/a.mli new file mode 100644 index 0000000000..cc721cd984 --- /dev/null +++ b/test/xref2/include_struct.t/a.mli @@ -0,0 +1 @@ +(* This space intentionally left blank *) diff --git a/test/xref2/include_struct.t/b.ml b/test/xref2/include_struct.t/b.ml new file mode 100644 index 0000000000..97fccc4637 --- /dev/null +++ b/test/xref2/include_struct.t/b.ml @@ -0,0 +1,3 @@ +include struct + module A = A +end diff --git a/test/xref2/include_struct.t/c.ml b/test/xref2/include_struct.t/c.ml new file mode 100644 index 0000000000..a192cdd15a --- /dev/null +++ b/test/xref2/include_struct.t/c.ml @@ -0,0 +1,3 @@ +include B + +include struct end diff --git a/test/xref2/include_struct.t/d.ml b/test/xref2/include_struct.t/d.ml new file mode 100644 index 0000000000..e55c653137 --- /dev/null +++ b/test/xref2/include_struct.t/d.ml @@ -0,0 +1 @@ +include struct end diff --git a/test/xref2/include_struct.t/e.ml b/test/xref2/include_struct.t/e.ml new file mode 100644 index 0000000000..e55c653137 --- /dev/null +++ b/test/xref2/include_struct.t/e.ml @@ -0,0 +1 @@ +include struct end diff --git a/test/xref2/include_struct.t/f.ml b/test/xref2/include_struct.t/f.ml new file mode 100644 index 0000000000..5375a36ac9 --- /dev/null +++ b/test/xref2/include_struct.t/f.ml @@ -0,0 +1,3 @@ +include D +include E (* or D again! *) +include C diff --git a/test/xref2/include_struct.t/run.t b/test/xref2/include_struct.t/run.t new file mode 100644 index 0000000000..80af461d83 --- /dev/null +++ b/test/xref2/include_struct.t/run.t @@ -0,0 +1,8 @@ +This was simply failing in a previous incarnation of the code + $ for i in a.mli b.ml c.ml d.ml e.ml f.ml; do ocamlc -c -bin-annot $i; done + $ odoc compile -I . a.cmti + $ odoc compile -I . b.cmt + $ odoc compile -I . c.cmt + $ odoc compile -I . d.cmt + $ odoc compile -I . e.cmt + $ odoc compile -I . f.cmt diff --git a/test/xref2/refs/refs.md b/test/xref2/refs/refs.md index 9775cd944b..f8f1d3b41d 100644 --- a/test/xref2/refs/refs.md +++ b/test/xref2/refs/refs.md @@ -996,7 +996,7 @@ Warning: Reference to 'Y' is ambiguous. Please specify its kind: constructor-Y, Y) # resolve_ref "Everything_ambiguous_in_sig.t" (* Some kinds are missing: label, type subst (would be "type-") *) ;; File "": -Warning: Reference to 't' is ambiguous. Please specify its kind: field-t, module-type-t, type-t, val-t, val-t. +Warning: Reference to 't' is ambiguous. Please specify its kind: field-t, module-type-t, type-t, val-t. - : ref = `Type (`Identifier diff --git a/test/xref2/shadow.t/c.mli b/test/xref2/shadow.t/c.mli new file mode 100644 index 0000000000..1f5c2bb769 --- /dev/null +++ b/test/xref2/shadow.t/c.mli @@ -0,0 +1,27 @@ +(* Can also inline the module types [B] and [B.Q] here. *) + +module B : sig + type t + + val a : unit + + module Q : sig + module U : sig end + end + + module U : sig end + +end + +include module type of B + +module Q : sig + include module type of struct + include B.Q + end + + module U : sig end + +end + +module U : sig end diff --git a/test/xref2/shadow.t/d.mli b/test/xref2/shadow.t/d.mli new file mode 100644 index 0000000000..14e7a486f6 --- /dev/null +++ b/test/xref2/shadow.t/d.mli @@ -0,0 +1,10 @@ +include module type of struct + include C +end + +type t + +val a : unit + +module U : sig end + diff --git a/test/xref2/shadow.t/run.t b/test/xref2/shadow.t/run.t new file mode 100644 index 0000000000..dbfd10fd39 --- /dev/null +++ b/test/xref2/shadow.t/run.t @@ -0,0 +1,8 @@ +This test contains a carefully crafted couple of modules that cause a clash of names in the current shadowing code. +If the shadowing code is working correctly this should not crash + + $ ocamlc -c -bin-annot -I . c.mli + $ ocamlc -c -bin-annot -I . d.mli + $ odoc compile -I . c.cmti + $ odoc compile -I . d.cmti +