this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Warnings: allow disabling warnings coming from specific units

When docstrings go are inherited, eg from an include or a functor expansion,
warnings may be generated in one docs while the fix is in a dependency.

This commit allows to tag each docstring with a boolean to indicate whether it
comes from a unit with warnings enabled or disabled.

+752 -435
+1 -1
src/document/comment.ml
··· 415 415 416 416 let to_ir (docs : Comment.docs) = 417 417 Utils.flatmap ~f:block_element 418 - @@ List.map (fun x -> x.Odoc_model.Location_.value) docs 418 + @@ List.map (fun x -> x.Odoc_model.Location_.value) docs.elements 419 419 420 420 let has_doc docs = docs <> []
+35 -28
src/document/generator.ml
··· 531 531 in 532 532 let anchor = Some url in 533 533 let rhs = Comment.to_ir fld.doc in 534 - let doc = if not (Comment.has_doc fld.doc) then [] else rhs in 534 + let doc = 535 + if not (Comment.has_doc fld.doc.elements) then [] else rhs 536 + in 535 537 let markers = Syntax.Comment.markers in 536 538 DocumentedSrc.Documented { anchor; attrs; code; doc; markers }) 537 539 in ··· 610 612 let anchor = Some url in 611 613 let rhs = Comment.to_ir cstr.doc in 612 614 let doc = 613 - if not (Comment.has_doc cstr.doc) then [] else rhs 615 + if not (Comment.has_doc cstr.doc.elements) then [] else rhs 614 616 in 615 617 let markers = Syntax.Comment.markers in 616 618 DocumentedSrc.Nested { anchor; attrs; code; doc; markers }) ··· 706 708 ++ 707 709 if Syntax.Type.Variant.parenthesize_params then params 708 710 else O.txt " " ++ O.keyword "of" ++ O.sp ++ params)), 709 - match doc with [] -> None | _ -> Some (Comment.to_ir doc) )) 711 + match doc with 712 + | { elements = []; _ } -> None 713 + | _ -> Some (Comment.to_ir doc) )) 710 714 in 711 715 let markers = Syntax.Comment.markers in 712 716 try ··· 920 924 module Sectioning : sig 921 925 open Odoc_model 922 926 923 - val comment_items : Comment.docs -> Item.t list 927 + val comment_items : Comment.elements -> Item.t list 924 928 925 - val docs : Comment.docs -> Item.t list * Item.t list 929 + val docs : Comment.elements -> Item.t list * Item.t list 926 930 end = struct 927 - let take_until_heading_or_end (docs : Odoc_model.Comment.docs) = 931 + let take_until_heading_or_end (docs : Odoc_model.Comment.elements) = 928 932 let content, _, rest = 929 933 Doctree.Take.until docs ~classify:(fun b -> 930 934 match b.Location.value with ··· 935 939 in 936 940 (content, rest) 937 941 938 - let comment_items (input0 : Odoc_model.Comment.docs) = 942 + let comment_items (input0 : Odoc_model.Comment.elements) = 939 943 let rec loop input_comment acc = 940 944 match input_comment with 941 945 | [] -> List.rev acc ··· 1070 1074 in 1071 1075 loop rest acc_items 1072 1076 | Comment (`Docs c) -> 1073 - let items = Sectioning.comment_items c in 1077 + let items = Sectioning.comment_items c.elements in 1074 1078 loop rest (List.rev_append items acc_items)) 1075 1079 in 1076 1080 (* FIXME: use [t.self] *) 1077 - (c.doc, loop c.items []) 1081 + (c.doc.elements, loop c.items []) 1078 1082 1079 1083 let rec class_decl (cd : Odoc_model.Lang.Class.decl) = 1080 1084 match cd with ··· 1111 1115 let expansion_doc, items = class_signature csig in 1112 1116 let url = Url.Path.from_identifier t.id in 1113 1117 let page = 1114 - make_expansion_page ~source_anchor url [ t.doc; expansion_doc ] 1118 + make_expansion_page ~source_anchor url 1119 + [ t.doc.elements; expansion_doc ] 1115 1120 items 1116 1121 in 1117 1122 ( O.documentedSrc @@ path url [ inline @@ Text name ], ··· 1132 1137 in 1133 1138 let attr = [ "class" ] in 1134 1139 let anchor = path_to_id t.id in 1135 - let doc = Comment.synopsis ~decl_doc:t.doc ~expansion_doc in 1140 + let doc = Comment.synopsis ~decl_doc:t.doc.elements ~expansion_doc in 1136 1141 Item.Declaration { attr; anchor; doc; content; source_anchor } 1137 1142 1138 1143 let class_type (t : Odoc_model.Lang.ClassType.t) = ··· 1149 1154 let url = Url.Path.from_identifier t.id in 1150 1155 let expansion_doc, items = class_signature csig in 1151 1156 let page = 1152 - make_expansion_page ~source_anchor url [ t.doc; expansion_doc ] 1157 + make_expansion_page ~source_anchor url 1158 + [ t.doc.elements; expansion_doc ] 1153 1159 items 1154 1160 in 1155 1161 ( O.documentedSrc @@ path url [ inline @@ Text name ], ··· 1166 1172 in 1167 1173 let attr = [ "class-type" ] in 1168 1174 let anchor = path_to_id t.id in 1169 - let doc = Comment.synopsis ~decl_doc:t.doc ~expansion_doc in 1175 + let doc = Comment.synopsis ~decl_doc:t.doc.elements ~expansion_doc in 1170 1176 Item.Declaration { attr; anchor; doc; content; source_anchor } 1171 1177 end 1172 1178 1173 1179 open Class 1174 1180 1175 1181 module Module : sig 1176 - val signature : Lang.Signature.t -> Comment.Comment.docs * Item.t list 1182 + val signature : Lang.Signature.t -> Comment.Comment.elements * Item.t list 1177 1183 (** Returns [header_doc, content]. *) 1178 1184 end = struct 1179 1185 let internal_module m = ··· 1242 1248 | Exception e -> continue @@ exn e 1243 1249 | Value v -> continue @@ value v 1244 1250 | Open o -> 1245 - let items = Sectioning.comment_items o.doc in 1251 + let items = Sectioning.comment_items o.doc.elements in 1246 1252 loop rest (List.rev_append items acc_items) 1247 1253 | Comment `Stop -> 1248 1254 let rest = ··· 1252 1258 in 1253 1259 loop rest acc_items 1254 1260 | Comment (`Docs c) -> 1255 - let items = Sectioning.comment_items c in 1261 + let items = Sectioning.comment_items c.elements in 1256 1262 loop rest (List.rev_append items acc_items)) 1257 1263 in 1258 - (Lang.extract_signature_doc s, loop s.items []) 1264 + ((Lang.extract_signature_doc s).elements, loop s.items []) 1259 1265 1260 1266 and functor_parameter : 1261 1267 Odoc_model.Lang.FunctorParameter.parameter -> DocumentedSrc.t = ··· 1319 1325 let source_anchor = None in 1320 1326 let modname = Paths.Identifier.name t.id in 1321 1327 let modname, expansion_doc, mty = 1322 - module_type_manifest ~subst:true ~source_anchor modname t.id t.doc 1323 - (Some t.manifest) prefix 1328 + module_type_manifest ~subst:true ~source_anchor modname t.id 1329 + t.doc.elements (Some t.manifest) prefix 1324 1330 in 1325 1331 let content = 1326 1332 O.documentedSrc (prefix ++ modname) ··· 1330 1336 in 1331 1337 let attr = [ "module-type" ] in 1332 1338 let anchor = path_to_id t.id in 1333 - let doc = Comment.synopsis ~decl_doc:t.doc ~expansion_doc in 1339 + let doc = Comment.synopsis ~decl_doc:t.doc.elements ~expansion_doc in 1334 1340 Item.Declaration { attr; anchor; doc; content; source_anchor } 1335 1341 1336 1342 and simple_expansion : 1337 1343 Odoc_model.Lang.ModuleType.simple_expansion -> 1338 - Comment.Comment.docs * Item.t list = 1344 + Comment.Comment.elements * Item.t list = 1339 1345 fun t -> 1340 1346 let rec extract_functor_params 1341 1347 (f : Odoc_model.Lang.ModuleType.simple_expansion) = ··· 1373 1379 1374 1380 and expansion_of_module_type_expr : 1375 1381 Odoc_model.Lang.ModuleType.expr -> 1376 - (Comment.Comment.docs * Item.t list) option = 1382 + (Comment.Comment.elements * Item.t list) option = 1377 1383 fun t -> 1378 1384 let rec simple_expansion_of (t : Odoc_model.Lang.ModuleType.expr) = 1379 1385 match t with ··· 1417 1423 let url = Url.Path.from_identifier t.id in 1418 1424 let link = path url [ inline @@ Text modname ] in 1419 1425 let page = 1420 - make_expansion_page ~source_anchor url [ t.doc; expansion_doc ] 1426 + make_expansion_page ~source_anchor url 1427 + [ t.doc.elements; expansion_doc ] 1421 1428 items 1422 1429 in 1423 1430 (link, status, Some page, Some expansion_doc) ··· 1436 1443 in 1437 1444 let attr = [ "module" ] in 1438 1445 let anchor = path_to_id t.id in 1439 - let doc = Comment.synopsis ~decl_doc:t.doc ~expansion_doc in 1446 + let doc = Comment.synopsis ~decl_doc:t.doc.elements ~expansion_doc in 1440 1447 Item.Declaration { attr; anchor; doc; content; source_anchor } 1441 1448 1442 1449 and simple_expansion_in_decl (base : Paths.Identifier.Module.t) se = ··· 1501 1508 let modname = Paths.Identifier.name t.id in 1502 1509 let source_anchor = source_anchor t.source_loc in 1503 1510 let modname, expansion_doc, mty = 1504 - module_type_manifest ~subst:false ~source_anchor modname t.id t.doc 1505 - t.expr prefix 1511 + module_type_manifest ~subst:false ~source_anchor modname t.id 1512 + t.doc.elements t.expr prefix 1506 1513 in 1507 1514 let content = 1508 1515 O.documentedSrc (prefix ++ modname) ··· 1512 1519 in 1513 1520 let attr = [ "module-type" ] in 1514 1521 let anchor = path_to_id t.id in 1515 - let doc = Comment.synopsis ~decl_doc:t.doc ~expansion_doc in 1522 + let doc = Comment.synopsis ~decl_doc:t.doc.elements ~expansion_doc in 1516 1523 Item.Declaration { attr; anchor; doc; content; source_anchor } 1517 1524 1518 1525 and umty_hidden : Odoc_model.Lang.ModuleType.U.expr -> bool = function ··· 1772 1779 in*) 1773 1780 (*let title = Odoc_model.Names.PageName.to_string name in*) 1774 1781 let url = Url.Path.from_identifier t.name in 1775 - let preamble, items = Sectioning.docs t.content in 1782 + let preamble, items = Sectioning.docs t.content.elements in 1776 1783 let source_anchor = None in 1777 1784 Document.Page { Page.preamble; items; url; source_anchor } 1778 1785
+1 -1
src/document/sidebar.ml
··· 94 94 | Page { short_title = None; _ } -> 95 95 let title = 96 96 let open Odoc_model in 97 - match Comment.find_zero_heading entry.doc with 97 + match Comment.find_zero_heading entry.doc.elements with 98 98 | Some t -> t 99 99 | None -> 100 100 let name =
+6 -1
src/index/skeleton.ml
··· 8 8 module Entry = struct 9 9 let of_comp_unit (u : Compilation_unit.t) = 10 10 let has_expansion = true in 11 - let doc = match u.content with Pack _ -> [] | Module m -> m.doc in 11 + let doc = 12 + match u.content with 13 + | Pack _ -> 14 + { Odoc_model.Comment.elements = []; suppress_warnings = false } 15 + | Module m -> m.doc 16 + in 12 17 Entry.entry ~id:u.id ~doc ~kind:(Module { has_expansion }) 13 18 14 19 let of_module (m : Module.t) =
+5 -3
src/index/skeleton_of.ml
··· 39 39 try_ Astring.String.compare by_name @@ fun () -> 0 40 40 41 41 let rec t_of_in_progress (dir : In_progress.in_progress) : t = 42 + let empty_doc = { Comment.elements = []; suppress_warnings = false } in 43 + 42 44 let entry_of_page page = 43 45 let kind = Entry.Page page.Lang.Page.frontmatter in 44 46 let doc = page.content in ··· 47 49 in 48 50 let entry_of_impl id = 49 51 let kind = Entry.Impl in 50 - let doc = [] in 52 + let doc = empty_doc in 51 53 Entry.entry ~kind ~doc ~id 52 54 in 53 55 let children_order, index = ··· 61 63 match In_progress.root_dir dir with 62 64 | Some id -> 63 65 let kind = Entry.Dir in 64 - let doc = [] in 66 + let doc = empty_doc in 65 67 Entry.entry ~kind ~doc ~id 66 68 | None -> 67 69 let id = ··· 69 71 Id.Mk.leaf_page (None, Names.PageName.make_std "index") 70 72 in 71 73 let kind = Entry.Dir in 72 - let doc = [] in 74 + let doc = empty_doc in 73 75 Entry.entry ~kind ~doc ~id 74 76 in 75 77 (None, entry)
+69 -53
src/loader/cmi.ml
··· 25 25 module Env = Ident_env 26 26 module Paths = Odoc_model.Paths 27 27 28 + 29 + type env = { 30 + ident_env : Env.t; 31 + suppress_warnings : bool; (** suppress warnings *) 32 + } 33 + 34 + let empty_doc = { Odoc_model.Comment.elements = []; suppress_warnings = false } 35 + 28 36 module Compat = struct 29 37 #if OCAML_VERSION >= (4, 14, 0) 30 38 #if OCAML_VERSION >= (5, 3, 0) ··· 458 466 let typs = List.map (read_type_expr env) typs in 459 467 Tuple typs 460 468 | Tconstr(p, params, _) -> 461 - let p = Env.Path.read_type env p in 469 + let p = Env.Path.read_type env.ident_env p in 462 470 let params = List.map (read_type_expr env) params in 463 471 Constr(p, params) 464 472 | Tvariant row -> read_row env px row ··· 479 487 let eqs = List.combine frags tyl in 480 488 #endif 481 489 let open TypeExpr.Package in 482 - let path = Env.Path.read_module_type env p in 490 + let path = Env.Path.read_module_type env.ident_env p in 483 491 let substitutions = 484 492 List.map 485 493 (fun (frag,typ) -> ··· 522 530 let all_present = List.length present = List.length sorted_fields in 523 531 match Compat.get_row_name row with 524 532 | Some(p, params) when namable_row row -> 525 - let p = Env.Path.read_type env p in 533 + let p = Env.Path.read_type env.ident_env p in 526 534 let params = List.map (read_type_expr env) params in 527 535 if Compat.row_closed row && all_present then 528 536 Constr (p, params) ··· 535 543 let elements = 536 544 List.map 537 545 (fun (name, f) -> 546 + let doc = empty_doc in 538 547 match Compat.row_field_repr f with 539 548 | Rpresent None -> 540 - Constructor {name; constant = true; arguments = []; doc = []} 549 + Constructor {name; constant = true; arguments = []; doc} 541 550 | Rpresent (Some typ) -> 542 551 Constructor { 543 552 name; 544 553 constant = false; 545 554 arguments = [read_type_expr env typ]; 546 - doc = []; 555 + doc; 547 556 } 548 557 #if OCAML_VERSION >= (4, 14, 0) 549 558 | Reither(constant, typs, _) -> ··· 553 562 let arguments = 554 563 List.map (read_type_expr env) typs 555 564 in 556 - Constructor {name; constant; arguments; doc = []} 565 + Constructor {name; constant; arguments; doc} 557 566 | Rabsent -> assert false) 558 567 sorted_fields 559 568 in ··· 600 609 in 601 610 Object {fields = methods; open_} 602 611 | Some (p, _ :: params) -> 603 - let p = Env.Path.read_class_type env p in 612 + let p = Env.Path.read_class_type env.ident_env p in 604 613 let params = List.map (read_type_expr env) params in 605 614 Class (p, params) 606 615 | _ -> assert false 607 616 end 608 617 609 - let read_value_description env parent id vd = 618 + let read_value_description ({ident_env ; suppress_warnings} as env) parent id vd = 610 619 let open Signature in 611 - let id = Env.find_value_identifier env id in 620 + let id = Env.find_value_identifier ident_env id in 612 621 let source_loc = None in 613 622 let container = 614 623 (parent : Identifier.Signature.t :> Identifier.LabelParent.t) 615 624 in 616 - let doc = Doc_attr.attached_no_tag container vd.val_attributes in 625 + let doc = Doc_attr.attached_no_tag ~suppress_warnings container vd.val_attributes in 617 626 mark_value_description vd; 618 627 let type_ = read_type_expr env vd.val_type in 619 628 let value = ··· 635 644 let name = Ident.name ld.ld_id in 636 645 let id = Identifier.Mk.field (parent, Odoc_model.Names.FieldName.make_std name) in 637 646 let doc = 638 - Doc_attr.attached_no_tag 647 + Doc_attr.attached_no_tag ~suppress_warnings:env.suppress_warnings 639 648 (parent :> Identifier.LabelParent.t) ld.ld_attributes 640 649 in 641 650 let mutable_ = (ld.ld_mutable = Mutable) in ··· 658 667 659 668 let read_constructor_declaration env parent cd = 660 669 let open TypeDecl.Constructor in 661 - let id = Ident_env.find_constructor_identifier env cd.cd_id in 670 + let id = Ident_env.find_constructor_identifier env.ident_env cd.cd_id in 662 671 let container = (parent :> Identifier.LabelParent.t) in 663 - let doc = Doc_attr.attached_no_tag container cd.cd_attributes in 672 + let doc = Doc_attr.attached_no_tag ~suppress_warnings:env.suppress_warnings container cd.cd_attributes in 664 673 let args = 665 674 read_constructor_declaration_arguments env 666 675 (parent :> Identifier.FieldParent.t) cd.cd_args ··· 735 744 let open ClassSignature in 736 745 read_type_constraints env params 737 746 |> List.map (fun (left, right) -> 738 - Constraint { Constraint.left; right; doc = [] }) 747 + Constraint { Constraint.left; right; doc = empty_doc }) 739 748 740 749 let read_type_declaration env parent id decl = 741 750 let open TypeDecl in 742 - let id = Env.find_type_identifier env id in 751 + let id = Env.find_type_identifier env.ident_env id in 743 752 let source_loc = None in 744 753 let container = (parent : Identifier.Signature.t :> Identifier.LabelParent.t) in 745 754 let doc, canonical = 746 - Doc_attr.attached Odoc_model.Semantics.Expect_canonical container decl.type_attributes 755 + Doc_attr.attached ~suppress_warnings:env.suppress_warnings Odoc_model.Semantics.Expect_canonical container decl.type_attributes 747 756 in 748 757 let canonical = match canonical with | None -> None | Some s -> Doc_attr.conv_canonical_type s in 749 758 let params = mark_type_declaration decl in ··· 779 788 780 789 let read_extension_constructor env parent id ext = 781 790 let open Extension.Constructor in 782 - let id = Env.find_extension_identifier env id in 791 + let id = Env.find_extension_identifier env.ident_env id in 783 792 let source_loc = None in 784 793 let container = (parent : Identifier.Signature.t :> Identifier.LabelParent.t) in 785 - let doc = Doc_attr.attached_no_tag container ext.ext_attributes in 794 + let doc = Doc_attr.attached_no_tag ~suppress_warnings:env.suppress_warnings container ext.ext_attributes in 786 795 let args = 787 796 read_constructor_declaration_arguments env 788 797 (parent : Identifier.Signature.t :> Identifier.FieldParent.t) ext.ext_args ··· 792 801 793 802 let read_type_extension env parent id ext rest = 794 803 let open Extension in 795 - let type_path = Env.Path.read_type env ext.ext_type_path in 804 + let type_path = Env.Path.read_type env.ident_env ext.ext_type_path in 796 805 let doc = Doc_attr.empty in 797 806 let type_params = mark_type_extension' ext rest in 798 807 let first = read_extension_constructor env parent id ext in ··· 812 821 813 822 let read_exception env parent id ext = 814 823 let open Exception in 815 - let id = Env.find_exception_identifier env id in 824 + let id = Env.find_exception_identifier env.ident_env id in 816 825 let source_loc = None in 817 826 let container = (parent : Identifier.Signature.t :> Identifier.LabelParent.t) in 818 - let doc = Doc_attr.attached_no_tag container ext.ext_attributes in 827 + let doc = Doc_attr.attached_no_tag ~suppress_warnings:env.suppress_warnings container ext.ext_attributes in 819 828 mark_exception ext; 820 829 let args = 821 830 read_constructor_declaration_arguments env ··· 854 863 || List.exists aliasable params 855 864 then read_class_signature env parent params cty 856 865 else begin 857 - let p = Env.Path.read_class_type env p in 866 + let p = Env.Path.read_class_type env.ident_env p in 858 867 let params = List.map (read_type_expr env) params in 859 868 Constr(p, params) 860 869 end ··· 881 890 List.map (read_method env parent (Compat.csig_concr csig)) methods 882 891 in 883 892 let items = constraints @ instance_variables @ methods in 884 - Signature {self; items; doc = []} 893 + Signature {self; items; doc = empty_doc} 885 894 | Cty_arrow _ -> assert false 886 895 887 896 let rec read_virtual = function ··· 906 915 907 916 let read_class_type_declaration env parent id cltd = 908 917 let open ClassType in 909 - let id = Env.find_class_type_identifier env id in 918 + let id = Env.find_class_type_identifier env.ident_env id in 910 919 let source_loc = None in 911 920 let container = (parent : Identifier.Signature.t :> Identifier.LabelParent.t) in 912 - let doc = Doc_attr.attached_no_tag container cltd.clty_attributes in 921 + let doc = Doc_attr.attached_no_tag ~suppress_warnings:env.suppress_warnings container cltd.clty_attributes in 913 922 mark_class_type_declaration cltd; 914 923 let params = 915 924 List.map2 ··· 942 951 943 952 let read_class_declaration env parent id cld = 944 953 let open Class in 945 - let id = Env.find_class_identifier env id in 954 + let id = Env.find_class_identifier env.ident_env id in 946 955 let source_loc = None in 947 956 let container = (parent : Identifier.Signature.t :> Identifier.LabelParent.t) in 948 - let doc = Doc_attr.attached_no_tag container cld.cty_attributes in 957 + let doc = Doc_attr.attached_no_tag ~suppress_warnings:env.suppress_warnings container cld.cty_attributes in 949 958 mark_class_declaration cld; 950 959 let params = 951 960 List.map2 ··· 961 970 let rec read_module_type env parent (mty : Odoc_model.Compat.module_type) = 962 971 let open ModuleType in 963 972 match mty with 964 - | Mty_ident p -> Path {p_path = Env.Path.read_module_type env p; p_expansion=None } 973 + | Mty_ident p -> Path {p_path = Env.Path.read_module_type env.ident_env p; p_expansion=None } 965 974 | Mty_signature sg -> Signature (read_signature env parent sg) 966 975 | Mty_functor(parameter, res) -> 967 976 let f_parameter, env = ··· 970 979 | Named (id_opt, arg) -> 971 980 let id, env = match id_opt with 972 981 | None -> Identifier.Mk.parameter(parent, Odoc_model.Names.ModuleName.make_std "_"), env 973 - | Some id -> let env = Env.add_parameter parent id (ModuleName.of_ident id) env in 974 - Ident_env.find_parameter_identifier env id, env 982 + | Some id -> let e' = Env.add_parameter parent id (ModuleName.of_ident id) env.ident_env in 983 + Ident_env.find_parameter_identifier e' id, {env with ident_env = e'} 975 984 in 976 985 let arg = read_module_type env (id :> Identifier.Signature.t) arg in 977 986 Odoc_model.Lang.FunctorParameter.Named ({ FunctorParameter. id; expr = arg }), env ··· 979 988 let res = read_module_type env (Identifier.Mk.result parent) res in 980 989 Functor( f_parameter, res) 981 990 | Mty_alias p -> 982 - let t_original_path = Env.Path.read_module env p in 991 + let t_original_path = Env.Path.read_module env.ident_env p in 983 992 let t_desc = ModPath t_original_path in 984 993 TypeOf { t_desc; t_expansion = None; t_original_path } 985 994 986 995 and read_module_type_declaration env parent id (mtd : Odoc_model.Compat.modtype_declaration) = 987 996 let open ModuleType in 988 - let id = Env.find_module_type env id in 997 + let id = Env.find_module_type env.ident_env id in 989 998 let source_loc = None in 990 999 let container = (parent : Identifier.Signature.t :> Identifier.LabelParent.t) in 991 - let doc, canonical = Doc_attr.attached Odoc_model.Semantics.Expect_canonical container mtd.mtd_attributes in 1000 + let doc, canonical = Doc_attr.attached ~suppress_warnings:env.suppress_warnings Odoc_model.Semantics.Expect_canonical container mtd.mtd_attributes in 992 1001 let canonical = match canonical with | None -> None | Some s -> Doc_attr.conv_canonical_module_type s in 993 1002 let expr = opt_map (read_module_type env (id :> Identifier.Signature.t)) mtd.mtd_type in 994 1003 {id; source_loc; doc; canonical; expr } 995 1004 996 1005 and read_module_declaration env parent ident (md : Odoc_model.Compat.module_declaration) = 997 1006 let open Module in 998 - let id = (Env.find_module_identifier env ident :> Identifier.Module.t) in 1007 + let id = (Env.find_module_identifier env.ident_env ident :> Identifier.Module.t) in 999 1008 let source_loc = None in 1000 1009 let container = (parent : Identifier.Signature.t :> Identifier.LabelParent.t) in 1001 - let doc, canonical = Doc_attr.attached Odoc_model.Semantics.Expect_canonical container md.md_attributes in 1010 + let doc, canonical = Doc_attr.attached ~suppress_warnings:env.suppress_warnings Odoc_model.Semantics.Expect_canonical container md.md_attributes in 1002 1011 let canonical = match canonical with | None -> None | Some s -> Some (Doc_attr.conv_canonical_module s) in 1003 1012 let type_ = 1004 1013 match md.md_type with 1005 - | Mty_alias p -> Alias (Env.Path.read_module env p, None) 1014 + | Mty_alias p -> Alias (Env.Path.read_module env.ident_env p, None) 1006 1015 | _ -> ModuleType (read_module_type env (id :> Identifier.Signature.t) md.md_type) 1007 1016 in 1008 1017 let hidden = ··· 1035 1044 | Sig_value(id, v, _) :: rest -> 1036 1045 let vd = read_value_description env parent id v in 1037 1046 let shadowed = 1038 - if Env.is_shadowed env id 1047 + if Env.is_shadowed env.ident_env id 1039 1048 then 1040 - let identifier = Env.find_value_identifier env id in 1049 + let identifier = Env.find_value_identifier env.ident_env id in 1041 1050 match identifier.iv with 1042 1051 | `Value (_, n) -> { shadowed with s_values = (Odoc_model.Names.parenthesise (Ident.name id), n) :: shadowed.s_values } 1043 1052 else shadowed ··· 1049 1058 | Sig_type(id, decl, rec_status, _)::rest -> 1050 1059 let decl = read_type_declaration env parent id decl in 1051 1060 let shadowed = 1052 - if Env.is_shadowed env id 1061 + if Env.is_shadowed env.ident_env id 1053 1062 then 1054 - let identifier = Env.find_type_identifier env id in 1063 + let identifier = Env.find_type_identifier env.ident_env id in 1055 1064 let `Type (_, name) = identifier.iv in 1056 1065 { shadowed with s_types = (Ident.name id, name) :: shadowed.s_types } 1057 1066 else shadowed ··· 1077 1086 | Sig_module (id, _, md, rec_status, _)::rest -> 1078 1087 let md = read_module_declaration env parent id md in 1079 1088 let shadowed = 1080 - if Env.is_shadowed env id 1089 + if Env.is_shadowed env.ident_env id 1081 1090 then 1082 - let identifier = Env.find_module_identifier env id in 1091 + let identifier = Env.find_module_identifier env.ident_env id in 1083 1092 let name = 1084 1093 match identifier.iv with 1085 1094 | `Module (_, n) -> n ··· 1093 1102 | Sig_modtype(id, mtd, _) :: rest -> 1094 1103 let mtd = read_module_type_declaration env parent id mtd in 1095 1104 let shadowed = 1096 - if Env.is_shadowed env id 1105 + if Env.is_shadowed env.ident_env id 1097 1106 then 1098 - let identifier = Env.find_module_type env id in 1107 + let identifier = Env.find_module_type env.ident_env id in 1099 1108 let name = 1100 1109 match identifier.iv with 1101 1110 | `ModuleType (_, n) -> n ··· 1114 1123 #endif 1115 1124 let cl = read_class_declaration env parent id cl in 1116 1125 let shadowed = 1117 - if Env.is_shadowed env id 1126 + if Env.is_shadowed env.ident_env id 1118 1127 then 1119 - let identifier = Env.find_class_identifier env id in 1128 + let identifier = Env.find_class_identifier env.ident_env id in 1120 1129 let name = 1121 1130 match identifier.iv with 1122 1131 | `Class (_, n) -> n ··· 1133 1142 #endif 1134 1143 let cltyp = read_class_type_declaration env parent id cltyp in 1135 1144 let shadowed = 1136 - if Env.is_shadowed env id 1145 + if Env.is_shadowed env.ident_env id 1137 1146 then 1138 - let identifier = Env.find_class_type_identifier env id in 1147 + let identifier = Env.find_class_type_identifier env.ident_env id in 1139 1148 let name = 1140 1149 match identifier.iv with 1141 1150 | `ClassType (_, n) -> n ··· 1152 1161 | Sig_class_type _ :: _ 1153 1162 | Sig_class _ :: _ -> assert false 1154 1163 1155 - | [] -> ({items = List.rev acc; compiled=false; removed = []; doc = [] }, shadowed) 1164 + | [] -> ({items = List.rev acc; compiled=false; removed = []; doc = empty_doc }, shadowed) 1156 1165 in 1157 1166 loop ([],{s_modules=[]; s_module_types=[]; s_values=[];s_types=[]; s_classes=[]; s_class_types=[]}) items 1158 1167 1159 1168 and read_signature env parent (items : Odoc_model.Compat.signature) = 1160 - let env = Env.handle_signature_type_items parent items env in 1169 + let e' = Env.handle_signature_type_items parent items env.ident_env in 1170 + let env = { env with ident_env = e' } in 1161 1171 fst @@ read_signature_noenv env parent items 1162 1172 1163 1173 1164 - let read_interface root name intf = 1165 - let id = Identifier.Mk.root (root, Odoc_model.Names.ModuleName.make_std name) in 1166 - let items = read_signature (Env.empty ()) id intf in 1174 + let read_interface root name suppress_warnings intf = 1175 + let id = 1176 + Identifier.Mk.root (root, Odoc_model.Names.ModuleName.make_std name) 1177 + in 1178 + let items = 1179 + read_signature 1180 + { ident_env = Env.empty (); suppress_warnings } 1181 + id intf 1182 + in 1167 1183 (id, items)
+18 -10
src/loader/cmi.mli
··· 18 18 19 19 module Paths = Odoc_model.Paths 20 20 21 + 22 + type env = { 23 + ident_env : Ident_env.t; (** Environment *) 24 + suppress_warnings : bool (** Suppress warnings *) 25 + } 26 + 21 27 val read_interface : 22 28 Odoc_model.Paths.Identifier.ContainerPage.t option -> 23 29 string -> 30 + bool -> 24 31 Odoc_model.Compat.signature -> 25 32 Paths.Identifier.RootModule.t * Odoc_model.Lang.Signature.t 26 33 ··· 32 39 33 40 val mark_type_expr : Types.type_expr -> unit 34 41 35 - val read_type_expr : Ident_env.t -> 42 + val read_type_expr : env -> 36 43 Types.type_expr -> Odoc_model.Lang.TypeExpr.t 37 44 38 45 val mark_type_extension : Types.type_expr list -> ··· 46 53 47 54 val read_self_type : Types.type_expr -> Odoc_model.Lang.TypeExpr.t option 48 55 49 - val read_type_constraints : Ident_env.t -> Types.type_expr list -> 56 + val read_type_constraints : env -> Types.type_expr list -> 50 57 (Odoc_model.Lang.TypeExpr.t 51 58 * Odoc_model.Lang.TypeExpr.t) list 52 59 53 60 val read_class_constraints : 54 - Ident_env.t -> 61 + env -> 55 62 Types.type_expr list -> 56 63 Odoc_model.Lang.ClassSignature.item list 57 64 58 - val read_class_signature : Ident_env.t -> 65 + val read_class_signature : env -> 59 66 Paths.Identifier.ClassSignature.t -> 60 67 Types.type_expr list -> Types.class_type -> 61 68 Odoc_model.Lang.ClassType.expr 62 69 63 - val read_class_type : Ident_env.t -> 70 + val read_class_type : env -> 64 71 Paths.Identifier.ClassSignature.t -> 65 72 Types.type_expr list -> Types.class_type -> 66 73 Odoc_model.Lang.Class.decl 67 74 68 - val read_module_type : Ident_env.t -> 75 + val read_module_type : env -> 69 76 Paths.Identifier.Signature.t -> 70 77 Odoc_model.Compat.module_type -> Odoc_model.Lang.ModuleType.expr 71 78 72 - val read_signature_noenv : Ident_env.t -> 79 + val read_signature_noenv : env -> 73 80 Paths.Identifier.Signature.t -> 74 81 Odoc_model.Compat.signature -> 75 82 (Odoc_model.Lang.Signature.t * Odoc_model.Lang.Include.shadowed) 76 83 77 - val read_signature : Ident_env.t -> 84 + val read_signature : env -> 78 85 Paths.Identifier.Signature.t -> 79 86 Odoc_model.Compat.signature -> Odoc_model.Lang.Signature.t 80 87 81 88 82 - val read_extension_constructor : Ident_env.t -> 89 + val read_extension_constructor : env -> 83 90 Paths.Identifier.Signature.t -> 84 91 Ident.t -> Types.extension_constructor -> 85 92 Odoc_model.Lang.Extension.Constructor.t 86 93 87 - val read_exception : Ident_env.t -> 94 + val read_exception : env -> 88 95 Paths.Identifier.Signature.t -> Ident.t -> 89 96 Types.extension_constructor -> Odoc_model.Lang.Exception.t 97 +
+49 -34
src/loader/cmt.ml
··· 25 25 26 26 module Env = Ident_env 27 27 28 + type env = Cmi.env = { 29 + ident_env : Ident_env.t; 30 + suppress_warnings : bool; 31 + } 32 + 33 + 28 34 let read_core_type env ctyp = 29 35 Cmi.read_type_expr env ctyp.ctyp_type 30 36 ··· 39 45 | Tpat_var(id,_,_uid) -> 40 46 #endif 41 47 let open Value in 42 - let id = Env.find_value_identifier env id in 48 + let id = Env.find_value_identifier env.ident_env id in 43 49 Cmi.mark_type_expr pat.pat_type; 44 50 let type_ = Cmi.read_type_expr env pat.pat_type in 45 51 let value = Abstract in ··· 50 56 | Tpat_alias(pat, id, _,_) -> 51 57 #endif 52 58 let open Value in 53 - let id = Env.find_value_identifier env id in 59 + let id = Env.find_value_identifier env.ident_env id in 54 60 Cmi.mark_type_expr pat.pat_type; 55 61 let type_ = Cmi.read_type_expr env pat.pat_type in 56 62 let value = Abstract in ··· 85 91 86 92 let read_value_binding env parent vb = 87 93 let container = (parent : Identifier.Signature.t :> Identifier.LabelParent.t) in 88 - let doc = Doc_attr.attached_no_tag container vb.vb_attributes in 94 + let doc = Doc_attr.attached_no_tag ~suppress_warnings:env.suppress_warnings container vb.vb_attributes in 89 95 read_pattern env parent doc vb.vb_pat 90 96 91 97 let read_value_bindings env parent vbs = ··· 95 101 (fun acc vb -> 96 102 let open Signature in 97 103 let comments = 98 - Doc_attr.standalone_multiple container vb.vb_attributes in 104 + Doc_attr.standalone_multiple container ~suppress_warnings:env.suppress_warnings vb.vb_attributes in 99 105 let comments = List.map (fun com -> Comment com) comments in 100 106 let vb = read_value_binding env parent vb in 101 107 List.rev_append vb (List.rev_append comments acc)) ··· 105 111 106 112 let read_type_extension env parent tyext = 107 113 let open Extension in 108 - let type_path = Env.Path.read_type env tyext.tyext_path in 114 + let type_path = Env.Path.read_type env.ident_env tyext.tyext_path in 109 115 let container = (parent : Identifier.Signature.t :> Identifier.LabelParent.t) in 110 - let doc = Doc_attr.attached_no_tag container tyext.tyext_attributes in 116 + let doc = Doc_attr.attached_no_tag ~suppress_warnings:env.suppress_warnings container tyext.tyext_attributes in 111 117 let type_params = 112 118 List.map (fun (ctyp, _) -> ctyp.ctyp_type) tyext.tyext_params 113 119 in ··· 136 142 rendered. For example, [constraint] items are read separately and not 137 143 associated with their comment. *) 138 144 let mk_class_comment = function 139 - | [] -> None 145 + | { Odoc_model.Comment.elements = []; _} -> None 140 146 | doc -> Some (ClassSignature.Comment (`Docs doc)) 141 147 142 148 let rec read_class_type_field env parent ctf = 143 149 let open ClassSignature in 144 150 let open Odoc_model.Names in 145 151 let container = (parent : Identifier.ClassSignature.t :> Identifier.LabelParent.t) in 146 - let doc = Doc_attr.attached_no_tag container ctf.ctf_attributes in 152 + let doc = Doc_attr.attached_no_tag ~suppress_warnings:env.suppress_warnings container ctf.ctf_attributes in 147 153 match ctf.ctf_desc with 148 154 | Tctf_val(name, mutable_, virtual_, typ) -> 149 155 let open InstanceVariable in ··· 164 170 let expr = read_class_signature env parent [] cltyp in 165 171 Some (Inherit {Inherit.expr; doc}) 166 172 | Tctf_attribute attr -> 167 - match Doc_attr.standalone container attr with 173 + match Doc_attr.standalone container ~suppress_warnings:env.suppress_warnings attr with 168 174 | None -> None 169 175 | Some doc -> Some (Comment doc) 170 176 ··· 172 178 let open ClassType in 173 179 match cltyp.cltyp_desc with 174 180 | Tcty_constr(p, _, params) -> 175 - let p = Env.Path.read_class_type env p in 181 + let p = Env.Path.read_class_type env.ident_env p in 176 182 let params = List.map (read_core_type env) params in 177 183 Constr(p, params) 178 184 | Tcty_signature csig -> ··· 193 199 let items, (doc, doc_post) = Doc_attr.extract_top_comment_class items in 194 200 let items = 195 201 match doc_post with 196 - | [] -> items 202 + | { elements = []; _ } -> items 197 203 | _ -> Comment (`Docs doc_post) :: items 198 204 in 199 205 Signature {self; items; doc} ··· 224 230 let open ClassSignature in 225 231 let open Odoc_model.Names in 226 232 let container = (parent : Identifier.ClassSignature.t :> Identifier.LabelParent.t) in 227 - let doc = Doc_attr.attached_no_tag container (cf.cf_attributes) in 233 + let doc = Doc_attr.attached_no_tag ~suppress_warnings:env.suppress_warnings container (cf.cf_attributes) in 228 234 match cf.cf_desc with 229 235 | Tcf_val({txt = name; _}, mutable_, _, kind, _) -> 230 236 let open InstanceVariable in ··· 264 270 Some (Inherit {Inherit.expr; doc}) 265 271 | Tcf_initializer _ -> mk_class_comment doc 266 272 | Tcf_attribute attr -> 267 - match Doc_attr.standalone container attr with 273 + match Doc_attr.standalone container ~suppress_warnings:env.suppress_warnings attr with 268 274 | None -> None 269 275 | Some doc -> Some (Comment doc) 270 276 ··· 289 295 let items, (doc, doc_post) = Doc_attr.extract_top_comment_class items in 290 296 let items = 291 297 match doc_post with 292 - | [] -> items 298 + | { elements = []; _ } -> items 293 299 | _ -> Comment (`Docs doc_post) :: items 294 300 in 295 301 Signature {self; items; doc} ··· 331 337 332 338 let read_class_declaration env parent cld = 333 339 let open Class in 334 - let id = Env.find_class_identifier env cld.ci_id_class in 340 + let id = Env.find_class_identifier env.ident_env cld.ci_id_class in 335 341 let source_loc = None in 336 342 let container = (parent : Identifier.Signature.t :> Identifier.LabelParent.t) in 337 - let doc = Doc_attr.attached_no_tag container cld.ci_attributes in 343 + let doc = Doc_attr.attached_no_tag ~suppress_warnings:env.suppress_warnings container cld.ci_attributes in 338 344 Cmi.mark_class_declaration cld.ci_decl; 339 345 let virtual_ = (cld.ci_virt = Virtual) in 340 346 let clparams = ··· 352 358 let container = (parent : Identifier.Signature.t :> Identifier.LabelParent.t) in 353 359 let open Signature in 354 360 List.fold_left begin fun (acc, recursive) cld -> 355 - let comments = Doc_attr.standalone_multiple container cld.ci_attributes in 361 + let comments = Doc_attr.standalone_multiple container ~suppress_warnings:env.suppress_warnings cld.ci_attributes in 356 362 let comments = List.map (fun com -> Comment com) comments in 357 363 let cld = read_class_declaration env parent cld in 358 364 ((Class (recursive, cld))::(List.rev_append comments acc), And) ··· 378 384 let id, env = 379 385 match id_opt with 380 386 | None -> Identifier.Mk.parameter (parent, Odoc_model.Names.ModuleName.make_std "_"), env 381 - | Some id -> let env = Env.add_parameter parent id (ModuleName.of_ident id) env in 382 - Env.find_parameter_identifier env id, env 387 + | Some id -> let e' = Env.add_parameter parent id (ModuleName.of_ident id) env.ident_env in 388 + Env.find_parameter_identifier e' id, {env with ident_env=e'} 383 389 in 384 390 let arg = Cmti.read_module_type env (id :> Identifier.Signature.t) label_parent arg in 385 391 ··· 435 441 match mb.mb_id with 436 442 | None -> None 437 443 | Some id -> 438 - let mid = Env.find_module_identifier env id in 444 + let mid = Env.find_module_identifier env.ident_env id in 439 445 #else 440 - let mid = Env.find_module_identifier env mb.mb_id in 446 + let mid = Env.find_module_identifier env.ident_env mb.mb_id in 441 447 #endif 442 448 let id = (mid :> Identifier.Module.t) in 443 449 let source_loc = None in 444 450 let container = (parent : Identifier.Signature.t :> Identifier.LabelParent.t) in 445 - let doc, canonical = Doc_attr.attached Odoc_model.Semantics.Expect_canonical container mb.mb_attributes in 451 + let doc, canonical = Doc_attr.attached ~suppress_warnings:env.suppress_warnings Odoc_model.Semantics.Expect_canonical container mb.mb_attributes in 446 452 let type_, canonical = 447 453 match unwrap_module_expr_desc mb.mb_expr.mod_desc with 448 - | Tmod_ident (p, _) -> (Alias (Env.Path.read_module env p, None), canonical) 454 + | Tmod_ident (p, _) -> (Alias (Env.Path.read_module env.ident_env p, None), canonical) 449 455 | _ -> 450 456 let id = (id :> Identifier.Signature.t) in 451 457 let expr, canonical = ··· 473 479 let open Signature in 474 480 List.fold_left 475 481 (fun (acc, recursive) mb -> 476 - let comments = Doc_attr.standalone_multiple container mb.mb_attributes in 482 + let comments = Doc_attr.standalone_multiple container ~suppress_warnings:env.suppress_warnings mb.mb_attributes in 477 483 let comments = List.map (fun com -> Comment com) comments in 478 484 match read_module_binding env parent mb with 479 485 | Some mb -> ··· 543 549 Cmti.read_class_type_declarations env parent cltyps 544 550 | Tstr_attribute attr -> 545 551 let container = (parent : Identifier.Signature.t :> Identifier.LabelParent.t) in 546 - match Doc_attr.standalone container attr with 552 + match Doc_attr.standalone container ~suppress_warnings:env.suppress_warnings attr with 547 553 | None -> [] 548 554 | Some doc -> [Comment doc] 549 555 ··· 551 557 let open Include in 552 558 let loc = Doc_attr.read_location incl.incl_loc in 553 559 let container = (parent : Identifier.Signature.t :> Identifier.LabelParent.t) in 554 - let doc, status = Doc_attr.attached Odoc_model.Semantics.Expect_status container incl.incl_attributes in 560 + let doc, status = Doc_attr.attached ~suppress_warnings:env.suppress_warnings Odoc_model.Semantics.Expect_status container incl.incl_attributes in 555 561 let decl_modty = 556 562 match unwrap_module_expr_desc incl.incl_mod.mod_desc with 557 563 | Tmod_ident(p, _) -> 558 - let p = Env.Path.read_module env p in 564 + let p = Env.Path.read_module env.ident_env p in 559 565 Some (ModuleType.U.TypeOf (ModuleType.StructInclude p, p)) 560 566 | _ -> 561 567 let mty = read_module_expr env parent container incl.incl_mod in ··· 572 578 573 579 and read_open env parent o = 574 580 let container = (parent : Identifier.Signature.t :> Identifier.LabelParent.t) in 575 - let doc = Doc_attr.attached_no_tag container o.open_attributes in 581 + let doc = Doc_attr.attached_no_tag ~suppress_warnings:env.suppress_warnings container o.open_attributes in 576 582 #if OCAML_VERSION >= (4,8,0) 577 583 let signature = o.open_bound_items in 578 584 #else ··· 585 591 'tags. 'tags Odoc_model.Semantics.handle_internal_tags -> _ -> _ -> _ -> 586 592 _ * 'tags = 587 593 fun internal_tags env parent str -> 588 - let env = Env.add_structure_tree_items parent str env in 594 + let e' = Env.add_structure_tree_items parent str env.ident_env in 595 + let env = { env with ident_env=e' } in 589 596 let items, (doc, doc_post), tags = 590 597 let classify item = 591 598 match item.str_desc with ··· 603 610 |> List.rev 604 611 in 605 612 match doc_post with 606 - | [] -> 613 + | { elements = [] ; _} -> 607 614 ({ Signature.items; compiled = false; removed = []; doc }, tags) 608 615 | _ -> 609 616 ({ Signature.items = Comment (`Docs doc_post) :: items; compiled=false; removed = []; doc }, tags) 610 617 611 - let read_implementation root name impl = 612 - let id = Identifier.Mk.root (root, Odoc_model.Names.ModuleName.make_std name) in 618 + let read_implementation root name suppress_warnings impl = 619 + let id = 620 + Identifier.Mk.root (root, Odoc_model.Names.ModuleName.make_std name) 621 + in 613 622 let sg, canonical = 614 - read_structure Odoc_model.Semantics.Expect_canonical (Env.empty ()) id impl 623 + read_structure Odoc_model.Semantics.Expect_canonical 624 + { ident_env = Env.empty (); suppress_warnings } 625 + id impl 615 626 in 616 - let canonical = match canonical with | None -> None | Some s -> Some (Doc_attr.conv_canonical_module s) in 627 + let canonical = 628 + match canonical with 629 + | None -> None 630 + | Some s -> Some (Doc_attr.conv_canonical_module s) 631 + in 617 632 (id, sg, canonical) 618 633 619 634 let _ = Cmti.read_module_expr := read_module_expr
+1
src/loader/cmt.mli
··· 17 17 val read_implementation : 18 18 Odoc_model.Paths.Identifier.ContainerPage.t option -> 19 19 string -> 20 + bool -> 20 21 Typedtree.structure -> 21 22 Odoc_model.Paths.Identifier.RootModule.t 22 23 * Odoc_model.Lang.Signature.t
+72 -57
src/loader/cmti.ml
··· 26 26 module Env = Ident_env 27 27 module Paths = Odoc_model.Paths 28 28 29 - let read_module_expr : (Ident_env.t -> Identifier.Signature.t -> Identifier.LabelParent.t -> Typedtree.module_expr -> ModuleType.expr) ref = ref (fun _ _ _ _ -> failwith "unset") 29 + type env = Cmi.env = { 30 + ident_env : Ident_env.t; 31 + suppress_warnings : bool; 32 + } 33 + 34 + let read_module_expr : (env -> Identifier.Signature.t -> Identifier.LabelParent.t -> Typedtree.module_expr -> ModuleType.expr) ref = ref (fun _ _ _ _ -> failwith "unset") 30 35 31 36 let opt_map f = function 32 37 | None -> None ··· 62 67 let typs = List.map (read_core_type env container) typs in 63 68 Tuple typs 64 69 | Ttyp_constr(p, _, params) -> 65 - let p = Env.Path.read_type env p in 70 + let p = Env.Path.read_type env.ident_env p in 66 71 let params = List.map (read_core_type env container) params in 67 72 Constr(p, params) 68 73 | Ttyp_object(methods, closed) -> ··· 93 98 in 94 99 Object {fields; open_ = (closed = Asttypes.Open)} 95 100 | Ttyp_class(p, _, params) -> 96 - let p = Env.Path.read_class_type env p in 101 + let p = Env.Path.read_class_type env.ident_env p in 97 102 let params = List.map (read_core_type env container) params in 98 103 Class(p, params) 99 104 | Ttyp_alias(typ, var) -> ··· 120 125 #if OCAML_VERSION >= (4,6,0) 121 126 let name = name.txt in 122 127 #endif 123 - let doc = Doc_attr.attached_no_tag container attributes in 128 + let doc = Doc_attr.attached_no_tag ~suppress_warnings:env.suppress_warnings container attributes in 124 129 Constructor {name; constant; arguments; doc} 125 130 | Tinherit typ -> Type (read_core_type env container typ) 126 131 end ··· 136 141 | Ttyp_poly(vars, typ) -> Poly(vars, read_core_type env container typ) 137 142 | Ttyp_package {pack_path; pack_fields; _} -> 138 143 let open TypeExpr.Package in 139 - let path = Env.Path.read_module_type env pack_path in 144 + let path = Env.Path.read_module_type env.ident_env pack_path in 140 145 let substitutions = 141 146 List.map 142 147 (fun (frag, typ) -> ··· 154 159 155 160 let read_value_description env parent vd = 156 161 let open Signature in 157 - let id = Env.find_value_identifier env vd.val_id in 162 + let id = Env.find_value_identifier env.ident_env vd.val_id in 158 163 let source_loc = None in 159 164 let container = 160 165 (parent : Identifier.Signature.t :> Identifier.LabelParent.t) 161 166 in 162 - let doc = Doc_attr.attached_no_tag container vd.val_attributes in 167 + let doc = Doc_attr.attached_no_tag ~suppress_warnings:env.suppress_warnings container vd.val_attributes in 163 168 let type_ = read_core_type env container vd.val_desc in 164 169 let value = 165 170 match vd.val_prim with ··· 203 208 let open Odoc_model.Names in 204 209 let name = Ident.name ld.ld_id in 205 210 let id = Identifier.Mk.field(parent, FieldName.make_std name) in 206 - let doc = Doc_attr.attached_no_tag label_parent ld.ld_attributes in 211 + let doc = Doc_attr.attached_no_tag ~suppress_warnings:env.suppress_warnings label_parent ld.ld_attributes in 207 212 let mutable_ = (ld.ld_mutable = Mutable) in 208 213 let type_ = read_core_type env label_parent ld.ld_type in 209 214 {id; doc; mutable_; type_} ··· 222 227 223 228 let read_constructor_declaration env parent cd = 224 229 let open TypeDecl.Constructor in 225 - let id = Ident_env.find_constructor_identifier env cd.cd_id in 230 + let id = Ident_env.find_constructor_identifier env.ident_env cd.cd_id in 226 231 let container = (parent :> Identifier.FieldParent.t) in 227 232 let label_container = (container :> Identifier.LabelParent.t) in 228 - let doc = Doc_attr.attached_no_tag label_container cd.cd_attributes in 233 + let doc = Doc_attr.attached_no_tag ~suppress_warnings:env.suppress_warnings label_container cd.cd_attributes in 229 234 let args = 230 235 read_constructor_declaration_arguments 231 236 env container label_container cd.cd_args ··· 263 268 264 269 let read_type_declaration env parent decl = 265 270 let open TypeDecl in 266 - let id = Env.find_type_identifier env decl.typ_id in 271 + let id = Env.find_type_identifier env.ident_env decl.typ_id in 267 272 let source_loc = None in 268 273 let container = (parent : Identifier.Signature.t :> Identifier.LabelParent.t) in 269 - let doc, canonical = Doc_attr.attached Odoc_model.Semantics.Expect_canonical container decl.typ_attributes in 274 + let doc, canonical = Doc_attr.attached ~suppress_warnings:env.suppress_warnings Odoc_model.Semantics.Expect_canonical container decl.typ_attributes in 270 275 let canonical = match canonical with | None -> None | Some s -> Doc_attr.conv_canonical_type s in 271 276 let equation = read_type_equation env container decl in 272 277 let representation = read_type_kind env id decl.typ_kind in ··· 282 287 then (acc, recursive) 283 288 else begin 284 289 let comments = 285 - Doc_attr.standalone_multiple container decl.typ_attributes in 290 + Doc_attr.standalone_multiple container ~suppress_warnings:env.suppress_warnings decl.typ_attributes in 286 291 let comments = List.map (fun com -> Comment com) comments in 287 292 let decl = read_type_declaration env parent decl in 288 293 ((Type (recursive, decl)) :: (List.rev_append comments acc), And) ··· 299 304 300 305 let read_extension_constructor env parent ext = 301 306 let open Extension.Constructor in 302 - let id = Env.find_extension_identifier env ext.ext_id in 307 + let id = Env.find_extension_identifier env.ident_env ext.ext_id in 303 308 let source_loc = None in 304 309 let container = (parent : Identifier.Signature.t :> Identifier.FieldParent.t) in 305 310 let label_container = (container :> Identifier.LabelParent.t) in 306 - let doc = Doc_attr.attached_no_tag label_container ext.ext_attributes in 311 + let doc = Doc_attr.attached_no_tag ~suppress_warnings:env.suppress_warnings label_container ext.ext_attributes in 307 312 match ext.ext_kind with 308 313 | Text_rebind _ -> assert false 309 314 #if OCAML_VERSION >= (4, 14, 0) ··· 320 325 321 326 let read_type_extension env parent tyext = 322 327 let open Extension in 323 - let type_path = Env.Path.read_type env tyext.tyext_path in 328 + let type_path = Env.Path.read_type env.ident_env tyext.tyext_path in 324 329 let container = (parent : Identifier.Signature.t :> Identifier.LabelParent.t) in 325 - let doc = Doc_attr.attached_no_tag container tyext.tyext_attributes in 330 + let doc = Doc_attr.attached_no_tag ~suppress_warnings:env.suppress_warnings container tyext.tyext_attributes in 326 331 let type_params = List.map read_type_parameter tyext.tyext_params in 327 332 let private_ = (tyext.tyext_private = Private) in 328 333 let constructors = ··· 332 337 333 338 let read_exception env parent (ext : extension_constructor) = 334 339 let open Exception in 335 - let id = Env.find_exception_identifier env ext.ext_id in 340 + let id = Env.find_exception_identifier env.ident_env ext.ext_id in 336 341 let source_loc = None in 337 342 let container = (parent : Identifier.Signature.t :> Identifier.FieldParent.t) in 338 343 let label_container = (container :> Identifier.LabelParent.t) in 339 - let doc = Doc_attr.attached_no_tag label_container ext.ext_attributes in 344 + let doc = Doc_attr.attached_no_tag ~suppress_warnings:env.suppress_warnings label_container ext.ext_attributes in 340 345 match ext.ext_kind with 341 346 | Text_rebind _ -> assert false 342 347 #if OCAML_VERSION >= (4, 14, 0) ··· 355 360 let open ClassSignature in 356 361 let open Odoc_model.Names in 357 362 let container = (parent : Identifier.ClassSignature.t :> Identifier.LabelParent.t) in 358 - let doc = Doc_attr.attached_no_tag container ctf.ctf_attributes in 363 + let doc = Doc_attr.attached_no_tag ~suppress_warnings:env.suppress_warnings container ctf.ctf_attributes in 359 364 match ctf.ctf_desc with 360 365 | Tctf_val(name, mutable_, virtual_, typ) -> 361 366 let open InstanceVariable in ··· 379 384 let expr = read_class_signature env parent container cltyp in 380 385 Some (Inherit {expr; doc}) 381 386 | Tctf_attribute attr -> 382 - match Doc_attr.standalone container attr with 387 + match Doc_attr.standalone container ~suppress_warnings:env.suppress_warnings attr with 383 388 | None -> None 384 389 | Some doc -> Some (Comment doc) 385 390 ··· 391 396 let open ClassType in 392 397 match cltyp.cltyp_desc with 393 398 | Tcty_constr(p, _, params) -> 394 - let p = Env.Path.read_class_type env p in 399 + let p = Env.Path.read_class_type env.ident_env p in 395 400 let params = List.map (read_core_type env label_parent) params in 396 401 Constr(p, params) 397 402 | Tcty_signature csig -> ··· 409 414 let items, (doc, doc_post) = Doc_attr.extract_top_comment_class items in 410 415 let items = 411 416 match doc_post with 412 - | [] -> items 417 + | {elements=[]; _} -> items 413 418 | _ -> Comment (`Docs doc_post) :: items 414 419 in 415 420 Signature {self; items; doc} ··· 422 427 423 428 let read_class_type_declaration env parent cltd = 424 429 let open ClassType in 425 - let id = Env.find_class_type_identifier env cltd.ci_id_class_type in 430 + let id = Env.find_class_type_identifier env.ident_env cltd.ci_id_class_type in 426 431 let source_loc = None in 427 432 let container = (parent : Identifier.Signature.t :> Identifier.LabelParent.t) in 428 - let doc = Doc_attr.attached_no_tag container cltd.ci_attributes in 433 + let doc = Doc_attr.attached_no_tag container ~suppress_warnings:env.suppress_warnings cltd.ci_attributes in 429 434 let virtual_ = (cltd.ci_virt = Virtual) in 430 435 let params = List.map read_type_parameter cltd.ci_params in 431 436 let expr = read_class_signature env (id :> Identifier.ClassSignature.t) container cltd.ci_expr in ··· 435 440 let container = (parent : Identifier.Signature.t :> Identifier.LabelParent.t) in 436 441 let open Signature in 437 442 List.fold_left begin fun (acc,recursive) cltd -> 438 - let comments = Doc_attr.standalone_multiple container cltd.ci_attributes in 443 + let comments = Doc_attr.standalone_multiple container ~suppress_warnings:env.suppress_warnings cltd.ci_attributes in 439 444 let comments = List.map (fun com -> Comment com) comments in 440 445 let cltd = read_class_type_declaration env parent cltd in 441 446 ((ClassType (recursive, cltd))::(List.rev_append comments acc), And) ··· 461 466 462 467 let read_class_description env parent cld = 463 468 let open Class in 464 - let id = Env.find_class_identifier env cld.ci_id_class in 469 + let id = Env.find_class_identifier env.ident_env cld.ci_id_class in 465 470 let source_loc = None in 466 471 let container = (parent : Identifier.Signature.t :> Identifier.LabelParent.t) in 467 - let doc = Doc_attr.attached_no_tag container cld.ci_attributes in 472 + let doc = Doc_attr.attached_no_tag container ~suppress_warnings:env.suppress_warnings cld.ci_attributes in 468 473 let virtual_ = (cld.ci_virt = Virtual) in 469 474 let params = List.map read_type_parameter cld.ci_params in 470 475 let type_ = read_class_type env (id :> Identifier.ClassSignature.t) container cld.ci_expr in ··· 474 479 let container = (parent : Identifier.Signature.t :> Identifier.LabelParent.t) in 475 480 let open Signature in 476 481 List.fold_left begin fun (acc, recursive) cld -> 477 - let comments = Doc_attr.standalone_multiple container cld.ci_attributes in 482 + let comments = Doc_attr.standalone_multiple container ~suppress_warnings:env.suppress_warnings cld.ci_attributes in 478 483 let comments = List.map (fun com -> Comment com) comments in 479 484 let cld = read_class_description env parent cld in 480 485 ((Class (recursive, cld))::(List.rev_append comments acc), And) ··· 500 505 TypeSubst(frag, eq) 501 506 | Twith_modsubst(p, _) -> 502 507 let frag = Env.Fragment.read_module frag.Location.txt in 503 - let p = Env.Path.read_module env p in 508 + let p = Env.Path.read_module env.ident_env p in 504 509 ModuleSubst(frag, p) 505 510 #if OCAML_VERSION >= (4,13,0) 506 511 | Twith_modtype mty -> ··· 516 521 and read_module_type env parent label_parent mty = 517 522 let open ModuleType in 518 523 match mty.mty_desc with 519 - | Tmty_ident(p, _) -> Path { p_path = Env.Path.read_module_type env p; p_expansion = None } 524 + | Tmty_ident(p, _) -> Path { p_path = Env.Path.read_module_type env.ident_env p; p_expansion = None } 520 525 | Tmty_signature sg -> 521 526 let sg, () = read_signature Odoc_model.Semantics.Expect_none env parent sg in 522 527 Signature sg ··· 530 535 match id_opt with 531 536 | None -> Identifier.Mk.parameter (parent, ModuleName.make_std "_"), env 532 537 | Some id -> 533 - let env = Env.add_parameter parent id (ModuleName.of_ident id) env in 534 - Env.find_parameter_identifier env id, env 538 + let e' = Env.add_parameter parent id (ModuleName.of_ident id) env.ident_env in 539 + let env = {env with ident_env = e'} in 540 + Env.find_parameter_identifier e' id, env 535 541 in 536 542 let arg = read_module_type env (id :> Identifier.Signature.t) label_parent arg in 537 543 Named { id; expr = arg; }, env ··· 564 570 let decl = 565 571 match mexpr.mod_desc with 566 572 | Tmod_ident(p, _) -> 567 - let p = Env.Path.read_module env p in 573 + let p = Env.Path.read_module env.ident_env p in 568 574 TypeOf {t_desc = ModPath p; t_original_path = p; t_expansion = None} 569 575 | Tmod_structure {str_items = [{str_desc = Tstr_include {incl_mod; _}; _}]; _} -> begin 570 576 match Typemod.path_of_module incl_mod with 571 577 | Some p -> 572 - let p = Env.Path.read_module env p in 578 + let p = Env.Path.read_module env.ident_env p in 573 579 TypeOf {t_desc=StructInclude p; t_original_path = p; t_expansion = None} 574 580 | None -> 575 581 !read_module_expr env parent label_parent mexpr ··· 593 599 594 600 and read_module_type_declaration env parent mtd = 595 601 let open ModuleType in 596 - let id = Env.find_module_type env mtd.mtd_id in 602 + let id = Env.find_module_type env.ident_env mtd.mtd_id in 597 603 let source_loc = None in 598 604 let container = (parent : Identifier.Signature.t :> Identifier.LabelParent.t) in 599 - let doc, canonical = Doc_attr.attached Odoc_model.Semantics.Expect_canonical container mtd.mtd_attributes in 605 + let doc, canonical = Doc_attr.attached ~suppress_warnings:env.suppress_warnings Odoc_model.Semantics.Expect_canonical container mtd.mtd_attributes in 600 606 let expr, canonical = 601 607 match mtd.mtd_type with 602 608 | Some mty -> ··· 617 623 match md.md_id with 618 624 | None -> None 619 625 | Some id -> 620 - let mid = Env.find_module_identifier env id in 626 + let mid = Env.find_module_identifier env.ident_env id in 621 627 #else 622 - let mid = Env.find_module_identifier env md.md_id in 628 + let mid = Env.find_module_identifier env.ident_env md.md_id in 623 629 #endif 624 630 let id = (mid :> Identifier.Module.t) in 625 631 let source_loc = None in 626 632 let container = (parent : Identifier.Signature.t :> Identifier.LabelParent.t) in 627 - let doc, canonical = Doc_attr.attached Odoc_model.Semantics.Expect_canonical container md.md_attributes in 633 + let doc, canonical = Doc_attr.attached ~suppress_warnings:env.suppress_warnings Odoc_model.Semantics.Expect_canonical container md.md_attributes in 628 634 let type_, canonical = 629 635 match md.md_type.mty_desc with 630 - | Tmty_alias (p, _) -> (Alias (Env.Path.read_module env p, None), canonical) 636 + | Tmty_alias (p, _) -> (Alias (Env.Path.read_module env.ident_env p, None), canonical) 631 637 | _ -> 632 638 let expr, canonical = 633 639 read_module_type_maybe_canonical env ··· 655 661 let open Signature in 656 662 List.fold_left 657 663 (fun (acc, recursive) md -> 658 - let comments = Doc_attr.standalone_multiple container md.md_attributes in 664 + let comments = Doc_attr.standalone_multiple container ~suppress_warnings:env.suppress_warnings md.md_attributes in 659 665 let comments = List.map (fun com -> Comment com) comments in 660 666 match read_module_declaration env parent md with 661 667 | Some md -> ((Module (recursive, md))::(List.rev_append comments acc), And) ··· 666 672 667 673 and read_module_equation env p = 668 674 let open Module in 669 - Alias (Env.Path.read_module env p, None) 675 + Alias (Env.Path.read_module env.ident_env p, None) 670 676 671 677 and read_signature_item env parent item = 672 678 let open Signature in ··· 714 720 read_class_type_declarations env parent cltyps 715 721 | Tsig_attribute attr -> begin 716 722 let container = (parent : Identifier.Signature.t :> Identifier.LabelParent.t) in 717 - match Doc_attr.standalone container attr with 723 + match Doc_attr.standalone container ~suppress_warnings:env.suppress_warnings attr with 718 724 | None -> [] 719 725 | Some doc -> [Comment doc] 720 726 end ··· 731 737 732 738 and read_module_substitution env parent ms = 733 739 let open ModuleSubstitution in 734 - let id = Env.find_module_identifier env ms.ms_id in 740 + let id = Env.find_module_identifier env.ident_env ms.ms_id in 735 741 let container = (parent : Identifier.Signature.t :> Identifier.LabelParent.t) in 736 - let doc, () = Doc_attr.attached Odoc_model.Semantics.Expect_none container ms.ms_attributes in 737 - let manifest = Env.Path.read_module env ms.ms_manifest in 742 + let doc, () = Doc_attr.attached ~suppress_warnings:env.suppress_warnings Odoc_model.Semantics.Expect_none container ms.ms_attributes in 743 + let manifest = Env.Path.read_module env.ident_env ms.ms_manifest in 738 744 { id; doc; manifest } 739 745 740 746 #if OCAML_VERSION >= (4,13,0) 741 747 and read_module_type_substitution env parent mtd = 742 748 let open ModuleTypeSubstitution in 743 - let id = Env.find_module_type env mtd.mtd_id in 749 + let id = Env.find_module_type env.ident_env mtd.mtd_id in 744 750 let container = (parent : Identifier.Signature.t :> Identifier.LabelParent.t) in 745 - let doc, () = Doc_attr.attached Odoc_model.Semantics.Expect_none container mtd.mtd_attributes in 751 + let doc, () = Doc_attr.attached ~suppress_warnings:env.suppress_warnings Odoc_model.Semantics.Expect_none container mtd.mtd_attributes in 746 752 let expr = match opt_map (read_module_type env (id :> Identifier.Signature.t) container) mtd.mtd_type with 747 753 | None -> assert false 748 754 | Some x -> x ··· 757 763 let open Include in 758 764 let loc = Doc_attr.read_location incl.incl_loc in 759 765 let container = (parent : Identifier.Signature.t :> Identifier.LabelParent.t) in 760 - let doc, status = Doc_attr.attached Odoc_model.Semantics.Expect_status container incl.incl_attributes in 766 + let doc, status = Doc_attr.attached ~suppress_warnings:env.suppress_warnings Odoc_model.Semantics.Expect_status container incl.incl_attributes in 761 767 let content, shadowed = Cmi.read_signature_noenv env parent (Odoc_model.Compat.signature incl.incl_type) in 762 768 let expr = read_module_type env parent container incl.incl_mod in 763 769 let umty = Odoc_model.Lang.umty_of_mty expr in ··· 771 777 772 778 and read_open env parent o = 773 779 let container = (parent : Identifier.Signature.t :> Identifier.LabelParent.t) in 774 - let doc = Doc_attr.attached_no_tag container o.open_attributes in 780 + let doc = Doc_attr.attached_no_tag container ~suppress_warnings:env.suppress_warnings o.open_attributes in 775 781 #if OCAML_VERSION >= (4,8,0) 776 782 let signature = o.open_bound_items in 777 783 #else ··· 784 790 'tags. 'tags Odoc_model.Semantics.handle_internal_tags -> _ -> _ -> _ -> 785 791 _ * 'tags = 786 792 fun internal_tags env parent sg -> 787 - let env = Env.add_signature_tree_items parent sg env in 793 + let e' = Env.add_signature_tree_items parent sg env.ident_env in 794 + let env = { env with ident_env = e' } in 788 795 let items, (doc, doc_post), tags = 789 796 let classify item = 790 797 match item.sig_desc with ··· 802 809 |> List.rev 803 810 in 804 811 match doc_post with 805 - | [] -> 812 + | {elements=[]; _} -> 806 813 ({ Signature.items; compiled = false; removed = []; doc }, tags) 807 814 | _ -> 808 815 ({ Signature.items = Comment (`Docs doc_post) :: items; compiled=false; removed = []; doc }, tags) 809 816 810 - let read_interface root name intf = 811 - let id = Identifier.Mk.root (root, Odoc_model.Names.ModuleName.make_std name) in 817 + let read_interface root name suppress_warnings intf = 818 + let id = 819 + Identifier.Mk.root (root, Odoc_model.Names.ModuleName.make_std name) 820 + in 812 821 let sg, canonical = 813 - read_signature Odoc_model.Semantics.Expect_canonical (Env.empty ()) id intf 822 + read_signature Odoc_model.Semantics.Expect_canonical 823 + { ident_env = Env.empty (); suppress_warnings } 824 + id intf 814 825 in 815 - let canonical = match canonical with | None -> None | Some s -> Some (Doc_attr.conv_canonical_module s) in 826 + let canonical = 827 + match canonical with 828 + | None -> None 829 + | Some s -> Some (Doc_attr.conv_canonical_module s) 830 + in 816 831 (id, sg, canonical)
+7 -6
src/loader/cmti.mli
··· 17 17 module Paths = Odoc_model.Paths 18 18 19 19 val read_module_expr : 20 - (Ident_env.t -> 20 + (Cmi.env -> 21 21 Paths.Identifier.Signature.t -> 22 22 Paths.Identifier.LabelParent.t -> 23 23 Typedtree.module_expr -> ··· 27 27 val read_interface : 28 28 Odoc_model.Paths.Identifier.ContainerPage.t option -> 29 29 string -> 30 + bool -> 30 31 Typedtree.signature -> 31 32 Paths.Identifier.RootModule.t 32 33 * Odoc_model.Lang.Signature.t ··· 35 36 [@canonical] tag. *) 36 37 37 38 val read_module_type : 38 - Ident_env.t -> 39 + Cmi.env -> 39 40 Paths.Identifier.Signature.t -> 40 41 Paths.Identifier.LabelParent.t -> 41 42 Typedtree.module_type -> 42 43 Odoc_model.Lang.ModuleType.expr 43 44 44 45 val read_value_description : 45 - Ident_env.t -> 46 + Cmi.env -> 46 47 Paths.Identifier.Signature.t -> 47 48 Typedtree.value_description -> 48 49 Odoc_model.Lang.Signature.item 49 50 50 51 val read_type_declarations : 51 - Ident_env.t -> 52 + Cmi.env -> 52 53 Paths.Identifier.Signature.t -> 53 54 Odoc_model.Lang.Signature.recursive -> 54 55 Typedtree.type_declaration list -> 55 56 Odoc_model.Lang.Signature.item list 56 57 57 58 val read_module_type_declaration : 58 - Ident_env.t -> 59 + Cmi.env -> 59 60 Paths.Identifier.Signature.t -> 60 61 Typedtree.module_type_declaration -> 61 62 Odoc_model.Lang.ModuleType.t 62 63 63 64 val read_class_type_declarations : 64 - Ident_env.t -> 65 + Cmi.env -> 65 66 Paths.Identifier.Signature.t -> 66 67 Typedtree.class_type Typedtree.class_infos list -> 67 68 Odoc_model.Lang.Signature.item list
+25 -16
src/loader/doc_attr.ml
··· 29 29 end_ = point_of_pos loc_end; 30 30 } 31 31 32 - let empty_body = [] 32 + let empty_body = { Comment.elements = []; suppress_warnings = false } 33 33 34 34 let empty : Odoc_model.Comment.docs = empty_body 35 35 ··· 124 124 let span = read_location loc in 125 125 Location_.at span elt 126 126 127 - let attached internal_tags parent attrs = 127 + let attached ~suppress_warnings internal_tags parent attrs = 128 128 let rec loop acc_docs acc_alerts = function 129 129 | attr :: rest -> ( 130 130 match parse_attribute attr with ··· 141 141 | [] -> (List.rev acc_docs, List.rev acc_alerts) 142 142 in 143 143 let ast_docs, alerts = loop [] [] attrs in 144 - ast_to_comment ~internal_tags parent ast_docs alerts 144 + let elements, warnings = ast_to_comment ~internal_tags parent ast_docs alerts in 145 + { Comment.elements; suppress_warnings }, warnings 145 146 146 - let attached_no_tag parent attrs = 147 - let x, () = attached Semantics.Expect_none parent attrs in 147 + let attached_no_tag ~suppress_warnings parent attrs = 148 + let x, () = attached ~suppress_warnings Semantics.Expect_none parent attrs in 148 149 x 149 150 150 151 let read_string ~tags_allowed internal_tags parent location str = ··· 160 161 read_string ~tags_allowed:true internal_tags parent (pad_loc loc) str 161 162 162 163 let page parent loc str = 163 - read_string ~tags_allowed:false Odoc_model.Semantics.Expect_page_tags parent loc.Location.loc_start 164 + let elements, tags = read_string ~tags_allowed:false Odoc_model.Semantics.Expect_page_tags parent loc.Location.loc_start 164 165 str 166 + in 167 + { Comment.elements; suppress_warnings = false}, tags 165 168 166 - let standalone parent (attr : Parsetree.attribute) : 169 + let standalone parent ~suppress_warnings (attr : Parsetree.attribute) : 167 170 Odoc_model.Comment.docs_or_stop option = 168 171 match parse_attribute attr with 169 172 | Some (`Stop _loc) -> Some `Stop 170 173 | Some (`Text (str, loc)) -> 171 - let doc, () = read_string_comment Semantics.Expect_none parent loc str in 172 - Some (`Docs doc) 174 + let elements, () = read_string_comment Semantics.Expect_none parent loc str in 175 + Some (`Docs { elements; suppress_warnings }) 173 176 | Some (`Doc _) -> None 174 177 | Some (`Alert (name, _, attr_loc)) -> 175 178 let w = 176 - Error.make "Alert %s not expected here." name 177 - (read_location attr_loc) 179 + Error.make "Alert %s not expected here." name (read_location attr_loc) 178 180 in 179 181 Error.raise_warning w; 180 182 None 181 183 | _ -> None 182 184 183 - let standalone_multiple parent attrs = 185 + let standalone_multiple parent ~suppress_warnings attrs = 184 186 let coms = 185 187 List.fold_left 186 188 (fun acc attr -> 187 - match standalone parent attr with 189 + match standalone parent ~suppress_warnings attr with 188 190 | None -> acc 189 191 | Some com -> com :: acc) 190 192 [] attrs ··· 251 253 (parent : Paths.Identifier.Signature.t :> Paths.Identifier.LabelParent.t) 252 254 ast_docs alerts 253 255 in 254 - (items, split_docs docs, tags) 256 + let d1, d2 = split_docs docs in 257 + ( items, 258 + ( { Comment.elements = d1; suppress_warnings = false }, 259 + { Comment.elements = d2; suppress_warnings = false } ), 260 + tags ) 255 261 256 262 let extract_top_comment_class items = 263 + let mk elements suppress_warnings = { Comment.elements; suppress_warnings } in 257 264 match items with 258 - | Lang.ClassSignature.Comment (`Docs doc) :: tl -> (tl, split_docs doc) 259 - | _ -> items, (empty,empty) 265 + | Lang.ClassSignature.Comment (`Docs doc) :: tl -> 266 + let d1, d2 = split_docs doc.elements in 267 + (tl, (mk d1 doc.suppress_warnings, mk d2 doc.suppress_warnings)) 268 + | _ -> (items, (mk [] false, mk [] false)) 260 269 261 270 let rec conv_canonical_module : Odoc_model.Reference.path -> Paths.Path.Module.t = function 262 271 | `Dot (parent, name) -> `Dot (conv_canonical_module parent, Names.ModuleName.make_std name)
+4
src/loader/doc_attr.mli
··· 22 22 val is_stop_comment : Parsetree.attribute -> bool 23 23 24 24 val attached : 25 + suppress_warnings:bool -> 25 26 'tags Semantics.handle_internal_tags -> 26 27 Paths.Identifier.LabelParent.t -> 27 28 Parsetree.attributes -> 28 29 Odoc_model.Comment.docs * 'tags 29 30 30 31 val attached_no_tag : 32 + suppress_warnings:bool -> 31 33 Paths.Identifier.LabelParent.t -> 32 34 Parsetree.attributes -> 33 35 Odoc_model.Comment.docs ··· 47 49 48 50 val standalone : 49 51 Paths.Identifier.LabelParent.t -> 52 + suppress_warnings:bool -> 50 53 Parsetree.attribute -> 51 54 Odoc_model.Comment.docs_or_stop option 52 55 53 56 val standalone_multiple : 54 57 Paths.Identifier.LabelParent.t -> 58 + suppress_warnings:bool -> 55 59 Parsetree.attributes -> 56 60 Odoc_model.Comment.docs_or_stop list 57 61
+19 -12
src/loader/odoc_loader.ml
··· 101 101 make_compilation_unit ~make_root ~imports ~interface ?sourcefile ~name ~id 102 102 ?canonical content 103 103 104 - let read_cmti ~make_root ~parent ~filename () = 104 + let read_cmti ~make_root ~parent ~filename ~suppress_warnings () = 105 105 let cmt_info = Cmt_format.read_cmt filename in 106 106 match cmt_info.cmt_annots with 107 107 | Interface intf -> ( ··· 118 118 cmt_info.cmt_source_digest, 119 119 cmt_info.cmt_builddir ) 120 120 in 121 - let id, sg, canonical = Cmti.read_interface parent name intf in 121 + let id, sg, canonical = 122 + Cmti.read_interface parent name suppress_warnings intf 123 + in 122 124 compilation_unit_of_sig ~make_root ~imports:cmt_info.cmt_imports 123 125 ~interface ~sourcefile ~name ~id ?canonical sg) 124 126 | _ -> raise Not_an_interface 125 127 126 - let read_cmt ~make_root ~parent ~filename () = 128 + let read_cmt ~make_root ~parent ~filename ~suppress_warnings () = 127 129 match Cmt_format.read_cmt filename with 128 130 | exception Cmi_format.Error (Not_an_interface _) -> 129 131 raise Not_an_implementation ··· 175 177 make_compilation_unit ~make_root ~imports ~interface ~sourcefile ~name 176 178 ~id content 177 179 | Implementation impl -> 178 - let id, sg, canonical = Cmt.read_implementation parent name impl in 180 + let id, sg, canonical = 181 + Cmt.read_implementation parent name suppress_warnings impl 182 + in 179 183 compilation_unit_of_sig ~make_root ~imports ~interface ~sourcefile 180 184 ~name ~id ?canonical sg 181 185 | _ -> raise Not_an_implementation) 182 186 183 - let read_cmi ~make_root ~parent ~filename () = 187 + let read_cmi ~make_root ~parent ~filename ~suppress_warnings () = 184 188 let cmi_info = Cmi_format.read_cmi filename in 185 189 match cmi_info.cmi_crcs with 186 190 | (name, (Some _ as interface)) :: imports when name = cmi_info.cmi_name -> 187 191 let id, sg = 188 - Cmi.read_interface parent name 192 + Cmi.read_interface parent name suppress_warnings 189 193 (Odoc_model.Compat.signature cmi_info.cmi_sign) 190 194 in 191 195 compilation_unit_of_sig ~make_root ~imports ~interface ~name ~id sg ··· 251 255 | Not_an_interface -> not_an_interface filename 252 256 | Make_root_error m -> error_msg filename m) 253 257 254 - let read_cmti ~make_root ~parent ~filename = 255 - wrap_errors ~filename (read_cmti ~make_root ~parent ~filename) 258 + let read_cmti ~make_root ~parent ~filename ~suppress_warnings = 259 + wrap_errors ~filename 260 + (read_cmti ~make_root ~parent ~filename ~suppress_warnings) 256 261 257 - let read_cmt ~make_root ~parent ~filename = 258 - wrap_errors ~filename (read_cmt ~make_root ~parent ~filename) 262 + let read_cmt ~make_root ~parent ~filename ~suppress_warnings = 263 + wrap_errors ~filename 264 + (read_cmt ~make_root ~parent ~filename ~suppress_warnings) 259 265 260 266 let read_impl ~make_root ~filename ~source_id = 261 267 wrap_errors ~filename (read_impl ~make_root ~source_id ~filename) 262 268 263 - let read_cmi ~make_root ~parent ~filename = 264 - wrap_errors ~filename (read_cmi ~make_root ~parent ~filename) 269 + let read_cmi ~make_root ~parent ~filename ~suppress_warnings = 270 + wrap_errors ~filename 271 + (read_cmi ~make_root ~parent ~filename ~suppress_warnings) 265 272 266 273 let read_location = Doc_attr.read_location
+3
src/loader/odoc_loader.mli
··· 17 17 make_root:make_root -> 18 18 parent:Identifier.ContainerPage.t option -> 19 19 filename:string -> 20 + suppress_warnings:bool -> 20 21 (Lang.Compilation_unit.t, Error.t) result Error.with_warnings 21 22 22 23 val read_cmt : 23 24 make_root:make_root -> 24 25 parent:Identifier.ContainerPage.t option -> 25 26 filename:string -> 27 + suppress_warnings:bool -> 26 28 (Lang.Compilation_unit.t, Error.t) result Error.with_warnings 27 29 28 30 val read_impl : ··· 35 37 make_root:make_root -> 36 38 parent:Identifier.ContainerPage.t option -> 37 39 filename:string -> 40 + suppress_warnings:bool -> 38 41 (Lang.Compilation_unit.t, Error.t) result Error.with_warnings 39 42 40 43 val read_location : Location.t -> Location_.span
+3 -3
src/markdown/odoc_md.ml
··· 20 20 in 21 21 (content, List.map Error.t_of_parser_t parser_warnings @ semantics_warnings) 22 22 23 - let mk_page input_s id content = 23 + let mk_page input_s id elements = 24 24 (* Construct the output file representation *) 25 - let zero_heading = Comment.find_zero_heading content in 25 + let zero_heading = Comment.find_zero_heading elements in 26 26 let frontmatter = Frontmatter.empty in 27 27 let digest = Digest.file input_s in 28 28 let root = ··· 34 34 Lang.Page.name = id; 35 35 root; 36 36 children; 37 - content; 37 + content = { elements; suppress_warnings = false }; 38 38 digest; 39 39 linked = false; 40 40 frontmatter;
+3 -1
src/model/comment.ml
··· 113 113 heading_attrs * Identifier.Label.t * inline_element with_location list 114 114 | `Tag of tag ] 115 115 116 - type docs = block_element with_location list 116 + type elements = block_element with_location list 117 + 118 + type docs = { elements : elements; suppress_warnings : bool } 117 119 118 120 type docs_or_stop = [ `Docs of docs | `Stop ] 119 121
+5 -1
src/model/error.ml
··· 101 101 102 102 let print_errors = List.iter print_error 103 103 104 - type warnings_options = { warn_error : bool; print_warnings : bool } 104 + type warnings_options = { 105 + warn_error : bool; 106 + print_warnings : bool; 107 + suppress_warnings : bool; 108 + } 105 109 106 110 let print_warnings ~warnings_options warnings = 107 111 if warnings_options.print_warnings then
+1
src/model/error.mli
··· 41 41 type warnings_options = { 42 42 warn_error : bool; (** If [true], warnings will result in an error. *) 43 43 print_warnings : bool; (** Whether to print warnings. *) 44 + suppress_warnings : bool; (** Whether to suppress warnings. *) 44 45 } 45 46 46 47 val handle_warnings :
+2 -1
src/model/lang.ml
··· 571 571 | { decl = ModuleType expr; _ } -> uexpr_considered_hidden expr 572 572 in 573 573 match (s.doc, s.items) with 574 - | [], Include inc :: _ when should_take_top inc -> inc.expansion.content.doc 574 + | { elements = []; _ }, Include inc :: _ when should_take_top inc -> 575 + inc.expansion.content.doc 575 576 | doc, _ -> doc
+1 -1
src/model/semantics.ml
··· 531 531 comment) 532 532 alerts 533 533 in 534 - comment @ (alerts : alerts :> Comment.docs) 534 + comment @ (alerts :> Comment.elements) 535 535 536 536 let handle_internal_tags (type a) tags : a handle_internal_tags -> a = function 537 537 | Expect_status -> (
+2 -2
src/model/semantics.mli
··· 17 17 parent_of_sections:Paths.Identifier.LabelParent.t -> 18 18 Odoc_parser.Ast.t -> 19 19 alerts -> 20 - (Comment.docs * 'tags) Error.with_warnings 20 + (Comment.elements * 'tags) Error.with_warnings 21 21 22 22 val non_link_inline_element : 23 23 context:string -> ··· 30 30 containing_definition:Paths.Identifier.LabelParent.t -> 31 31 location:Lexing.position -> 32 32 text:string -> 33 - (Comment.docs * 'tags) Error.with_warnings 33 + (Comment.elements * 'tags) Error.with_warnings 34 34 35 35 val parse_reference : string -> Paths.Reference.t Error.with_errors_and_warnings
+23 -15
src/model_desc/comment_desc.ml
··· 33 33 Comment.heading_attrs * Identifier.Label.t * general_link_content 34 34 | `Tag of general_tag 35 35 | `Media of 36 - [ `Reference of Paths.Reference.t | `Link of string ] * media * string 37 - | `MediaLink of string * media * general_link_content ] 36 + [ `Reference of Paths.Reference.t | `Link of string ] * media * string ] 38 37 39 38 and general_tag = 40 39 [ `Author of string ··· 133 132 | `Verbatim x -> C ("`Verbatim", x, string) 134 133 | `Modules x -> C ("`Modules", x, List module_reference) 135 134 | `List (x1, x2) -> 136 - C ("`List", (x1, (x2 :> general_docs list)), Pair (list_kind, List docs)) 135 + C 136 + ( "`List", 137 + (x1, (x2 :> general_docs list)), 138 + Pair (list_kind, List general_content) ) 137 139 | `Table { data; align } -> 138 140 let cell_type_desc = 139 141 Variant (function `Header -> C0 "`Header" | `Data -> C0 "`Data") 140 142 in 141 - let data_desc = List (List (Pair (docs, cell_type_desc))) in 143 + let data_desc = List (List (Pair (general_content, cell_type_desc))) in 142 144 let align_desc = 143 145 Option 144 146 (Variant ··· 153 155 | `Heading h -> C ("`Heading", h, heading) 154 156 | `Tag x -> C ("`Tag", x, tag) 155 157 | `Media (x1, m, x2) -> 156 - C ("`MediaReference", (x1, m, x2), Triple (media_href, media, string)) 157 - | `MediaLink (x1, m, x2) -> 158 - C ("`MediaLink", (x1, m, x2), Triple (string, media, link_content))) 158 + C ("`Media", (x1, m, x2), Triple (media_href, media, string))) 159 159 160 160 and tag : general_tag t = 161 161 let url_kind = ··· 166 166 Variant 167 167 (function 168 168 | `Author x -> C ("`Author", x, string) 169 - | `Deprecated x -> C ("`Deprecated", x, docs) 170 - | `Param (x1, x2) -> C ("`Param", (x1, x2), Pair (string, docs)) 169 + | `Deprecated x -> C ("`Deprecated", x, general_content) 170 + | `Param (x1, x2) -> C ("`Param", (x1, x2), Pair (string, general_content)) 171 171 | `Raise (x1, x2) -> 172 172 C 173 173 ( "`Raise", 174 174 ((x1 :> general_inline_element), x2), 175 - Pair (inline_element, docs) ) 176 - | `Return x -> C ("`Return", x, docs) 175 + Pair (inline_element, general_content) ) 176 + | `Return x -> C ("`Return", x, general_content) 177 177 | `See (x1, x2, x3) -> 178 - C ("`See", (x1, x2, x3), Triple (url_kind, string, docs)) 178 + C ("`See", (x1, x2, x3), Triple (url_kind, string, general_content)) 179 179 | `Since x -> C ("`Since", x, string) 180 - | `Before (x1, x2) -> C ("`Before", (x1, x2), Pair (string, docs)) 180 + | `Before (x1, x2) -> C ("`Before", (x1, x2), Pair (string, general_content)) 181 181 | `Version x -> C ("`Version", x, string) 182 182 | `Alert (x1, x2) -> C ("`Alert", (x1, x2), Pair (string, Option string))) 183 183 184 - and docs : general_docs t = List (Indirect (ignore_loc, block_element)) 184 + and general_content : general_docs t = 185 + List (Indirect (ignore_loc, block_element)) 185 186 186 - let docs = Indirect ((fun n -> ((n :> docs) :> general_docs)), docs) 187 + let elements : elements t = 188 + Indirect ((fun x -> (x :> general_docs)), general_content) 189 + let docs = 190 + Record 191 + [ 192 + F ("elements", (fun h -> h.elements), elements); 193 + F ("suppress_warnings", (fun h -> h.suppress_warnings), bool); 194 + ] 187 195 188 196 let docs_or_stop : docs_or_stop t = 189 197 Variant (function `Docs x -> C ("`Docs", x, docs) | `Stop -> C0 "`Stop")
+4 -2
src/model_desc/comment_desc.mli
··· 1 1 open Odoc_model 2 2 open Odoc_model.Comment 3 3 4 - val docs : docs Type_desc.t 4 + val inline_element : inline_element Location_.with_location list Type_desc.t 5 5 6 - val inline_element : inline_element Location_.with_location list Type_desc.t 6 + val elements : elements Type_desc.t 7 + 8 + val docs : docs Type_desc.t 7 9 8 10 val docs_or_stop : docs_or_stop Type_desc.t
+30 -5
src/odoc/bin/main.ml
··· 141 141 let env = Arg.env_var "ODOC_ENABLE_MISSING_ROOT_WARNING" ~doc in 142 142 Arg.(value & flag & info ~docs ~doc ~env [ "enable-missing-root-warning" ]) 143 143 in 144 + let suppress_warnings = 145 + let doc = 146 + "Suppress warnings. This is useful when you want to declare that \ 147 + warnings that would be generated resolving the references defined in \ 148 + this unit should be ignored if they end up in expansions in other \ 149 + units." 150 + in 151 + let env = Arg.env_var "ODOC_SUPPRESS_WARNINGS" ~doc in 152 + Arg.(value & flag & info ~docs ~doc ~env [ "suppress-warnings" ]) 153 + in 144 154 Term.( 145 - const (fun warn_error print_warnings enable_missing_root_warning -> 155 + const 156 + (fun 157 + warn_error 158 + print_warnings 159 + enable_missing_root_warning 160 + suppress_warnings 161 + -> 146 162 Odoc_model.Error.enable_missing_root_warning := 147 163 enable_missing_root_warning; 148 - { Odoc_model.Error.warn_error; print_warnings }) 149 - $ warn_error $ print_warnings $ enable_missing_root_warning) 164 + { Odoc_model.Error.warn_error; print_warnings; suppress_warnings }) 165 + $ warn_error $ print_warnings $ enable_missing_root_warning 166 + $ suppress_warnings) 150 167 151 168 let dst ?create () = 152 169 let doc = "Output directory where the HTML tree is expected to be saved." in ··· 965 982 ~roots:None 966 983 in 967 984 let warnings_options = 968 - { Odoc_model.Error.warn_error = false; print_warnings = false } 985 + { 986 + Odoc_model.Error.warn_error = false; 987 + print_warnings = false; 988 + suppress_warnings = false; 989 + } 969 990 in 970 991 Rendering.targets_odoc ~resolver ~warnings_options ~syntax:OCaml 971 992 ~renderer:R.renderer ~output:output_dir ~extra odoc_file ··· 1000 1021 module Targets_source = struct 1001 1022 let list_targets output_dir source_file extra odoc_file = 1002 1023 let warnings_options = 1003 - { Odoc_model.Error.warn_error = false; print_warnings = false } 1024 + { 1025 + Odoc_model.Error.warn_error = false; 1026 + print_warnings = false; 1027 + suppress_warnings = false; 1028 + } 1004 1029 in 1005 1030 Rendering.targets_source_odoc ~warnings_options ~syntax:OCaml 1006 1031 ~renderer:R.renderer ~output:output_dir ~extra ~source_file odoc_file
+8 -7
src/odoc/compile.ml
··· 121 121 imports 122 122 123 123 (** Raises warnings and errors. *) 124 - let resolve_and_substitute ~resolver ~make_root ~hidden 124 + let resolve_and_substitute ~resolver ~make_root ~hidden ~suppress_warnings 125 125 (parent : Paths.Identifier.ContainerPage.t option) input_file input_type = 126 126 let filename = Fs.File.to_string input_file in 127 127 let unit = 128 128 match input_type with 129 129 | `Cmti -> 130 - Odoc_loader.read_cmti ~make_root ~parent ~filename 130 + Odoc_loader.read_cmti ~make_root ~parent ~filename ~suppress_warnings 131 131 |> Error.raise_errors_and_warnings 132 132 | `Cmt -> 133 - Odoc_loader.read_cmt ~make_root ~parent ~filename 133 + Odoc_loader.read_cmt ~make_root ~parent ~filename ~suppress_warnings 134 134 |> Error.raise_errors_and_warnings 135 135 | `Cmi -> 136 - Odoc_loader.read_cmi ~make_root ~parent ~filename 136 + Odoc_loader.read_cmi ~make_root ~parent ~filename ~suppress_warnings 137 137 |> Error.raise_errors_and_warnings 138 138 in 139 139 let unit = { unit with hidden = hidden || unit.hidden } in ··· 246 246 >>= fun id -> Ok (id :> Paths.Identifier.Page.t)) 247 247 >>= fun id -> 248 248 let resolve content frontmatter = 249 - let zero_heading = Comment.find_zero_heading content in 249 + let zero_heading = Comment.find_zero_heading content.Comment.elements in 250 250 if (not (is_index_page id)) && has_children_order frontmatter then 251 251 Error.raise_warning 252 252 (Error.filename_only "Non-index page cannot specify @children_order." ··· 352 352 in 353 353 let result = 354 354 Error.catch_errors_and_warnings (fun () -> 355 - resolve_and_substitute ~resolver ~make_root ~hidden parent_id input 356 - input_type) 355 + resolve_and_substitute ~resolver ~make_root ~hidden 356 + ~suppress_warnings:warnings_options.suppress_warnings parent_id 357 + input input_type) 357 358 in 358 359 (* Extract warnings to write them into the output file *) 359 360 let _, warnings = Error.unpack_warnings result in
+9 -2
src/odoc/odoc_link.ml
··· 34 34 `Word "hidden."; 35 35 ] 36 36 in 37 - [ Comment (`Docs [ with_loc @@ `Paragraph (List.map with_loc sentence) ]) ] 37 + [ 38 + Comment 39 + (`Docs 40 + { 41 + elements = [ with_loc @@ `Paragraph (List.map with_loc sentence) ]; 42 + suppress_warnings = true; 43 + }); 44 + ] 38 45 39 46 let link_unit ~resolver ~filename m = 40 47 let open Odoc_model in ··· 49 56 items = content_for_hidden_modules; 50 57 compiled = false; 51 58 removed = []; 52 - doc = []; 59 + doc = { elements = []; suppress_warnings = false }; 53 60 }; 54 61 expansion = None; 55 62 }
+7 -1
src/odoc/url.ml
··· 7 7 in 8 8 let reference = 9 9 let open Odoc_model in 10 - let warnings_options = { Error.warn_error = true; print_warnings = true } in 10 + let warnings_options = 11 + { 12 + Error.warn_error = true; 13 + print_warnings = true; 14 + suppress_warnings = false; 15 + } 16 + in 11 17 Semantics.parse_reference reference 12 18 |> Error.handle_errors_and_warnings ~warnings_options 13 19 in
+1 -1
src/search/text.ml
··· 42 42 let get_value x = x.Odoc_model.Location_.value 43 43 44 44 let rec string_of_doc (doc : Odoc_model.Comment.docs) = 45 - doc |> List.map get_value 45 + doc.elements |> List.map get_value 46 46 |> List.map s_of_block_element 47 47 |> String.concat "\n" 48 48
+5 -1
src/xref2/compile.ml
··· 253 253 Component.Delayed.( 254 254 put (fun () -> Component.Of_Lang.(module_ (empty ()) m))) 255 255 in 256 - Env.add_module (m.id :> Paths.Identifier.Path.Module.t) ty [] env 256 + Env.add_module 257 + (m.id :> Paths.Identifier.Path.Module.t) 258 + ty 259 + { elements = []; suppress_warnings = false } 260 + env 257 261 in 258 262 let env = 259 263 match r with
+12 -4
src/xref2/component.ml
··· 456 456 | `Media of 457 457 Odoc_model.Comment.media_href * Odoc_model.Comment.media * string ] 458 458 459 - type docs = block_element Odoc_model.Comment.with_location list 459 + type docs = { 460 + elements : block_element Odoc_model.Comment.with_location list; 461 + suppress_warnings : bool; 462 + } 460 463 461 464 type docs_or_stop = [ `Docs of docs | `Stop ] 462 465 end = ··· 2704 2707 | { value = `Tag _ | `Media _; _ } as t -> t 2705 2708 | { value = #Odoc_model.Comment.nestable_block_element; _ } as n -> n 2706 2709 2707 - and docs ident_map d = List.map (block_element ident_map) d 2710 + and docs ident_map d = 2711 + { 2712 + elements = List.map (block_element ident_map) d.elements; 2713 + suppress_warnings = d.suppress_warnings; 2714 + } 2708 2715 2709 2716 and docs_or_stop ident_map = function 2710 2717 | `Docs d -> `Docs (docs ident_map d) ··· 2714 2721 let module_of_functor_argument (arg : FunctorParameter.parameter) = 2715 2722 { 2716 2723 Module.source_loc = None; 2717 - doc = []; 2724 + doc = { elements = []; suppress_warnings = false }; 2718 2725 type_ = ModuleType arg.expr; 2719 2726 canonical = None; 2720 2727 hidden = false; ··· 2723 2730 (** This is equivalent to {!Lang.extract_signature_doc}. *) 2724 2731 let extract_signature_doc (s : Signature.t) = 2725 2732 match (s.doc, s.items) with 2726 - | [], Include { expansion_; status = `Inline; _ } :: _ -> expansion_.doc 2733 + | { elements = []; _ }, Include { expansion_; status = `Inline; _ } :: _ -> 2734 + expansion_.doc 2727 2735 | doc, _ -> doc
+4 -1
src/xref2/component.mli
··· 433 433 | `Media of 434 434 Odoc_model.Comment.media_href * Odoc_model.Comment.media * string ] 435 435 436 - type docs = block_element Odoc_model.Comment.with_location list 436 + type docs = { 437 + elements : block_element Odoc_model.Comment.with_location list; 438 + suppress_warnings : bool; 439 + } 437 440 438 441 type docs_or_stop = [ `Docs of docs | `Stop ] 439 442 end
+21 -7
src/xref2/env.ml
··· 273 273 let label = Ident.Of_Identifier.label id in 274 274 add_label id { Component.Label.attrs; label; text; location } env 275 275 | _ -> env) 276 - env docs 276 + env docs.elements 277 277 278 278 let add_comment (com : Comment.docs_or_stop) env = 279 279 match com with `Docs doc -> add_docs doc env | `Stop -> env ··· 289 289 in 290 290 add_label label h env 291 291 | _ -> env) 292 - env docs 292 + env docs.elements 293 293 294 294 let add_module identifier m docs env = 295 295 let env' = add_to_elts Kind_Module identifier (`Module (identifier, m)) env in ··· 373 373 { 374 374 id; 375 375 source_loc = None; 376 - doc = []; 376 + doc = { elements = []; suppress_warnings = false }; 377 377 type_ = ModuleType (Signature s); 378 378 canonical = unit.canonical; 379 379 hidden = unit.hidden; ··· 387 387 { 388 388 id; 389 389 source_loc = None; 390 - doc = []; 390 + doc = { elements = []; suppress_warnings = false }; 391 391 type_ = 392 392 ModuleType 393 393 (Signature 394 - { items = []; compiled = true; removed = []; doc = [] }); 394 + { 395 + items = []; 396 + compiled = true; 397 + removed = []; 398 + doc = { elements = []; suppress_warnings = false }; 399 + }); 395 400 canonical = unit.canonical; 396 401 hidden = unit.hidden; 397 402 } ··· 644 649 let mk_functor_parameter module_type = 645 650 let type_ = Component.Module.ModuleType module_type in 646 651 Component.Module. 647 - { source_loc = None; doc = []; type_; canonical = None; hidden = false } 652 + { 653 + source_loc = None; 654 + doc = { elements = []; suppress_warnings = false }; 655 + type_; 656 + canonical = None; 657 + hidden = false; 658 + } 648 659 649 660 let add_functor_parameter : Lang.FunctorParameter.t -> t -> t = 650 661 fun p t -> ··· 656 667 let open Component.Of_Lang in 657 668 mk_functor_parameter (module_type_expr (empty ()) n.expr) 658 669 in 659 - add_module id (Component.Delayed.put_val m) [] t 670 + add_module id 671 + (Component.Delayed.put_val m) 672 + { elements = []; suppress_warnings = false } 673 + t 660 674 661 675 let add_functor_args' : 662 676 Paths.Identifier.Signature.t -> Component.ModuleType.expr -> t -> t =
+2 -2
src/xref2/find.ml
··· 271 271 | Some r -> Some (`In_type (N.typed_type id, typ, r)) 272 272 | None -> None) 273 273 | TypExt typext -> any_in_typext typext name 274 - | Comment (`Docs d) -> any_in_comment d (LabelName.make_std name) 274 + | Comment (`Docs d) -> any_in_comment d.elements (LabelName.make_std name) 275 275 | _ -> None) 276 276 277 277 let signature_in_sig sg name = ··· 303 303 304 304 let label_in_sig sg name = 305 305 filter_in_sig sg (function 306 - | Signature.Comment (`Docs d) -> any_in_comment d name 306 + | Signature.Comment (`Docs d) -> any_in_comment d.elements name 307 307 | _ -> None) 308 308 309 309 let exception_in_sig sg name =
+6 -1
src/xref2/lang_of.ml
··· 1092 1092 Identifier.LabelParent.t -> 1093 1093 Component.CComment.docs -> 1094 1094 Odoc_model.Comment.docs = 1095 - fun parent ds -> List.rev_map (fun d -> block_element parent d) ds |> List.rev 1095 + fun parent ds -> 1096 + { 1097 + elements = 1098 + List.rev_map (fun d -> block_element parent d) ds.elements |> List.rev; 1099 + suppress_warnings = ds.suppress_warnings; 1100 + } 1096 1101 1097 1102 and docs_or_stop parent (d : Component.CComment.docs_or_stop) = 1098 1103 match d with `Docs d -> `Docs (docs parent d) | `Stop -> `Stop
+109 -47
src/xref2/link.ml
··· 7 7 let map f = function Some x -> Some (f x) | None -> None 8 8 end 9 9 10 + (* omg. Our current warning system is spread on different system. Hence this 11 + atrocity. *) 12 + let maybe_suppress suppress_warnings = 13 + if suppress_warnings then fun f -> 14 + Lookup_failures.catch_failures ~filename:"" (fun () -> 15 + Error.catch_warnings f |> fun x -> 16 + Error.unpack_warnings x |> fst |> Error.unpack_warnings |> fst) 17 + |> Error.unpack_warnings |> fst 18 + else fun f -> f () |> Error.raise_warnings 19 + 10 20 let source_loc env id loc = 11 21 let id = (id :> Id.NonSrc.t) in 12 22 match loc with Some _ as loc -> loc | None -> Shape_tools.lookup_def env id 13 23 14 24 (** Equivalent to {!Comment.synopsis}. *) 15 25 let synopsis_from_comment (docs : Component.CComment.docs) = 16 - match docs with 26 + match docs.elements with 17 27 | ({ value = #Comment.nestable_block_element; _ } as e) :: _ -> 18 28 (* Only the first element is considered. *) 19 29 Comment.synopsis [ e ] ··· 222 232 p) 223 233 224 234 let rec comment_inline_element : 225 - loc:_ -> Env.t -> Comment.inline_element -> Comment.inline_element = 226 - fun ~loc:_ env x -> 235 + loc:_ -> Env.t -> bool -> Comment.inline_element -> Comment.inline_element = 236 + fun ~loc:_ env suppress_warnings x -> 227 237 match x with 228 238 | `Styled (s, ls) -> 229 - `Styled (s, List.map (with_location (comment_inline_element env)) ls) 239 + `Styled 240 + ( s, 241 + List.map 242 + (with_location (comment_inline_element env suppress_warnings)) 243 + ls ) 230 244 | `Reference (r, content) as orig -> ( 231 - match Ref_tools.resolve_reference env r |> Error.raise_warnings with 245 + match 246 + maybe_suppress suppress_warnings (fun () -> 247 + Ref_tools.resolve_reference env r) 248 + with 232 249 | Ok (ref_, c) -> 233 250 let content = 234 251 (* In case of labels, use the heading text as reference text if ··· 240 257 in 241 258 `Reference (`Resolved ref_, content) 242 259 | Error e -> 243 - Errors.report ~what:(`Reference r) ~tools_error:(`Reference e) 244 - `Resolve; 260 + if not suppress_warnings then 261 + Errors.report ~what:(`Reference r) ~tools_error:(`Reference e) 262 + `Resolve; 245 263 orig) 246 264 | y -> y 247 265 248 - and paragraph env elts = 249 - List.map (with_location (comment_inline_element env)) elts 266 + and paragraph env suppress_warnings elts = 267 + List.map (with_location (comment_inline_element env suppress_warnings)) elts 250 268 251 - and resolve_external_synopsis env synopsis = 269 + and resolve_external_synopsis env suppress_warnings synopsis = 252 270 let env = Env.inherit_resolver env in 253 - paragraph env synopsis 271 + paragraph env suppress_warnings synopsis 254 272 255 - and comment_nestable_block_element env parent ~loc:_ 273 + and comment_nestable_block_element env suppress_warnings parent ~loc:_ 256 274 (x : Comment.nestable_block_element) = 257 275 match x with 258 - | `Paragraph elts -> `Paragraph (paragraph env elts) 276 + | `Paragraph elts -> `Paragraph (paragraph env suppress_warnings elts) 259 277 | (`Code_block _ | `Math_block _ | `Verbatim _) as x -> x 260 278 | `List (x, ys) -> 261 279 `List 262 280 ( x, 263 - List.rev_map (comment_nestable_block_element_list env parent) ys 281 + List.rev_map 282 + (comment_nestable_block_element_list env suppress_warnings parent) 283 + ys 264 284 |> List.rev ) 265 285 | `Table { data; align } -> 266 286 let data = 267 287 let map f x = List.rev_map f x |> List.rev in 268 288 map 269 289 (map (fun (cell, cell_type) -> 270 - (comment_nestable_block_element_list env parent cell, cell_type))) 290 + ( comment_nestable_block_element_list env suppress_warnings 291 + parent cell, 292 + cell_type ))) 271 293 data 272 294 in 273 295 `Table { Comment.data; align } ··· 276 298 List.rev_map 277 299 (fun (r : Comment.module_reference) -> 278 300 match 279 - Ref_tools.resolve_module_reference env r.module_reference 280 - |> Error.raise_warnings 301 + maybe_suppress suppress_warnings (fun () -> 302 + Ref_tools.resolve_module_reference env r.module_reference) 281 303 with 282 304 | Ok (r, _, m) -> 283 305 let module_synopsis = 284 306 Opt.map 285 - (resolve_external_synopsis env) 307 + (resolve_external_synopsis env suppress_warnings) 286 308 (synopsis_of_module env m) 287 309 in 288 310 { Comment.module_reference = `Resolved r; module_synopsis } 289 311 | Error e -> 290 - Errors.report 291 - ~what:(`Reference (r.module_reference :> Paths.Reference.t)) 292 - ~tools_error:(`Reference e) `Resolve; 312 + if not suppress_warnings then 313 + Errors.report 314 + ~what:(`Reference (r.module_reference :> Paths.Reference.t)) 315 + ~tools_error:(`Reference e) `Resolve; 293 316 r) 294 317 refs 295 318 |> List.rev 296 319 in 297 320 `Modules refs 298 321 | `Media (`Reference r, m, content) as orig -> ( 299 - match Ref_tools.resolve_asset_reference env r |> Error.raise_warnings with 322 + match 323 + maybe_suppress suppress_warnings (fun () -> 324 + Ref_tools.resolve_asset_reference env r) 325 + with 300 326 | Ok x -> `Media (`Reference (`Resolved x), m, content) 301 327 | Error e -> 302 - Errors.report 303 - ~what:(`Reference (r :> Paths.Reference.t)) 304 - ~tools_error:(`Reference e) `Resolve; 328 + if not suppress_warnings then 329 + Errors.report 330 + ~what:(`Reference (r :> Paths.Reference.t)) 331 + ~tools_error:(`Reference e) `Resolve; 305 332 orig) 306 333 | `Media _ as orig -> orig 307 334 308 - and comment_nestable_block_element_list env parent 335 + and comment_nestable_block_element_list env suppress_warnings parent 309 336 (xs : Comment.nestable_block_element Comment.with_location list) = 310 - List.rev_map (with_location (comment_nestable_block_element env parent)) xs 337 + List.rev_map 338 + (with_location 339 + (comment_nestable_block_element env suppress_warnings parent)) 340 + xs 311 341 |> List.rev 312 342 313 - and comment_tag env parent ~loc:_ (x : Comment.tag) = 343 + and comment_tag env suppress_warnings parent ~loc:_ (x : Comment.tag) = 314 344 match x with 315 345 | `Deprecated content -> 316 - `Deprecated (comment_nestable_block_element_list env parent content) 346 + `Deprecated 347 + (comment_nestable_block_element_list env suppress_warnings parent 348 + content) 317 349 | `Param (name, content) -> 318 - `Param (name, comment_nestable_block_element_list env parent content) 350 + `Param 351 + ( name, 352 + comment_nestable_block_element_list env suppress_warnings parent 353 + content ) 319 354 | `Raise ((`Reference (r, reference_content) as orig), content) -> ( 320 - match Ref_tools.resolve_reference env r |> Error.raise_warnings with 355 + match 356 + maybe_suppress suppress_warnings (fun () -> 357 + Ref_tools.resolve_reference env r) 358 + with 321 359 | Ok (x, _) -> 322 360 `Raise 323 361 ( `Reference (`Resolved x, reference_content), 324 - comment_nestable_block_element_list env parent content ) 362 + comment_nestable_block_element_list env suppress_warnings parent 363 + content ) 325 364 | Error e -> 326 - Errors.report ~what:(`Reference r) ~tools_error:(`Reference e) 327 - `Resolve; 328 - `Raise (orig, comment_nestable_block_element_list env parent content)) 365 + if not suppress_warnings then 366 + Errors.report ~what:(`Reference r) ~tools_error:(`Reference e) 367 + `Resolve; 368 + `Raise 369 + ( orig, 370 + comment_nestable_block_element_list env suppress_warnings parent 371 + content )) 329 372 | `Raise ((`Code_span _ as orig), content) -> 330 - `Raise (orig, comment_nestable_block_element_list env parent content) 373 + `Raise 374 + ( orig, 375 + comment_nestable_block_element_list env suppress_warnings parent 376 + content ) 331 377 | `Return content -> 332 - `Return (comment_nestable_block_element_list env parent content) 378 + `Return 379 + (comment_nestable_block_element_list env suppress_warnings parent 380 + content) 333 381 | `See (kind, target, content) -> 334 - `See (kind, target, comment_nestable_block_element_list env parent content) 382 + `See 383 + ( kind, 384 + target, 385 + comment_nestable_block_element_list env suppress_warnings parent 386 + content ) 335 387 | `Before (version, content) -> 336 - `Before (version, comment_nestable_block_element_list env parent content) 388 + `Before 389 + ( version, 390 + comment_nestable_block_element_list env suppress_warnings parent 391 + content ) 337 392 | `Author _ | `Since _ | `Alert _ | `Version _ -> 338 393 x (* only contain primitives *) 339 394 340 - and comment_block_element env parent ~loc (x : Comment.block_element) = 395 + and comment_block_element env suppress_warnings parent ~loc 396 + (x : Comment.block_element) = 341 397 match x with 342 398 | #Comment.nestable_block_element as x -> 343 - (comment_nestable_block_element env parent ~loc x 399 + (comment_nestable_block_element env suppress_warnings parent ~loc x 344 400 :> Comment.block_element) 345 401 | `Heading (attrs, label, elems) -> 346 - let cie = comment_inline_element env in 402 + let cie = comment_inline_element env suppress_warnings in 347 403 let elems = 348 404 List.rev_map (fun ele -> with_location cie ele) elems |> List.rev 349 405 in 350 406 let h = (attrs, label, elems) in 351 407 check_ambiguous_label ~loc env h; 352 408 `Heading h 353 - | `Tag t -> `Tag (comment_tag env parent ~loc t) 409 + | `Tag t -> `Tag (comment_tag env suppress_warnings parent ~loc t) 354 410 355 411 and with_location : 356 412 type a. ··· 361 417 { value; location = loc } 362 418 363 419 and comment_docs env parent d = 364 - List.rev_map 365 - (with_location (comment_block_element env (parent :> Id.LabelParent.t))) 366 - d 367 - |> List.rev 420 + { 421 + Comment.elements = 422 + List.rev_map 423 + (with_location 424 + (comment_block_element env d.Comment.suppress_warnings 425 + (parent :> Id.LabelParent.t))) 426 + d.Comment.elements 427 + |> List.rev; 428 + suppress_warnings = d.suppress_warnings; 429 + } 368 430 369 431 and comment env parent = function 370 432 | `Stop -> `Stop
+1 -1
src/xref2/ref_tools.ml
··· 402 402 | _ -> find tl) 403 403 | [] -> Error (`Find_by_name (`Page, name)) 404 404 in 405 - find p.Odoc_model.Lang.Page.content 405 + find p.Odoc_model.Lang.Page.content.elements 406 406 407 407 let of_component _env ~parent_ref label = 408 408 Ok
+1 -1
src/xref2/tools.ml
··· 1711 1711 let sg = 1712 1712 (* Override the signature's documentation when the module also has 1713 1713 a comment attached. *) 1714 - match m.doc with [] -> sg | doc -> { sg with doc } 1714 + match m.doc.elements with [] -> sg | _ -> { sg with doc = m.doc } 1715 1715 in 1716 1716 Ok (Signature sg) 1717 1717 | Functor _ as f -> Ok f
+2 -2
test/frontmatter/frontmatter.t/run.t
··· 36 36 "toc_status": "None", 37 37 "order_category": "None" 38 38 } 39 - $ odoc_print page-one_frontmatter.odoc | jq '.content' 39 + $ odoc_print page-one_frontmatter.odoc | jq '.content.elements' 40 40 [ 41 41 { 42 42 "`Heading": [ ··· 91 91 "toc_status": "None", 92 92 "order_category": "None" 93 93 } 94 - $ odoc_print page-two_frontmatters.odoc | jq '.content' 94 + $ odoc_print page-two_frontmatters.odoc | jq '.content.elements' 95 95 [ 96 96 { 97 97 "`Heading": [
+7 -1
test/integration/dune
··· 1 + (env 2 + (_ 3 + (binaries 4 + (../odoc_print/odoc_print.exe as odoc_print)))) 5 + 1 6 (cram 2 7 (deps 3 - (package odoc))) 8 + (package odoc) 9 + %{bin:odoc_print})) 4 10 5 11 (cram 6 12 (applies_to json_expansion_with_sources)
+3
test/integration/suppress_warnings.t/main.mli
··· 1 + include Module_with_errors.S 2 + 3 +
+9
test/integration/suppress_warnings.t/module_with_errors.mli
··· 1 + module type S = sig 2 + (** {1:t section} *) 3 + 4 + type t 5 + 6 + val here_is_the_problem : t 7 + (** {!t} *) 8 + end 9 +
+20
test/integration/suppress_warnings.t/run.t
··· 1 + $ ocamlc -c -bin-annot module_with_errors.mli 2 + $ ocamlc -c -bin-annot main.mli 3 + 4 + $ odoc compile module_with_errors.cmti 5 + $ odoc compile main.cmti -I . 6 + $ odoc link main.odoc 7 + File "module_with_errors.mli", line 7, characters 6-10: 8 + Warning: While resolving the expansion of include at File "main.mli", line 1, character 0 9 + Reference to 't' is ambiguous. Please specify its kind: section-t, type-t. 10 + $ odoc html-generate -o html main.odocl 11 + $ odoc support-files -o html 12 + 13 + $ odoc compile --suppress-warnings module_with_errors.cmti 14 + $ odoc compile main.cmti -I . 15 + $ odoc link main.odoc 16 + $ odoc html-generate -o html2 main.odocl 17 + $ odoc support-files -o html2 18 + 19 + 20 +
+1 -1
test/model/semantics/test.ml
··· 11 11 ( Error.unpack_warnings, 12 12 Record 13 13 [ 14 - F ("value", fst, Indirect (fst, Comment_desc.docs)); 14 + F ("value", fst, Indirect (fst, Comment_desc.elements)); 15 15 F ("warnings", snd, List warning_desc); 16 16 ] ) 17 17
+3 -3
test/pages/resolution.t/run.t
··· 27 27 references should be to the correct identifiers - so top1 should be a RootPage, sub1 is a Page, sub2 is a LeafPage, and m1 is a Root. 28 28 29 29 This is the '{!childpage-sub1}' reference 30 - $ odoc_print page-top1.odocl | jq '.content[1]["`Paragraph"][0]["`Reference"][0]' 30 + $ odoc_print page-top1.odocl | jq '.content.elements[1]["`Paragraph"][0]["`Reference"][0]' 31 31 { 32 32 "`Resolved": { 33 33 "`Identifier": { ··· 47 47 } 48 48 49 49 This is the '{!childpage:sub2}' reference 50 - $ odoc_print page-top1.odocl | jq '.content[1]["`Paragraph"][2]["`Reference"][0]' 50 + $ odoc_print page-top1.odocl | jq '.content.elements[1]["`Paragraph"][2]["`Reference"][0]' 51 51 { 52 52 "`Resolved": { 53 53 "`Identifier": { ··· 67 67 } 68 68 69 69 This is the '{!childmodule:M1}' reference 70 - $ odoc_print page-sub1.odocl | jq '.content[1]["`Paragraph"][0]["`Reference"][0]' 70 + $ odoc_print page-sub1.odocl | jq '.content.elements[1]["`Paragraph"][0]["`Reference"][0]' 71 71 { 72 72 "`Resolved": { 73 73 "`Identifier": {
+20 -5
test/xref2/canonical_nested.t/run.t
··· 55 55 ] 56 56 }, 57 57 "source_loc": "None", 58 - "doc": [], 58 + "doc": { 59 + "elements": [], 60 + "suppress_warnings": "false" 61 + }, 59 62 "type_": { 60 63 "Alias": [ 61 64 { ··· 121 124 ] 122 125 }, 123 126 "source_loc": "None", 124 - "doc": [], 127 + "doc": { 128 + "elements": [], 129 + "suppress_warnings": "false" 130 + }, 125 131 "type_": { 126 132 "Alias": [ 127 133 { ··· 186 192 ] 187 193 }, 188 194 "source_loc": "None", 189 - "doc": [], 195 + "doc": { 196 + "elements": [], 197 + "suppress_warnings": "false" 198 + }, 190 199 "type_": { 191 200 "Alias": [ 192 201 { ··· 278 287 ] 279 288 }, 280 289 "source_loc": "None", 281 - "doc": [], 290 + "doc": { 291 + "elements": [], 292 + "suppress_warnings": "false" 293 + }, 282 294 "equation": { 283 295 "params": [], 284 296 "private_": "false", ··· 291 303 } 292 304 ], 293 305 "compiled": "true", 294 - "doc": [] 306 + "doc": { 307 + "elements": [], 308 + "suppress_warnings": "false" 309 + } 295 310 } 296 311 } 297 312 }
+8 -2
test/xref2/classes.t/run.t
··· 27 27 ] 28 28 }, 29 29 "source_loc": "None", 30 - "doc": [], 30 + "doc": { 31 + "elements": [], 32 + "suppress_warnings": "false" 33 + }, 31 34 "type_": { 32 35 "Class": [ 33 36 { ··· 64 67 ] 65 68 }, 66 69 "source_loc": "None", 67 - "doc": [], 70 + "doc": { 71 + "elements": [], 72 + "suppress_warnings": "false" 73 + }, 68 74 "type_": { 69 75 "Class": [ 70 76 {
+2 -2
test/xref2/cross_references.t/run.t
··· 11 11 12 12 Check that references are resolved: 13 13 14 - $ odoc_print a.odocl | jq '.content.Module.items[0].Type[1].doc[0]' 14 + $ odoc_print a.odocl | jq '.content.Module.items[0].Type[1].doc.elements[0]' 15 15 { 16 16 "`Paragraph": [ 17 17 { ··· 38 38 } 39 39 ] 40 40 } 41 - $ odoc_print b.odocl | jq '.content.Module.items[0].Type[1].doc[0]' 41 + $ odoc_print b.odocl | jq '.content.Module.items[0].Type[1].doc.elements[0]' 42 42 { 43 43 "`Paragraph": [ 44 44 {
+4 -1
test/xref2/deep_substitution.t/run.t
··· 38 38 ] 39 39 }, 40 40 "source_loc": "None", 41 - "doc": [], 41 + "doc": { 42 + "elements": [], 43 + "suppress_warnings": "false" 44 + }, 42 45 "equation": { 43 46 "params": [], 44 47 "private_": "false",
+9 -3
test/xref2/hidden_modules.t/run.t
··· 101 101 ] 102 102 }, 103 103 "source_loc": "None", 104 - "doc": [], 104 + "doc": { 105 + "elements": [], 106 + "suppress_warnings": "false" 107 + }, 105 108 "equation": { 106 109 "params": [], 107 110 "private_": "false", ··· 114 117 } 115 118 ], 116 119 "compiled": "true", 117 - "doc": [] 120 + "doc": { 121 + "elements": [], 122 + "suppress_warnings": "false" 123 + } 118 124 } 119 125 } 120 126 } ··· 128 134 ] 129 135 }, 130 136 "source_loc": "None", 131 - "doc": [], 137 + "doc": { "elements": [], "suppress_warnings": "false" }, 132 138 "type_": { 133 139 "Constr": [ 134 140 {
+1 -1
test/xref2/labels/page_labels.t/run.t
··· 1 1 $ odoc compile page.mld 2 2 $ odoc link page-page.odoc 3 - $ odoc_print page-page.odocl | jq '.content[1]["`Paragraph"][0]["`Reference"][0]' 3 + $ odoc_print page-page.odocl | jq '.content.elements[1]["`Paragraph"][0]["`Reference"][0]' 4 4 { 5 5 "`Resolved": { 6 6 "`Identifier": {
+3 -3
test/xref2/lib/common.cppo.ml
··· 70 70 71 71 let model_of_string str = 72 72 let cmti = cmti_of_string str in 73 - Odoc_loader__Cmti.read_interface (Some parent) "Root" cmti 73 + Odoc_loader__Cmti.read_interface (Some parent) "Root" false cmti 74 74 75 75 let model_of_string_impl str = 76 76 #if OCAML_VERSION < (4,13,0) ··· 78 78 #else 79 79 let cmt = (cmt_of_string str).structure in 80 80 #endif 81 - Odoc_loader__Cmt.read_implementation (Some parent) "Root" cmt 81 + Odoc_loader__Cmt.read_implementation (Some parent) "Root" false cmt 82 82 83 83 let signature_of_mli_string str = 84 84 Odoc_xref2.Ident.reset (); ··· 650 650 ) ~open_modules:[] 651 651 652 652 let warnings_options = 653 - { Odoc_model.Error.warn_error = false; print_warnings = true } 653 + { Odoc_model.Error.warn_error = false; print_warnings = true; suppress_warnings = false } 654 654 655 655 let handle_warnings ww = 656 656 match Odoc_model.Error.handle_warnings ~warnings_options ww with
+85 -82
test/xref2/module_type_alias.t/run.t
··· 23 23 $ odoc_print test.odocl | jq ".content.Module.items[2]" 24 24 { 25 25 "Comment": { 26 - "`Docs": [ 27 - { 28 - "`Paragraph": [ 29 - { 30 - "`Reference": [ 31 - { 32 - "`Resolved": { 33 - "`AliasModuleType": [ 34 - { 35 - "`Identifier": { 36 - "`ModuleType": [ 26 + "`Docs": { 27 + "elements": [ 28 + { 29 + "`Paragraph": [ 30 + { 31 + "`Reference": [ 32 + { 33 + "`Resolved": { 34 + "`AliasModuleType": [ 35 + { 36 + "`Identifier": { 37 + "`ModuleType": [ 38 + { 39 + "`Root": [ 40 + "None", 41 + "Test" 42 + ] 43 + }, 44 + "A" 45 + ] 46 + } 47 + }, 48 + { 49 + "`Identifier": { 50 + "`ModuleType": [ 51 + { 52 + "`Root": [ 53 + "None", 54 + "Test" 55 + ] 56 + }, 57 + "B" 58 + ] 59 + } 60 + } 61 + ] 62 + } 63 + }, 64 + [] 65 + ] 66 + }, 67 + "`Space", 68 + { 69 + "`Reference": [ 70 + { 71 + "`Resolved": { 72 + "`Type": [ 73 + { 74 + "`AliasModuleType": [ 37 75 { 38 - "`Root": [ 39 - "None", 40 - "Test" 41 - ] 76 + "`Identifier": { 77 + "`ModuleType": [ 78 + { 79 + "`Root": [ 80 + "None", 81 + "Test" 82 + ] 83 + }, 84 + "A" 85 + ] 86 + } 42 87 }, 43 - "A" 44 - ] 45 - } 46 - }, 47 - { 48 - "`Identifier": { 49 - "`ModuleType": [ 50 88 { 51 - "`Root": [ 52 - "None", 53 - "Test" 54 - ] 55 - }, 56 - "B" 89 + "`Identifier": { 90 + "`ModuleType": [ 91 + { 92 + "`Root": [ 93 + "None", 94 + "Test" 95 + ] 96 + }, 97 + "B" 98 + ] 99 + } 100 + } 57 101 ] 58 - } 59 - } 60 - ] 61 - } 62 - }, 63 - [] 64 - ] 65 - }, 66 - "`Space", 67 - { 68 - "`Reference": [ 69 - { 70 - "`Resolved": { 71 - "`Type": [ 72 - { 73 - "`AliasModuleType": [ 74 - { 75 - "`Identifier": { 76 - "`ModuleType": [ 77 - { 78 - "`Root": [ 79 - "None", 80 - "Test" 81 - ] 82 - }, 83 - "A" 84 - ] 85 - } 86 - }, 87 - { 88 - "`Identifier": { 89 - "`ModuleType": [ 90 - { 91 - "`Root": [ 92 - "None", 93 - "Test" 94 - ] 95 - }, 96 - "B" 97 - ] 98 - } 99 - } 100 - ] 101 - }, 102 - "t" 103 - ] 104 - } 105 - }, 106 - [] 107 - ] 108 - } 109 - ] 110 - } 111 - ] 102 + }, 103 + "t" 104 + ] 105 + } 106 + }, 107 + [] 108 + ] 109 + } 110 + ] 111 + } 112 + ], 113 + "suppress_warnings": "false" 114 + } 112 115 } 113 116 } 114 117