this repo has no description
1(* Page shell interface and registry. *)
2
3module Html = Tyxml.Html
4
5type page_data = {
6 url : Odoc_document.Url.Path.t;
7 header : Html_types.flow5_without_header_footer Html.elt list;
8 preamble : Html_types.flow5_without_header_footer Html.elt list;
9 content : Html_types.div_content Html.elt list;
10 breadcrumbs : Types.breadcrumbs;
11 toc : Types.toc list;
12 sidebar : Html_types.div_content Html.elt list option;
13 sidebar_data : Odoc_document.Sidebar.t option;
14 uses_katex : bool;
15 source_anchor : string option;
16 resources : Odoc_extension_registry.resource list;
17 assets : Odoc_extension_registry.asset list;
18 children : Odoc_document.Renderer.page list;
19}
20
21type src_page_data = {
22 url : Odoc_document.Url.Path.t;
23 header : Html_types.flow5_without_header_footer Html.elt list;
24 breadcrumbs : Types.breadcrumbs;
25 sidebar : Html_types.div_content Html.elt list option;
26 sidebar_data : Odoc_document.Sidebar.t option;
27 title : string;
28 content : Html_types.div_content Html.elt list;
29}
30
31module type S = sig
32 val name : string
33 val make : config:Config.t -> page_data -> Odoc_document.Renderer.page
34 val make_src : config:Config.t -> src_page_data -> Odoc_document.Renderer.page
35end
36
37(* Registry *)
38
39let shells : (string, (module S)) Hashtbl.t = Hashtbl.create 4
40
41let register (module Shell : S) =
42 Hashtbl.replace shells Shell.name (module Shell : S)
43
44let find name = Hashtbl.find_opt shells name
45
46let list_shells () =
47 Hashtbl.fold (fun name _ acc -> name :: acc) shells []
48 |> List.sort String.compare
49
50let default () =
51 match Hashtbl.find_opt shells "default" with
52 | Some shell -> shell
53 | None -> failwith "No default shell registered"