Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 1f404558b0
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 146 lines (131 sloc) 4.27 kb
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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145
(***********************************************************************)
(* OCamldoc *)
(* *)
(* Maxence Guesdon, projet Cristal, INRIA Rocquencourt *)
(* *)
(* Copyright 2001 Institut National de Recherche en Informatique et *)
(* en Automatique. All rights reserved. This file is distributed *)
(* under the terms of the Q Public License version 1.0. *)
(* *)
(***********************************************************************)

(* $Id: odoc.ml 9547 2010-01-22 12:48:24Z doligez $ *)

(** Main module for bytecode. *)

open Config
open Clflags
open Misc
open Format

let print_DEBUG s = print_string s ; print_newline ()

(* we check if we must load a module given on the command line *)
let arg_list = Array.to_list Sys.argv
let (cm_opt, paths) =
  let rec iter (f_opt, inc) = function
      [] | _ :: [] -> (f_opt, inc)
    | "-g" :: file :: q when
        ((Filename.check_suffix file "cmo") or
         (Filename.check_suffix file "cma") or
           (Filename.check_suffix file "cmxs")) &
        (f_opt = None) ->
      iter (Some file, inc) q
  | "-i" :: dir :: q ->
      iter (f_opt, inc @ [dir]) q
  | _ :: q ->
        iter (f_opt, inc) q
  in
  iter (None, []) arg_list

let _ = print_DEBUG "Fin analyse des arguments pour le dynamic load"

(** Return the real name of the file to load,
searching it in the paths if it is
a simple name and not in the current directory. *)
let get_real_filename name =
   if Filename.basename name <> name then
     name
   else
     (
      let paths = Filename.current_dir_name :: paths @ [Odoc_config.custom_generators_path] in
      try
        let d = List.find
            (fun d -> Sys.file_exists (Filename.concat d name))
            paths
        in
        Filename.concat d name
      with
        Not_found ->
          failwith (Odoc_messages.file_not_found_in_paths paths name)
     )
(*
let _ =
match cm_opt with
None ->
()
| Some file ->
let file = Dynlink.adapt_filename file in
Dynlink.allow_unsafe_modules true;
try
let real_file = get_real_filename file in
ignore(Dynlink.loadfile real_file)
with
Dynlink.Error e ->
prerr_endline (Odoc_messages.load_file_error file (Dynlink.error_message e)) ;
exit 1
| Not_found ->
prerr_endline (Odoc_messages.load_file_error file "Not_found");
exit 1
| Sys_error s
| Failure s ->
prerr_endline (Odoc_messages.load_file_error file s);
exit 1
*)
let _ = print_DEBUG "Fin du chargement dynamique eventuel"

let default_html_generator = Odoc_html.generate
let default_latex_generator _ = assert false
let default_texi_generator _ = assert false
let default_man_generator _ = assert false
let default_dot_generator _ = assert false
let _ = Odoc_args.parse
    (default_html_generator)
    (default_latex_generator)
    (default_texi_generator)
    (default_man_generator)
    (default_dot_generator)


let loaded_modules =
  List.flatten
    (List.map
       (fun f ->
         Odoc_info.verbose (Odoc_messages.loading f);
         try
           let l = Odoc_analyse.load_modules f in
           Odoc_info.verbose Odoc_messages.ok;
           l
         with Failure s ->
           prerr_endline s ;
           incr Odoc_global.errors ;
           []
       )
       !Odoc_args.load
    )

let modules = Odoc_analyse.analyse_files loaded_modules !Odoc_args.files

let _ =
  match !Odoc_args.dump with
    None -> ()
  | Some f ->
      try Odoc_analyse.dump_modules f modules
      with Failure s ->
        prerr_endline s ;
        incr Odoc_global.errors

let _ =
  match !Odoc_args.doc_generator with
    None ->
      ()
  | Some gen ->
      Odoc_info.verbose Odoc_messages.generating_doc;
      gen modules;
      Odoc_info.verbose Odoc_messages.ok

let _ =
  if !Odoc_global.errors > 0 then
  (
   prerr_endline (Odoc_messages.errors_occured !Odoc_global.errors) ;
   exit 1
  )
  else
    exit 0;
  ()
Something went wrong with that request. Please try again.