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