@@ -74,10 +74,11 @@ and styled style ~emph_level =
74
74
| `Superscript -> (emph_level, Html. sup ~a: [] )
75
75
| `Subscript -> (emph_level, Html. sub ~a: [] )
76
76
77
- let rec internallink ~emph_level ~resolve ?(a = [] ) (t : InternalLink.t ) =
77
+ let rec internallink ~config ~emph_level ~resolve ?(a = [] ) (t : InternalLink.t )
78
+ =
78
79
match t with
79
80
| Resolved (uri , content ) ->
80
- let href = Link. href ~resolve uri in
81
+ let href = Link. href ~config ~ resolve uri in
81
82
let a = (a :> Html_types.a_attrib Html.attrib list ) in
82
83
let elt =
83
84
Html. a ~a: (Html. a_href href :: a) (inline_nolink ~emph_level content)
@@ -90,7 +91,7 @@ let rec internallink ~emph_level ~resolve ?(a = []) (t : InternalLink.t) =
90
91
* (ref_to_string ref)
91
92
* in *)
92
93
let a = Html. a_class [ " xref-unresolved" ] :: a in
93
- let elt = Html. span ~a (inline ~emph_level ~resolve content) in
94
+ let elt = Html. span ~a (inline ~config ~ emph_level ~resolve content) in
94
95
let elt = (elt :> phrasing Html.elt ) in
95
96
[ elt ]
96
97
@@ -100,7 +101,8 @@ and internallink_nolink ~emph_level
100
101
| Resolved (_ , content ) | Unresolved content ->
101
102
[ Html. span ~a (inline_nolink ~emph_level content) ]
102
103
103
- and inline ?(emph_level = 0 ) ~resolve (l : Inline.t ) : phrasing Html.elt list =
104
+ and inline ~config ?(emph_level = 0 ) ~resolve (l : Inline.t ) :
105
+ phrasing Html. elt list =
104
106
let one (t : Inline.one ) =
105
107
let a = class_ t.attr in
106
108
match t.desc with
@@ -112,13 +114,13 @@ and inline ?(emph_level = 0) ~resolve (l : Inline.t) : phrasing Html.elt list =
112
114
| Linebreak -> [ Html. br ~a () ]
113
115
| Styled (style , c ) ->
114
116
let emph_level, app_style = styled style ~emph_level in
115
- [ app_style @@ inline ~emph_level ~resolve c ]
117
+ [ app_style @@ inline ~config ~ emph_level ~resolve c ]
116
118
| Link (href , c ) ->
117
119
let a = (a :> Html_types.a_attrib Html.attrib list ) in
118
120
let content = inline_nolink ~emph_level c in
119
121
[ Html. a ~a: (Html. a_href href :: a) content ]
120
- | InternalLink c -> internallink ~emph_level ~resolve ~a c
121
- | Source c -> source (inline ~emph_level ~resolve ) ~a c
122
+ | InternalLink c -> internallink ~config ~ emph_level ~resolve ~a c
123
+ | Source c -> source (inline ~config ~ emph_level ~resolve ) ~a c
122
124
| Raw_markup r -> raw_markup r
123
125
in
124
126
Utils. list_concat_map ~f: one l
@@ -144,13 +146,13 @@ and inline_nolink ?(emph_level = 0) (l : Inline.t) :
144
146
in
145
147
Utils. list_concat_map ~f: one l
146
148
147
- let heading ~resolve (h : Heading.t ) =
149
+ let heading ~config ~ resolve (h : Heading.t ) =
148
150
let a, anchor =
149
151
match h.label with
150
152
| Some id -> ([ Html. a_id id ], mk_anchor_link id)
151
153
| None -> ([] , [] )
152
154
in
153
- let content = inline ~resolve h.title in
155
+ let content = inline ~config ~ resolve h.title in
154
156
let mk =
155
157
match h.level with
156
158
| 0 -> Html. h1
@@ -162,7 +164,7 @@ let heading ~resolve (h : Heading.t) =
162
164
in
163
165
mk ~a (anchor @ content)
164
166
165
- let rec block ~resolve (l : Block.t ) : flow Html.elt list =
167
+ let rec block ~config ~ resolve (l : Block.t ) : flow Html.elt list =
166
168
let as_flow x = (x : phrasing Html.elt list :> flow Html.elt list ) in
167
169
let one (t : Block.one ) =
168
170
let mk_block ?(extra_class = [] ) mk content =
@@ -171,29 +173,29 @@ let rec block ~resolve (l : Block.t) : flow Html.elt list =
171
173
in
172
174
match t.desc with
173
175
| Inline i ->
174
- if t.attr = [] then as_flow @@ inline ~resolve i
175
- else mk_block Html. span (inline ~resolve i)
176
- | Paragraph i -> mk_block Html. p (inline ~resolve i)
176
+ if t.attr = [] then as_flow @@ inline ~config ~ resolve i
177
+ else mk_block Html. span (inline ~config ~ resolve i)
178
+ | Paragraph i -> mk_block Html. p (inline ~config ~ resolve i)
177
179
| List (typ , l ) ->
178
180
let mk = match typ with Ordered -> Html. ol | Unordered -> Html. ul in
179
- mk_block mk (List. map (fun x -> Html. li (block ~resolve x)) l)
181
+ mk_block mk (List. map (fun x -> Html. li (block ~config ~ resolve x)) l)
180
182
| Description l ->
181
183
let item i =
182
184
let a = class_ i.Description. attr in
183
185
let term =
184
- (inline ~resolve i.Description. key
186
+ (inline ~config ~ resolve i.Description. key
185
187
: phrasing Html. elt list
186
188
:> flow Html. elt list )
187
189
in
188
- let def = block ~resolve i.Description. definition in
190
+ let def = block ~config ~ resolve i.Description. definition in
189
191
Html. li ~a (term @ (Html. txt " " :: def))
190
192
in
191
193
mk_block Html. ul (List. map item l)
192
194
| Raw_markup r -> raw_markup r
193
195
| Verbatim s -> mk_block Html. pre [ Html. txt s ]
194
196
| Source (lang_tag , c ) ->
195
197
let extra_class = [ " language-" ^ lang_tag ] in
196
- mk_block ~extra_class Html. pre (source (inline ~resolve ) c)
198
+ mk_block ~extra_class Html. pre (source (inline ~config ~ resolve ) c)
197
199
in
198
200
Utils. list_concat_map l ~f: one
199
201
@@ -210,13 +212,14 @@ let div : ([< Html_types.div_attrib ], [< item ], [> Html_types.div ]) Html.star
210
212
211
213
let spec_class attr = class_ (" spec" :: attr)
212
214
213
- let spec_doc_div ~resolve = function
215
+ let spec_doc_div ~config ~ resolve = function
214
216
| [] -> []
215
217
| docs ->
216
218
let a = [ Html. a_class [ " spec-doc" ] ] in
217
- [ div ~a (flow_to_item @@ block ~resolve docs) ]
219
+ [ div ~a (flow_to_item @@ block ~config ~ resolve docs) ]
218
220
219
- let rec documentedSrc ~resolve (t : DocumentedSrc.t ) : item Html.elt list =
221
+ let rec documentedSrc ~config ~resolve (t : DocumentedSrc.t ) :
222
+ item Html. elt list =
220
223
let open DocumentedSrc in
221
224
let take_code l =
222
225
Doctree.Take. until l ~classify: (function
@@ -239,14 +242,14 @@ let rec documentedSrc ~resolve (t : DocumentedSrc.t) : item Html.elt list =
239
242
| [] -> []
240
243
| (Code _ | Alternative _ ) :: _ ->
241
244
let code, _, rest = take_code t in
242
- source (inline ~resolve ) code @ to_html rest
243
- | Subpage subp :: _ -> subpage ~resolve subp
245
+ source (inline ~config ~ resolve ) code @ to_html rest
246
+ | Subpage subp :: _ -> subpage ~config ~ resolve subp
244
247
| (Documented _ | Nested _ ) :: _ ->
245
248
let l, _, rest = take_descr t in
246
249
let one { DocumentedSrc. attrs; anchor; code; doc; markers } =
247
250
let content =
248
251
match code with
249
- | `D code -> (inline ~resolve code :> item Html. elt list )
252
+ | `D code -> (inline ~config ~ resolve code :> item Html. elt list )
250
253
| `N n -> to_html n
251
254
in
252
255
let doc =
@@ -259,7 +262,7 @@ let rec documentedSrc ~resolve (t : DocumentedSrc.t) : item Html.elt list =
259
262
in
260
263
[
261
264
Html. div ~a: (class_ [ " def-doc" ])
262
- (delim opening @ block ~resolve doc @ delim closing);
265
+ (delim opening @ block ~config ~ resolve doc @ delim closing);
263
266
]
264
267
in
265
268
let extra_attr, extra_class, link = mk_anchor anchor in
@@ -272,10 +275,10 @@ let rec documentedSrc ~resolve (t : DocumentedSrc.t) : item Html.elt list =
272
275
in
273
276
to_html t
274
277
275
- and subpage ~resolve (subp : Subpage.t ) : item Html.elt list =
276
- items ~resolve subp.content.items
278
+ and subpage ~config ~ resolve (subp : Subpage.t ) : item Html.elt list =
279
+ items ~config ~ resolve subp.content.items
277
280
278
- and items ~resolve l : item Html.elt list =
281
+ and items ~config ~ resolve l : item Html.elt list =
279
282
let rec walk_items acc (t : Item.t list ) : item Html.elt list =
280
283
let continue_with rest elts =
281
284
(walk_items [@ tailcall]) (List. rev_append elts acc) rest
@@ -288,13 +291,13 @@ and items ~resolve l : item Html.elt list =
288
291
| Item. Text text -> Accum text
289
292
| _ -> Stop_and_keep )
290
293
in
291
- let content = flow_to_item @@ block ~resolve text in
294
+ let content = flow_to_item @@ block ~config ~ resolve text in
292
295
(continue_with [@ tailcall]) rest content
293
296
| Heading h :: rest ->
294
- (continue_with [@ tailcall]) rest [ heading ~resolve h ]
297
+ (continue_with [@ tailcall]) rest [ heading ~config ~ resolve h ]
295
298
| Include { attr; anchor; doc; content = { summary; status; content } }
296
299
:: rest ->
297
- let doc = spec_doc_div ~resolve doc in
300
+ let doc = spec_doc_div ~config ~ resolve doc in
298
301
let included_html = (items content :> item Html.elt list ) in
299
302
let a_class =
300
303
if List. length content = 0 then [ " odoc-include" ; " shadowed-include" ]
@@ -306,7 +309,8 @@ and items ~resolve l : item Html.elt list =
306
309
let summary =
307
310
let extra_attr, extra_class, anchor_link = mk_anchor anchor in
308
311
let a = spec_class (attr @ extra_class) @ extra_attr in
309
- Html. summary ~a @@ anchor_link @ source (inline ~resolve ) summary
312
+ Html. summary ~a @@ anchor_link
313
+ @ source (inline ~config ~resolve ) summary
310
314
in
311
315
let inner =
312
316
[
@@ -320,15 +324,15 @@ and items ~resolve l : item Html.elt list =
320
324
| `Inline -> doc @ included_html
321
325
| `Closed -> details ~open': false
322
326
| `Open -> details ~open': true
323
- | `Default -> details ~open': ! Tree . open_details
327
+ | `Default -> details ~open': ( Config . open_details config)
324
328
in
325
329
(continue_with [@ tailcall]) rest content
326
330
| Declaration { Item. attr; anchor; content; doc } :: rest ->
327
331
let extra_attr, extra_class, anchor_link = mk_anchor anchor in
328
332
let a = spec_class (attr @ extra_class) @ extra_attr in
329
- let content = anchor_link @ documentedSrc ~resolve content in
333
+ let content = anchor_link @ documentedSrc ~config ~ resolve content in
330
334
let spec =
331
- let doc = spec_doc_div ~resolve doc in
335
+ let doc = spec_doc_div ~config ~ resolve doc in
332
336
[ div ~a: [ Html. a_class [ " odoc-spec" ] ] (div ~a content :: doc) ]
333
337
in
334
338
(continue_with [@ tailcall]) rest spec
@@ -343,7 +347,7 @@ module Toc = struct
343
347
| `Closed | `Open | `Default -> false
344
348
| `Inline -> true
345
349
346
- let gen_toc ~resolve ~path i =
350
+ let gen_toc ~config ~ resolve ~path i =
347
351
let toc = Toc. compute path ~on_sub i in
348
352
let rec section { Toc. url; text; children } =
349
353
let text = inline_nolink text in
@@ -356,7 +360,7 @@ module Toc = struct
356
360
List. map (Format. asprintf " %a" (Tyxml.Html. pp_elt () )) text
357
361
|> String. concat " "
358
362
in
359
- let href = Link. href ~resolve url in
363
+ let href = Link. href ~config ~ resolve url in
360
364
{ title; title_str; href; children = List. map section children }
361
365
in
362
366
List. map section toc
@@ -370,32 +374,29 @@ module Page = struct
370
374
| `Closed | `Open | `Default -> None
371
375
| `Inline -> Some 0 )
372
376
373
- let rec include_ ?theme_uri indent { Subpage. content; _ } =
374
- page ?theme_uri indent content
377
+ let rec include_ ~config { Subpage. content; _ } = page ~config content
375
378
376
- and subpages ? theme_uri indent subpages =
377
- Utils. list_concat_map ~f: (include_ ?theme_uri indent ) subpages
379
+ and subpages ~ config subpages =
380
+ Utils. list_concat_map ~f: (include_ ~config ) subpages
378
381
379
- and page ? theme_uri ? support_uri indent p : Odoc_document.Renderer.page list =
382
+ and page ~ config p : Odoc_document.Renderer.page list =
380
383
let { Page. title; header; items = i; url } =
381
384
Doctree.Labels. disambiguate_page p
382
385
and subpages =
383
386
(* Don't use the output of [disambiguate_page] to avoid unecessarily
384
387
mangled labels. *)
385
- subpages ?theme_uri indent @@ Doctree.Subpages. compute p
388
+ subpages ~config @@ Doctree.Subpages. compute p
386
389
in
387
390
let resolve = Link. Current url in
388
391
let i = Doctree.Shift. compute ~on_sub i in
389
- let toc = Toc. gen_toc ~resolve ~path: url i in
390
- let header = items ~resolve header in
391
- let content = (items ~resolve i :> any Html. elt list ) in
392
- Tree. make ?theme_uri ?support_uri ~indent ~header ~toc ~url title content
393
- subpages
392
+ let toc = Toc. gen_toc ~config ~resolve ~path: url i in
393
+ let header = items ~config ~resolve header in
394
+ let content = (items ~config ~resolve i :> any Html. elt list ) in
395
+ Tree. make ~config ~header ~toc ~url title content subpages
394
396
end
395
397
396
- let render ?theme_uri ?support_uri ~indent page =
397
- Page. page ?theme_uri ?support_uri indent page
398
+ let render ~config page = Page. page ~config page
398
399
399
- let doc ~xref_base_uri b =
400
+ let doc ~config ~ xref_base_uri b =
400
401
let resolve = Link. Base xref_base_uri in
401
- block ~resolve b
402
+ block ~config ~ resolve b
0 commit comments