Skip to content

Commit 593f076

Browse files
committed
Move HTML types into a separate module
1 parent 1759051 commit 593f076

File tree

10 files changed

+52
-53
lines changed

10 files changed

+52
-53
lines changed

src/html/generator.ml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -337,13 +337,7 @@ and items ~resolve l : item Html.elt list =
337337

338338
module Toc = struct
339339
open Odoc_document.Doctree
340-
341-
type t = Tree.toc = {
342-
title : Html_types.flow5_without_interactive Html.elt list;
343-
title_str : string;
344-
href : string;
345-
children : t list;
346-
}
340+
open Types
347341

348342
let on_sub : Subpage.status -> bool = function
349343
| `Closed | `Open | `Default -> false

src/html/generator.mli

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
open Odoc_document
21

32
val render :
4-
?theme_uri:Tree.uri ->
5-
?support_uri:Tree.uri ->
3+
?theme_uri:Types.uri ->
4+
?support_uri:Types.uri ->
65
indent:bool ->
7-
Types.Page.t ->
8-
Renderer.page list
6+
Odoc_document.Types.Page.t ->
7+
Odoc_document.Renderer.page list
98

109
val doc :
1110
xref_base_uri:string ->
12-
Types.Block.t ->
11+
Odoc_document.Types.Block.t ->
1312
Html_types.flow5_without_sectioning_heading_header_footer Tyxml.Html.elt list

src/html/odoc_html.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
module Types = Types
12
module Tree = Tree
23
(** @canonical Odoc_html.Tree *)
34

src/html/tree.ml

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,8 @@
1616

1717
module Html = Tyxml.Html
1818

19-
type uri = Absolute of string | Relative of Odoc_document.Url.Path.t option
20-
21-
type toc = {
22-
title : Html_types.flow5_without_interactive Html.elt list;
23-
title_str : string;
24-
href : string;
25-
children : toc list;
26-
}
27-
2819
let html_of_toc toc =
20+
let open Types in
2921
let rec section section =
3022
let link = Html.a ~a:[ Html.a_href section.href ] section.title in
3123
match section.children with [] -> [ link ] | cs -> [ link; sections cs ]
@@ -38,7 +30,7 @@ let html_of_toc toc =
3830
| [] -> []
3931
| _ -> [ Html.nav ~a:[ Html.a_class [ "odoc-toc" ] ] [ sections toc ] ]
4032

41-
let page_creator ?(theme_uri = Relative None) ?(support_uri = Relative None)
33+
let page_creator ?(theme_uri = Types.Relative None) ?(support_uri = Types.Relative None)
4234
~url name header toc content =
4335
let path = Link.Path.for_printing url in
4436

@@ -47,7 +39,7 @@ let page_creator ?(theme_uri = Relative None) ?(support_uri = Relative None)
4739

4840
let file_uri base file =
4941
match base with
50-
| Absolute uri -> uri ^ "/" ^ file
42+
| Types.Absolute uri -> uri ^ "/" ^ file
5143
| Relative uri ->
5244
let page =
5345
Odoc_document.Url.Path.{ kind = `File; parent = uri; name = file }

src/html/tree.mli

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,37 +14,24 @@
1414
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1515
*)
1616

17-
open Odoc_document
1817
module Html = Tyxml.Html
1918

2019
(** Supported languages for printing code parts. *)
2120

22-
type toc = {
23-
title : Html_types.flow5_without_interactive Html.elt list;
24-
title_str : string;
25-
href : string;
26-
children : toc list;
27-
}
28-
29-
type uri =
30-
| Absolute of string
31-
| Relative of Odoc_document.Url.Path.t option
32-
(** The type for absolute and relative URIs. The relative URIs are resolved
33-
using the HTML output directory as a target. *)
3421

3522
(** {1 Page creator} *)
3623

