source: Deliverables/D2.2/8051/admin/myocamldoc @ 486

Last change on this file since 486 was 486, checked in by ayache, 9 years ago

Deliverable D2.2

  • Property svn:executable set to *
File size: 1.3 KB
RevLine 
[486]1#!/usr/bin/env ocaml
2
3(* This script is a wrapper for ocamldoc.
4
5   This is a simple workaround for the defaults ocamldoc rules of
6   ocamlbuild. *)
7
8(* We assume that the command line arguments are given in the
9   following order:
10
11   ocamldoc [options] FILE.(ml|mli)
12
13   where FILE is either an implementation or an interface.
14
15   This script rewrites this command line into something of
16   the shape:
17
18   ocamldoc [options] -intf FILE.mli -impl FILE.ml
19
20   provided that FILE.mli and FILE.ml exist (otherwise, one of these
21   two options is dropped out).
22
23*)
24
25open List
26
27let nb         = Array.length Sys.argv
28let args       = List.tl (Array.to_list Sys.argv)
29let file       = Filename.chop_extension (Sys.argv.(nb - 1))     
30let file_is    = Filename.check_suffix Sys.argv.(nb - 1)
31let impl       = file ^ ".ml"   
32let opt what f = if Sys.file_exists f then what ^ " " ^ f else ""
33
34let cmd =                                 
35  match args with
36    | [] -> "ocamlfind ocamldoc"
37    | _ -> 
38      if file_is ".ml" || file_is ".mli" then
39        let options = rev (tl (rev args)) in
40        Printf.sprintf "ocamlfind ocamldoc %s %s %s"
41          (opt "-impl" (file ^ ".ml"))
42          (opt "-intf" (file ^ ".mli"))
43          (String.concat " " options)
44      else 
45        Printf.sprintf "ocamlfind ocamldoc %s" 
46          (String.concat " " args)
47
48let _ = 
49  exit (Sys.command cmd)
50
Note: See TracBrowser for help on using the repository browser.