this repo has no description
1open Type_desc
2open Odoc_model
3open Comment
4open Paths_desc
5
6let ignore_loc x = x.Location_.value
7
8let media =
9 Variant
10 (function
11 | `Link -> C0 "`Link"
12 | `Audio -> C0 "`Audio"
13 | `Video -> C0 "`Video"
14 | `Image -> C0 "`Image")
15
16let rec leaf_inline_element_fn : Odoc_model.Comment.leaf_inline_element -> case
17 = function
18 | `Space -> C0 "`Space"
19 | `Word x -> C ("`Word", x, string)
20 | `Code_span x -> C ("`Code_span", x, string)
21 | `Math_span x -> C ("`Math_span", x, string)
22 | `Raw_markup (x1, x2) -> C ("`Raw_markup", (x1, x2), Pair (string, string))
23
24and style =
25 Variant
26 (function
27 | `Bold -> C0 "`Bold"
28 | `Italic -> C0 "`Italic"
29 | `Emphasis -> C0 "`Emphasis"
30 | `Superscript -> C0 "`Superscript"
31 | `Subscript -> C0 "`Subscript")
32
33and non_link_inline_element_fn : non_link_inline_element -> case = function
34 | #leaf_inline_element as x -> leaf_inline_element_fn x
35 | `Styled (x1, x2) -> C ("`Styled", (x1, x2), Pair (style, link_content))
36
37and reference_element_fn : reference_element -> case = function
38 | `Reference (x1, x2) ->
39 C ("`Reference", (x1, x2), Pair (reference, link_content))
40
41and inline_element_fn : inline_element -> case = function
42 | #leaf_inline_element as x -> leaf_inline_element_fn x
43 | #reference_element as x -> reference_element_fn x
44 | `Styled (x1, x2) -> C ("`Styled", (x1, x2), Pair (style, paragraph))
45 | `Link (x1, x2) -> C ("`Link", (x1, x2), Pair (string, link_content))
46
47and link_content =
48 List (Indirect (ignore_loc, Variant non_link_inline_element_fn))
49
50and inline_element = Variant inline_element_fn
51
52and paragraph = List (Indirect (ignore_loc, inline_element))
53
54let module_reference =
55 let simplify m =
56 ((m.module_reference :> Paths.Reference.t), m.module_synopsis)
57 in
58 Indirect (simplify, Pair (reference, Option paragraph))
59
60let heading =
61 let heading_level =
62 Variant
63 (function
64 | `Title -> C0 "`Title"
65 | `Section -> C0 "`Section"
66 | `Subsection -> C0 "`Subsection"
67 | `Subsubsection -> C0 "`Subsubsection"
68 | `Paragraph -> C0 "`Paragraph"
69 | `Subparagraph -> C0 "`Subparagraph")
70 in
71 let heading_attrs =
72 Record
73 [
74 F ("heading_level", (fun h -> h.heading_level), heading_level);
75 F ("heading_label_explicit", (fun h -> h.heading_label_explicit), bool);
76 ]
77 in
78 Triple (heading_attrs, identifier, paragraph)
79
80let media_href =
81 Variant
82 (function
83 | `Reference r ->
84 C ("`Reference", (r : Reference.Asset.t :> Reference.t), reference)
85 | `Link l -> C ("`Link", l, string))
86
87let code_block_tag : Odoc_parser.Ast.code_block_tag t =
88 Variant
89 (function
90 | `Tag x -> C ("`Tag", ignore_loc x, string)
91 | `Binding (x1, x2) ->
92 C ("`Binding", (ignore_loc x1, ignore_loc x2), Pair (string, string)))
93
94let code_block_meta : Odoc_parser.Ast.code_block_meta t =
95 Record
96 [
97 F ("language", (fun h -> ignore_loc h.language), string);
98 F ("warnings_tag", (fun h -> h.tags), List code_block_tag);
99 ]
100
101let rec code_block : code_block t =
102 Record
103 [
104 F ("meta", (fun h -> h.meta), Option code_block_meta);
105 F ("delimiter", (fun h -> h.delimiter), Option string);
106 F ("content", (fun h -> ignore_loc h.content), string);
107 F ("output", (fun h -> h.output), Option nestable_elements);
108 ]
109
110and nestable_block_element_fn : nestable_block_element -> case =
111 let list_kind =
112 Variant
113 (function `Unordered -> C0 "`Unordered" | `Ordered -> C0 "`Ordered")
114 in
115 function
116 | `Paragraph x -> C ("`Paragraph", x, paragraph)
117 | `Code_block c -> C ("`Code_block", c, code_block)
118 | `Math_block x -> C ("`Math_block", x, string)
119 | `Verbatim x -> C ("`Verbatim", x, string)
120 | `Modules x -> C ("`Modules", x, List module_reference)
121 | `Table { data; align } ->
122 let cell_type_desc =
123 Variant (function `Header -> C0 "`Header" | `Data -> C0 "`Data")
124 in
125 let data_desc = List (List (Pair (nestable_elements, cell_type_desc))) in
126 let align_desc =
127 Option
128 (Variant
129 (function
130 | `Left -> C0 "`Left"
131 | `Center -> C0 "`Center"
132 | `Right -> C0 "`Right"))
133 in
134 let align_desc = List align_desc in
135 let table_desc = Pair (data_desc, Option align_desc) in
136 C ("`Table", (data, align), table_desc)
137 | `List (x1, x2) ->
138 C ("`List", (x1, x2), Pair (list_kind, List nestable_elements))
139 | `Media (x1, m, x2) ->
140 C ("`Media", (x1, m, x2), Triple (media_href, media, string))
141
142and nestable_block_element : nestable_block_element t =
143 Variant nestable_block_element_fn
144
145and nestable_elements : nestable_block_element with_location list t =
146 List
147 (Indirect
148 ( (fun x ->
149 let x :> nestable_block_element Location_.with_location = x in
150 ignore_loc x),
151 nestable_block_element ))
152
153and block_element : block_element t =
154 Variant
155 (function
156 | #nestable_block_element as x -> nestable_block_element_fn x
157 | `Heading (x1, x2, x3) ->
158 C ("`Heading", (x1, (x2 :> Identifier.t), x3), heading)
159 | `Tag x -> C ("`Tag", x, tag))
160
161and tag : tag t =
162 let url_kind =
163 Variant
164 (function
165 | `Url -> C0 "`Url"
166 | `File -> C0 "`File"
167 | `Document -> C0 "`Document")
168 in
169 Variant
170 (function
171 | `Author x -> C ("`Author", x, string)
172 | `Deprecated x -> C ("`Deprecated", x, nestable_elements)
173 | `Param (x1, x2) -> C ("`Param", (x1, x2), Pair (string, nestable_elements))
174 | `Raise (`Code_span x1, x2) ->
175 C ("`Raise", (x1, x2), Pair (string, nestable_elements))
176 | `Raise (`Reference (x1, x2), x3) ->
177 C
178 ( "`Raise",
179 (x1, x2, x3),
180 Triple (reference, link_content, nestable_elements) )
181 | `Return x -> C ("`Return", x, nestable_elements)
182 | `See (x1, x2, x3) ->
183 C ("`See", (x1, x2, x3), Triple (url_kind, string, nestable_elements))
184 | `Since x -> C ("`Since", x, string)
185 | `Before (x1, x2) ->
186 C ("`Before", (x1, x2), Pair (string, nestable_elements))
187 | `Version x -> C ("`Version", x, string)
188 | `Alert (x1, x2) -> C ("`Alert", (x1, x2), Pair (string, Option string))
189 | `Custom (x1, x2) -> C ("`" ^ x1, x2, nestable_elements))
190
191let elements : elements t = List (Indirect (ignore_loc, block_element))
192
193let docs =
194 Record
195 [
196 F ("elements", (fun h -> h.elements), elements);
197 F ("warnings_tag", (fun h -> h.warnings_tag), Option string);
198 ]
199
200let docs_or_stop : docs_or_stop t =
201 Variant (function `Docs x -> C ("`Docs", x, docs) | `Stop -> C0 "`Stop")
202
203let inline_elements : inline_element with_location list t =
204 List (Indirect (ignore_loc, inline_element))