@@ -9,50 +9,65 @@ type entry = {
99module Generate = struct
1010 (* * Get plain text doc-comment from a doc comment *)
1111
12+ module C = Odoc_model. Comment
13+
1214 let get_value x = x.Odoc_model.Location_. value
1315
14- let rec string_of_doc (doc : Odoc_model.Comment .docs ) =
16+ let rec string_of_doc (doc : C .docs ) =
1517 doc |> List. map get_value
1618 |> List. map s_of_block_element
1719 |> String. concat " "
1820
19- and s_of_block_element (be : Odoc_model.Comment .block_element ) =
21+ and s_of_block_element (be : C .block_element ) =
2022 match be with
2123 | `Paragraph is -> inlines is
2224 | `Tag _ -> " "
2325 | `List (_ , ls ) ->
2426 List. map (fun x -> x |> List. map get_value |> List. map nestable) ls
2527 |> List. concat |> String. concat " "
26- | `Heading (_ , _ , h ) -> link_content h
28+ | `Heading (_ , _ , h ) -> inlines h
2729 | `Modules _ -> " "
28- | `Code_block (_ , s ) -> s |> get_value
30+ | `Code_block (_ , s , _ ) -> s |> get_value
2931 | `Verbatim v -> v
3032 | `Math_block m -> m
33+ | `Table { data; _ } -> grid data
34+
35+ and cell (c : _ C.cell ) =
36+ c |> fst |> List. map (fun x -> get_value x |> nestable) |> String. concat " "
3137
32- and nestable ( n : Odoc_model.Comment.nestable_block_element ) =
33- s_of_block_element (n :> Odoc_model.Comment.block_element )
38+ and row ( r : _ C.row ) = r |> List. map cell |> String. concat " "
39+ and grid ( g : _ C.grid ) = g |> List. map row |> String. concat " "
3440
35- and inlines is =
36- is |> List. map get_value |> List. map inline |> String. concat " "
41+ and nestable ( n : C.nestable_block_element ) =
42+ s_of_block_element (n :> C.block_element )
3743
38- and inline (i : Odoc_model.Comment.inline_element ) =
44+ and inlines (is : C.inline_element C.with_location list ) =
45+ is |> List. map (fun x -> get_value x |> inline) |> String. concat " "
46+
47+ and leaf_inline (i : C.leaf_inline_element ) =
3948 match i with
40- | `Code_span s -> s
49+ | `Space -> " "
4150 | `Word w -> w
51+ | `Code_span s -> s
4252 | `Math_span m -> m
43- | `Space -> " "
53+ | `Raw_markup (_ , _ ) -> " "
54+
55+ and inline (i : C.inline_element ) =
56+ match i with
57+ | #C. leaf_inline_element as i -> leaf_inline (i :> C.leaf_inline_element )
58+ | `Styled (_ , b ) -> inlines b
4459 | `Reference (_ , c ) -> link_content c
4560 | `Link (_ , c ) -> link_content c
46- | `Styled (_ , b ) -> inlines b
47- | `Raw_markup (_ , _ ) -> " "
4861
49- and link_content l =
50- l |> List. map get_value
51- |> List. map non_link_inline_element
52- |> String. concat " "
62+ and link_content (l : C.link_content ) = non_link_inlines l
63+
64+ and non_link_inline (x : C.non_link_inline_element ) =
65+ match x with
66+ | #C. leaf_inline_element as x -> leaf_inline (x :> C.leaf_inline_element )
67+ | `Styled (_ , b ) -> non_link_inlines b
5368
54- and non_link_inline_element ( n : Odoc_model.Comment. non_link_inline_element ) =
55- inline (n :> Odoc_model.Comment.inline_element )
69+ and non_link_inlines ( is : C. non_link_inline_element C.with_location list ) =
70+ is |> List. map ( fun x -> get_value x |> non_link_inline) |> String. concat " "
5671
5772 let rec full_name_aux : Odoc_model.Paths.Identifier.t -> string list =
5873 let open Odoc_model.Names in
@@ -80,6 +95,8 @@ module Generate = struct
8095 FieldName. to_string name :: full_name_aux (parent :> Identifier.t )
8196 | `Extension (parent , name ) ->
8297 ExtensionName. to_string name :: full_name_aux (parent :> Identifier.t )
98+ | `ExtensionDecl (parent , _ , name ) ->
99+ ExtensionName. to_string name :: full_name_aux (parent :> Identifier.t )
83100 | `Exception (parent , name ) ->
84101 ExceptionName. to_string name :: full_name_aux (parent :> Identifier.t )
85102 | `CoreException name -> [ ExceptionName. to_string name ]
@@ -96,6 +113,17 @@ module Generate = struct
96113 :: full_name_aux (parent :> Identifier.t )
97114 | `Label (parent , name ) ->
98115 LabelName. to_string name :: full_name_aux (parent :> Identifier.t )
116+ | `SourceDir (parent , name ) ->
117+ name :: full_name_aux (parent :> Identifier.t )
118+ | `AssetFile (parent , name ) ->
119+ name :: full_name_aux (parent :> Identifier.t )
120+ | `SourceLocationMod parent -> full_name_aux (parent :> Identifier.t )
121+ | `SourceLocation (parent , name ) ->
122+ DefName. to_string name :: full_name_aux (parent :> Identifier.t )
123+ | `SourceLocationInternal (parent , name ) ->
124+ LocalName. to_string name :: full_name_aux (parent :> Identifier.t )
125+ | `SourcePage (parent , name ) ->
126+ name :: full_name_aux (parent :> Identifier.t )
99127
100128 let prefixname :
101129 [< Odoc_model.Paths.Identifier. t_pv ] Odoc_model.Paths.Identifier. id ->
@@ -134,7 +162,14 @@ module Generate = struct
134162 | `CoreException _ -> " core exception"
135163 | `Constructor _ -> " constructor"
136164 | `Extension _ -> " extension"
165+ | `ExtensionDecl _ -> " extension-decl"
137166 | `Root _ -> " root"
167+ | `SourceDir _ -> " source dir"
168+ | `AssetFile _ -> " asset file"
169+ | `SourceLocationMod _ -> " source location mod"
170+ | `SourceLocation _ -> " source location"
171+ | `SourceLocationInternal _ -> " source location internal"
172+ | `SourcePage _ -> " source page"
138173 in
139174 let url = Odoc_html.Link. href ~config ~resolve: (Base " " ) url in
140175 let json =
@@ -172,6 +207,7 @@ module Load_doc = struct
172207 | `Constructor (parent , _ ) -> is_internal (parent :> Identifier.t )
173208 | `Field (parent , _ ) -> is_internal (parent :> Identifier.t )
174209 | `Extension (parent , _ ) -> is_internal (parent :> Identifier.t )
210+ | `ExtensionDecl (parent , _ , _ ) -> is_internal (parent :> Identifier.t )
175211 | `Exception (parent , _ ) -> is_internal (parent :> Identifier.t )
176212 | `CoreException _ -> false
177213 | `Value (_ , name ) -> ValueName. is_internal name
@@ -180,6 +216,13 @@ module Load_doc = struct
180216 | `Method (parent , _ ) -> is_internal (parent :> Identifier.t )
181217 | `InstanceVariable (parent , _ ) -> is_internal (parent :> Identifier.t )
182218 | `Label (parent , _ ) -> is_internal (parent :> Identifier.t )
219+ | `SourceDir (parent , _ ) -> is_internal (parent :> Identifier.t )
220+ | `AssetFile (parent , _ ) -> is_internal (parent :> Identifier.t )
221+ | `SourceLocationMod parent -> is_internal (parent :> Identifier.t )
222+ | `SourceLocation (parent , _ ) -> is_internal (parent :> Identifier.t )
223+ | `SourceLocationInternal (parent , _ ) ->
224+ is_internal (parent :> Identifier.t )
225+ | `SourcePage (parent , _ ) -> is_internal (parent :> Identifier.t )
183226
184227 let add t ppf =
185228 if is_internal t.id then ()
0 commit comments