1
(* Our custom HTML generator *)
5
{picture file.png Caption Text}
7
so images can be easily included into ocamldoc documentation
11
{directinclude <true>|<false>}
13
changing the bahviour of "include Module". If direct include is enabled,
14
the included stuff is directly shown.
18
{fixpxpcoretypes <true>|<false>}
20
If enabled, this mode changes all clickable references
21
- of Pxp_core_types.I.<id> into Pxp_types.<id>, and
22
- of Pxp_core_types.S.<id> into Pxp_types.<id>
25
{knowntype identifier}
26
{knownclass identifier}
28
to enter additional names into the tables of type and class names
29
for which links are generated
37
module StringSet = Odoc_html.StringSet
40
let word_re = Str.regexp "[ \t\r\n]+"
45
| [Odoc_info.Raw arg] -> Str.split word_re arg
47
failwith "Argument too complicated"
51
module Generator (G : Odoc_html.Html_generator) = struct
54
inherit G.html as super
56
method private html_of_picture b t =
58
match split_args t with
60
failwith "{picture ...} needs at least one argument"
64
(file, String.concat " " args)
66
failwith "{picture ...} needs a simple word as first argument"
69
"<div class=\"picture\">\
70
<div class=\"picture-caption\">%s</div>\
76
val mutable enable_direct_include = false
78
method private html_of_direct_include b t =
79
match split_args t with
81
enable_direct_include <- true
83
enable_direct_include <- false
85
failwith "{directinclude ...} needs one bool argument"
88
method html_of_included_module b im = (* overridden! *)
89
super # html_of_included_module b im;
90
if enable_direct_include then (
91
match im.im_module with
92
| None -> () (* case module is unknown *)
94
bprintf b "<div class=\"included-module\">\n";
96
(self#html_of_module_element b (Name.father m.m_name))
97
(Module.module_elements m);
99
| Some (Modtype mt) ->
100
bprintf b "<div class=\"included-module-type\">\n";
102
(self#html_of_module_element b (Name.father mt.mt_name))
103
(Module.module_type_elements mt);
108
val mutable enable_fix_pxp_core_types = false
110
method private html_of_fix_pxp_core_types b t =
111
match split_args t with
113
enable_fix_pxp_core_types <- true
115
enable_fix_pxp_core_types <- false
117
failwith "{fixpxpcoretypes ...} needs one bool argument"
120
val pxp_core_types_re = Str.regexp "Pxp_core_types\\.[SI]\\."
122
method create_fully_qualified_idents_links m_name s =
124
if enable_fix_pxp_core_types then (
125
Str.global_replace pxp_core_types_re "Pxp_types." s
129
super # create_fully_qualified_idents_links m_name s'
131
method html_of_Ref b name ref_opt =
133
if enable_fix_pxp_core_types then (
134
(* prerr_endline ("Ref: " ^ name); *)
135
Str.global_replace pxp_core_types_re "Pxp_types." name
139
super # html_of_Ref b name' ref_opt
141
method html_of_custom_text b s t =
142
let add_known_type t =
145
known_types_names <- StringSet.add s known_types_names
149
let add_known_class t =
152
known_classes_names <- StringSet.add s known_classes_names
157
| "picture" -> self#html_of_picture b t
158
| "directinclude" -> self#html_of_direct_include b t
159
| "fixpxpcoretypes" -> self#html_of_fix_pxp_core_types b t
160
| "knowntype" -> add_known_type t
161
| "knownclass" -> add_known_class t
167
Odoc_args.extend_html_generator (module Generator : Odoc_gen.Html_functor)