this repo has no description

Use Comment.elements in document and index

authored by

Jules Aguillon and committed by jon.recoil.org d51fbc0f 7276efd0

+51 -58
+2 -2
src/document/comment.ml
··· 413 413 Utils.flatmap ~f:item_element 414 414 @@ List.map (fun x -> x.Odoc_model.Location_.value) docs 415 415 416 - let to_ir (docs : Comment.docs) = 416 + let to_ir (docs : Comment.elements) = 417 417 Utils.flatmap ~f:block_element 418 - @@ List.map (fun x -> x.Odoc_model.Location_.value) docs.elements 418 + @@ List.map (fun x -> x.Odoc_model.Location_.value) docs 419 419 420 420 let has_doc docs = docs <> []
+18 -20
src/document/generator.ml
··· 530 530 field fld.mutable_ (fld.id :> Paths.Identifier.t) fld.type_ 531 531 in 532 532 let anchor = Some url in 533 - let rhs = Comment.to_ir fld.doc in 534 - let doc = 535 - if not (Comment.has_doc fld.doc.elements) then [] else rhs 536 - in 533 + let doc = fld.doc.elements in 534 + let rhs = Comment.to_ir doc in 535 + let doc = if not (Comment.has_doc doc) then [] else rhs in 537 536 let markers = Syntax.Comment.markers in 538 537 DocumentedSrc.Documented { anchor; attrs; code; doc; markers }) 539 538 in ··· 610 609 cstr.args cstr.res 611 610 in 612 611 let anchor = Some url in 613 - let rhs = Comment.to_ir cstr.doc in 614 - let doc = 615 - if not (Comment.has_doc cstr.doc.elements) then [] else rhs 616 - in 612 + let doc = cstr.doc.elements in 613 + let rhs = Comment.to_ir doc in 614 + let doc = if not (Comment.has_doc doc) then [] else rhs in 617 615 let markers = Syntax.Comment.markers in 618 616 DocumentedSrc.Nested { anchor; attrs; code; doc; markers }) 619 617 in ··· 625 623 let anchor = Some url in 626 624 let attrs = [ "def"; "variant"; Url.Anchor.string_of_kind url.kind ] in 627 625 let code = O.documentedSrc (O.txt "| ") @ constructor id t.args t.res in 628 - let doc = Comment.to_ir t.doc in 626 + let doc = Comment.to_ir t.doc.elements in 629 627 let markers = Syntax.Comment.markers in 630 628 DocumentedSrc.Nested { anchor; attrs; code; doc; markers } 631 629 ··· 646 644 in 647 645 let attr = [ "type"; "extension" ] in 648 646 let anchor = Some (Url.Anchor.extension_decl t) in 649 - let doc = Comment.to_ir t.doc in 647 + let doc = Comment.to_ir t.doc.elements in 650 648 let source_anchor = 651 649 (* Take the anchor from the first constructor only for consistency with 652 650 regular variants. *) ··· 666 664 in 667 665 let attr = [ "exception" ] in 668 666 let anchor = path_to_id t.id in 669 - let doc = Comment.to_ir t.doc in 667 + let doc = Comment.to_ir t.doc.elements in 670 668 let source_anchor = source_anchor t.source_loc in 671 669 Item.Declaration { attr; anchor; doc; content; source_anchor } 672 670 ··· 710 708 else O.txt " " ++ O.keyword "of" ++ O.sp ++ params)), 711 709 match doc with 712 710 | { elements = []; _ } -> None 713 - | _ -> Some (Comment.to_ir doc) )) 711 + | _ -> Some (Comment.to_ir doc.elements) )) 714 712 in 715 713 let markers = Syntax.Comment.markers in 716 714 try ··· 881 879 in 882 880 let attr = "type" :: (if is_substitution then [ "subst" ] else []) in 883 881 let anchor = path_to_id t.id in 884 - let doc = Comment.to_ir t.doc in 882 + let doc = Comment.to_ir t.doc.elements in 885 883 let source_anchor = source_anchor t.source_loc in 886 884 Item.Declaration { attr; anchor; doc; content; source_anchor } 887 885 end ··· 909 907 in 910 908 let attr = [ "value" ] @ extra_attr in 911 909 let anchor = path_to_id t.id in 912 - let doc = Comment.to_ir t.doc in 910 + let doc = Comment.to_ir t.doc.elements in 913 911 let source_anchor = source_anchor t.source_loc in 914 912 Item.Declaration { attr; anchor; doc; content; source_anchor } 915 913 end ··· 1010 1008 in 1011 1009 let attr = [ "method" ] in 1012 1010 let anchor = path_to_id t.id in 1013 - let doc = Comment.to_ir t.doc in 1011 + let doc = Comment.to_ir t.doc.elements in 1014 1012 Item.Declaration { attr; anchor; doc; content; source_anchor = None } 1015 1013 1016 1014 let instance_variable (t : Odoc_model.Lang.InstanceVariable.t) = ··· 1029 1027 in 1030 1028 let attr = [ "value"; "instance-variable" ] in 1031 1029 let anchor = path_to_id t.id in 1032 - let doc = Comment.to_ir t.doc in 1030 + let doc = Comment.to_ir t.doc.elements in 1033 1031 Item.Declaration { attr; anchor; doc; content; source_anchor = None } 1034 1032 1035 1033 let inherit_ (ih : Lang.ClassSignature.Inherit.t) = ··· 1043 1041 in 1044 1042 let attr = [ "inherit" ] in 1045 1043 let anchor = None in 1046 - let doc = Comment.to_ir ih.doc in 1044 + let doc = Comment.to_ir ih.doc.elements in 1047 1045 Item.Declaration { attr; anchor; doc; content; source_anchor = None } 1048 1046 1049 1047 let constraint_ (cst : Lang.ClassSignature.Constraint.t) = ··· 1052 1050 in 1053 1051 let attr = [] in 1054 1052 let anchor = None in 1055 - let doc = Comment.to_ir cst.doc in 1053 + let doc = Comment.to_ir cst.doc.elements in 1056 1054 Item.Declaration { attr; anchor; doc; content; source_anchor = None } 1057 1055 1058 1056 let class_signature (c : Lang.ClassSignature.t) = ··· 1314 1312 in 1315 1313 let attr = [ "module-substitution" ] in 1316 1314 let anchor = path_to_id t.id in 1317 - let doc = Comment.to_ir t.doc in 1315 + let doc = Comment.to_ir t.doc.elements in 1318 1316 Item.Declaration { attr; anchor; doc; content; source_anchor = None } 1319 1317 1320 1318 and module_type_substitution (t : Odoc_model.Lang.ModuleTypeSubstitution.t) ··· 1724 1722 synopsis because no page is generated to render it and we'd loose 1725 1723 the full documentation. 1726 1724 The documentation from the expansion is not used. *) 1727 - Comment.to_ir t.doc 1725 + Comment.to_ir t.doc.elements 1728 1726 in 1729 1727 Item.Include { attr; anchor; doc; content; source_anchor = None } 1730 1728 end
+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.elements with 97 + match Comment.find_zero_heading entry.doc with 98 98 | Some t -> t 99 99 | None -> 100 100 let name =
+1 -1
src/index/entry.ml
··· 62 62 63 63 type t = { 64 64 id : Odoc_model.Paths.Identifier.Any.t; 65 - doc : Odoc_model.Comment.docs; 65 + doc : Odoc_model.Comment.elements; 66 66 kind : kind; 67 67 } 68 68
+2 -2
src/index/entry.mli
··· 60 60 61 61 type t = { 62 62 id : Odoc_model.Paths.Identifier.Any.t; 63 - doc : Odoc_model.Comment.docs; 63 + doc : Odoc_model.Comment.elements; 64 64 kind : kind; 65 65 } 66 66 67 67 val entry : 68 68 id:[< Odoc_model.Paths.Identifier.Any.t_pv ] Odoc_model.Paths.Identifier.id -> 69 - doc:Odoc_model.Comment.docs -> 69 + doc:Odoc_model.Comment.elements -> 70 70 kind:kind -> 71 71 t
+16 -16
src/index/skeleton.ml
··· 6 6 type t = Entry.t Tree.t 7 7 8 8 module Entry = struct 9 + open Odoc_model.Comment 10 + 9 11 let of_comp_unit (u : Compilation_unit.t) = 10 12 let has_expansion = true in 11 13 let doc = 12 - match u.content with 13 - | Pack _ -> 14 - { Odoc_model.Comment.elements = []; suppress_warnings = false } 15 - | Module m -> m.doc 14 + match u.content with Pack _ -> [] | Module m -> m.doc.elements 16 15 in 17 16 Entry.entry ~id:u.id ~doc ~kind:(Module { has_expansion }) 18 17 ··· 20 19 let has_expansion = 21 20 match m.type_ with Alias (_, None) -> false | _ -> true 22 21 in 23 - Entry.entry ~id:m.id ~doc:m.doc ~kind:(Module { has_expansion }) 22 + Entry.entry ~id:m.id ~doc:m.doc.elements ~kind:(Module { has_expansion }) 24 23 25 24 let of_module_type (mt : ModuleType.t) = 26 25 let has_expansion = ··· 35 34 | _ -> false) 36 35 | _ -> true 37 36 in 38 - Entry.entry ~id:mt.id ~doc:mt.doc ~kind:(ModuleType { has_expansion }) 37 + Entry.entry ~id:mt.id ~doc:mt.doc.elements 38 + ~kind:(ModuleType { has_expansion }) 39 39 40 40 let of_type_decl (td : TypeDecl.t) = 41 41 let kind = ··· 46 46 representation = td.representation; 47 47 } 48 48 in 49 - Entry.entry ~id:td.id ~doc:td.doc ~kind 49 + Entry.entry ~id:td.id ~doc:td.doc.elements ~kind 50 50 51 51 let varify_params = 52 52 List.mapi (fun i param -> ··· 67 67 params ) 68 68 in 69 69 let kind = Entry.Constructor { args; res } in 70 - Entry.entry ~id:c.id ~doc:c.doc ~kind 70 + Entry.entry ~id:c.id ~doc:c.doc.elements ~kind 71 71 72 72 let of_field id_parent params (field : TypeDecl.Field.t) = 73 73 let params = varify_params params in ··· 81 81 Entry.Field 82 82 { mutable_ = field.mutable_; type_ = field.type_; parent_type } 83 83 in 84 - Entry.entry ~id:field.id ~doc:field.doc ~kind 84 + Entry.entry ~id:field.id ~doc:field.doc.elements ~kind 85 85 86 86 let of_exception (exc : Exception.t) = 87 87 let res = ··· 93 93 | Some x -> x 94 94 in 95 95 let kind = Entry.Exception { args = exc.args; res } in 96 - Entry.entry ~id:exc.id ~doc:exc.doc ~kind 96 + Entry.entry ~id:exc.id ~doc:exc.doc.elements ~kind 97 97 98 98 let of_value (v : Value.t) = 99 99 let kind = Entry.Value { value = v.value; type_ = v.type_ } in 100 - Entry.entry ~id:v.id ~doc:v.doc ~kind 100 + Entry.entry ~id:v.id ~doc:v.doc.elements ~kind 101 101 102 102 let of_extension_constructor type_path params (v : Extension.Constructor.t) = 103 103 let res = ··· 108 108 TypeExpr.Constr (type_path, params) 109 109 in 110 110 let kind = Entry.ExtensionConstructor { args = v.args; res } in 111 - Entry.entry ~id:v.id ~doc:v.doc ~kind 111 + Entry.entry ~id:v.id ~doc:v.doc.elements ~kind 112 112 113 113 let of_class (cl : Class.t) = 114 114 let kind = Entry.Class { virtual_ = cl.virtual_; params = cl.params } in 115 - Entry.entry ~id:cl.id ~doc:cl.doc ~kind 115 + Entry.entry ~id:cl.id ~doc:cl.doc.elements ~kind 116 116 117 117 let of_class_type (ct : ClassType.t) = 118 118 let kind = 119 119 Entry.Class_type { virtual_ = ct.virtual_; params = ct.params } 120 120 in 121 - Entry.entry ~id:ct.id ~doc:ct.doc ~kind 121 + Entry.entry ~id:ct.id ~doc:ct.doc.elements ~kind 122 122 123 123 let of_method (m : Method.t) = 124 124 let kind = 125 125 Entry.Method 126 126 { virtual_ = m.virtual_; private_ = m.private_; type_ = m.type_ } 127 127 in 128 - Entry.entry ~id:m.id ~doc:m.doc ~kind 128 + Entry.entry ~id:m.id ~doc:m.doc.elements ~kind 129 129 130 - let of_docs id doc = Entry.entry ~id ~doc ~kind:Doc 130 + let of_docs id doc = Entry.entry ~id ~doc:doc.elements ~kind:Doc 131 131 end 132 132 133 133 let if_non_hidden id f =
+4 -9
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 - 44 42 let entry_of_page page = 45 43 let kind = Entry.Page page.Lang.Page.frontmatter in 46 - let doc = page.content in 44 + let doc = page.content.elements in 47 45 let id = page.name in 48 46 Entry.entry ~kind ~doc ~id 49 47 in 50 48 let entry_of_impl id = 51 49 let kind = Entry.Impl in 52 - let doc = empty_doc in 53 - Entry.entry ~kind ~doc ~id 50 + Entry.entry ~kind ~doc:[] ~id 54 51 in 55 52 let children_order, index = 56 53 match In_progress.index dir with ··· 63 60 match In_progress.root_dir dir with 64 61 | Some id -> 65 62 let kind = Entry.Dir in 66 - let doc = empty_doc in 67 - Entry.entry ~kind ~doc ~id 63 + Entry.entry ~kind ~doc:[] ~id 68 64 | None -> 69 65 let id = 70 66 (* root dir must have an index page *) 71 67 Id.Mk.leaf_page (None, Names.PageName.make_std "index") 72 68 in 73 69 let kind = Entry.Dir in 74 - let doc = empty_doc in 75 - Entry.entry ~kind ~doc ~id 70 + Entry.entry ~kind ~doc:[] ~id 76 71 in 77 72 (None, entry) 78 73 in
+1 -1
src/odoc/html_fragment.ml
··· 34 34 Odoc_xref2.Link.resolve_page ~filename:input_s env page 35 35 |> Odoc_model.Error.handle_warnings ~warnings_options 36 36 >>= fun resolved -> 37 - let page = Odoc_document.Comment.to_ir resolved.content in 37 + let page = Odoc_document.Comment.to_ir resolved.content.elements in 38 38 let config = 39 39 Odoc_html.Config.v ~semantic_uris:false ~indent:false ~flat:false 40 40 ~open_details:false ~as_json:false ~remap:[] ()
+2 -2
src/search/html.mli
··· 27 27 The tuple is intended to be given respectively to the [prefix_name] and 28 28 [name] arguments of {!Odoc_html_frontend.of_strings}. *) 29 29 30 - val of_doc : Comment.docs -> html 30 + val of_doc : Comment.elements -> html 31 31 (** [of_doc d] returns the HTML associated of the documentation comment [d], 32 32 generated correctly for search (no links or anchors). *) 33 33 34 - val html_string_of_doc : Comment.docs -> string 34 + val html_string_of_doc : Comment.elements -> string 35 35 (** [html_string_of_doc d] is the same as {!of_doc} converted to a 36 36 string. *) 37 37
+1 -1
src/search/json_index/json_search.ml
··· 81 81 82 82 let of_id n = `Array (List.rev @@ of_id (n :> Odoc_model.Paths.Identifier.t)) 83 83 84 - let of_doc (doc : Odoc_model.Comment.docs) = 84 + let of_doc (doc : Odoc_model.Comment.elements) = 85 85 let txt = Text.of_doc doc in 86 86 `String txt 87 87
+2 -2
src/search/text.ml
··· 41 41 42 42 let get_value x = x.Odoc_model.Location_.value 43 43 44 - let rec string_of_doc (doc : Odoc_model.Comment.docs) = 45 - doc.elements |> List.map get_value 44 + let rec string_of_doc (doc : Odoc_model.Comment.elements) = 45 + doc |> List.map get_value 46 46 |> List.map s_of_block_element 47 47 |> String.concat "\n" 48 48
+1 -1
src/search/text.mli
··· 4 4 5 5 val of_type : Odoc_model.Lang.TypeExpr.t -> string 6 6 7 - val of_doc : Odoc_model.Comment.docs -> string 7 + val of_doc : Odoc_model.Comment.elements -> string 8 8 9 9 val of_record : Odoc_model.Lang.TypeDecl.Field.t list -> string