File: img.ml

package info (click to toggle)
mlpost 0.8.1-8
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 1,808 kB
  • ctags: 2,934
  • sloc: ml: 17,440; makefile: 469
file content (28 lines) | stat: -rw-r--r-- 891 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
module MyGenerator (G : Odoc_html.Html_generator) = struct
  class html = object(self)
    inherit G.html

    (** Return HTML code for the given text of a bar tag. *)
    method private html_of_img t =
      match t with 
      | [] -> ""
      | (x::r) ->
          begin
          match x with
          | Odoc_info.Raw s -> Format.sprintf "<img alt=\"%s\" src=\"img/%s\"/>" s s
          | _ -> ""
          end
          
    initializer
      tag_functions <- ("img", self#html_of_img) :: tag_functions
  end
end

let _ = 
  Odoc_args.extend_html_generator
    (module MyGenerator : Odoc_gen.Html_functor);
  (* we need to deactivate the -html option of ocamldoc, otherwise our generator
   * is overwritten by the standard html generator. Ocamlbuild gives the -html
   * option to ocamldoc, so this is really required *)
  Odoc_args.add_option ("-html", Arg.Unit (fun () -> ()), "")