3724
val make :
38-
?theme_uri:uri ->
39-
?support_uri:uri ->
25+
?theme_uri:Types.uri ->
26+
?support_uri:Types.uri ->
4027
indent:bool ->
41-
url:Url.Path.t ->
28+
url:Odoc_document.Url.Path.t ->
4229
header:Html_types.flow5_without_header_footer Html.elt list ->
43-
toc:toc list ->
30+
toc:Types.toc list ->
4431
string ->
4532
Html_types.div_content Html.elt list ->
46-
Renderer.page list ->
47-
Renderer.page list
33+
Odoc_document.Renderer.page list ->
34+
Odoc_document.Renderer.page list
4835
(** [make ?theme_uri (body, children)] calls "the page creator" to turn [body]
4936
into an [[ `Html ] elt]. If [theme_uri] is provided, it will be used to
5037
locate the theme files, otherwise the HTML output directory is used. *)

src/html/types.ml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
(* Type definitions for the HTML renderer *)
2+
3+
type uri = Absolute of string | Relative of Odoc_document.Url.Path.t option
4+
5+
type toc = {
6+
title : Html_types.flow5_without_interactive Tyxml.Html.elt list;
7+
title_str : string;
8+
href : string;
9+
children : toc list;
10+
}

src/html/types.mli

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
2+
type uri =
3+
| Absolute of string
4+
| Relative of Odoc_document.Url.Path.t option
5+
(** The type for absolute and relative URIs. The relative URIs are resolved
6+
using the HTML output directory as a target. *)
7+
8+
9+
type toc = {
10+
title : Html_types.flow5_without_interactive Tyxml.Html.elt list;
11+
title_str : string;
12+
href : string;
13+
children : toc list;
14+
}
15+
16+

src/odoc/bin/main.ml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ module Odoc_html = Make_renderer (struct
483483
Arg.(value & flag (info ~doc [ "indent" ]))
484484

485485
(* Very basic validation and normalization for URI paths. *)
486-
let convert_uri : Odoc_html.Tree.uri Arg.conv =
486+
let convert_uri : Odoc_html.Types.uri Arg.conv =
487487
let parser str =
488488
if String.length str = 0 then `Error "invalid URI"
489489
else
@@ -509,12 +509,12 @@ module Odoc_html = Make_renderer (struct
509509
l ~init:None
510510
in
511511
`Ok
512-
Odoc_html.Tree.(
512+
Odoc_html.Types.(
513513
if is_absolute then Absolute str else Relative (conv_rel str))
514514
in
515515
let printer ppf = function
516-
| Odoc_html.Tree.Absolute uri -> Format.pp_print_string ppf uri
517-
| Odoc_html.Tree.Relative _uri -> Format.pp_print_string ppf ""
516+
| Odoc_html.Types.Absolute uri -> Format.pp_print_string ppf uri
517+
| Odoc_html.Types.Relative _uri -> Format.pp_print_string ppf ""
518518
in
519519
(parser, printer)
520520

@@ -523,7 +523,7 @@ module Odoc_html = Make_renderer (struct
523523
"Where to look for theme files (e.g. `URI/odoc.css'). Relative URIs are \
524524
resolved using `--output-dir' as a target."
525525
in
526-
let default = Odoc_html.Tree.Relative None in
526+
let default = Odoc_html.Types.Relative None in
527527
Arg.(
528528
value & opt convert_uri default & info ~docv:"URI" ~doc [ "theme-uri" ])
529529

@@ -532,7 +532,7 @@ module Odoc_html = Make_renderer (struct
532532
"Where to look for support files (e.g. `URI/highlite.pack.js'). Relative \
533533
URIs are resolved using `--output-dir' as a target."
534534
in
535-
let default = Odoc_html.Tree.Relative None in
535+
let default = Odoc_html.Types.Relative None in
536536
Arg.(
537537
value & opt convert_uri default & info ~docv:"URI" ~doc [ "support-uri" ])
538538

src/odoc/html_page.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ type args = {
2020
semantic_uris : bool;
2121
closed_details : bool;
2222
indent : bool;
23-
theme_uri : Odoc_html.Tree.uri;
24-
support_uri : Odoc_html.Tree.uri;
23+
theme_uri : Odoc_html.Types.uri;
24+
support_uri : Odoc_html.Types.uri;
2525
flat : bool;
2626
}
2727

src/odoc/html_page.mli

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ type args = {
2020
semantic_uris : bool;
2121
closed_details : bool;
2222
indent : bool;
23-
theme_uri : Odoc_html.Tree.uri;
24-
support_uri : Odoc_html.Tree.uri;
23+
theme_uri : Odoc_html.Types.uri;
24+
support_uri : Odoc_html.Types.uri;
2525
flat : bool;
2626
}
2727

0 commit comments

Comments
 (0)