diff options
Diffstat (limited to 'ocamldoc/odoc_analyse.ml')
-rw-r--r-- | ocamldoc/odoc_analyse.ml | 77 |
1 files changed, 39 insertions, 38 deletions
diff --git a/ocamldoc/odoc_analyse.ml b/ocamldoc/odoc_analyse.ml index 0ef95ee9b..0bdf74ce3 100644 --- a/ocamldoc/odoc_analyse.ml +++ b/ocamldoc/odoc_analyse.ml @@ -21,6 +21,7 @@ open Misc open Format open Typedtree + (** Initialize the search path. The current directory is always searched first, then the directories specified with the -I option (in command-line order), @@ -194,45 +195,49 @@ let process_error exn = let process_file ppf sourcefile = if !Odoc_args.verbose then ( - print_string (Odoc_messages.analysing sourcefile) ; + let f = match sourcefile with Odoc_args.Impl_file f | Odoc_args.Intf_file f -> f in + print_string (Odoc_messages.analysing f) ; print_newline (); ); - if Filename.check_suffix sourcefile "ml" then - ( - try - let (parsetree_typedtree_opt, input_file) = process_implementation_file ppf sourcefile in - match parsetree_typedtree_opt with - None -> + match sourcefile with + Odoc_args.Impl_file file -> + ( + try + let (parsetree_typedtree_opt, input_file) = process_implementation_file ppf file in + match parsetree_typedtree_opt with + None -> + None + | Some (parsetree, typedtree) -> + let file_module = Ast_analyser.analyse_typed_tree file + !Location.input_name parsetree typedtree + in + file_module.Odoc_module.m_top_deps <- Odoc_dep.impl_dependencies parsetree ; + + if !Odoc_args.verbose then + ( + print_string Odoc_messages.ok; + print_newline () + ); + remove_preprocessed input_file; + Some file_module + with + | Sys_error s + | Failure s -> + prerr_endline s ; + incr Odoc_global.errors ; None - | Some (parsetree, typedtree) -> - let file_module = Ast_analyser.analyse_typed_tree sourcefile !Location.input_name parsetree typedtree in - - file_module.Odoc_module.m_top_deps <- Odoc_dep.impl_dependencies parsetree ; - - if !Odoc_args.verbose then - ( - print_string Odoc_messages.ok; - print_newline () - ); - remove_preprocessed input_file; - Some file_module - with - | Sys_error s - | Failure s -> - prerr_endline s ; - incr Odoc_global.errors ; - None - | e -> - process_error e ; - incr Odoc_global.errors ; - None - ) - else - if Filename.check_suffix sourcefile "mli" then + | e -> + process_error e ; + incr Odoc_global.errors ; + None + ) + | Odoc_args.Intf_file file -> ( try - let (ast, signat, input_file) = process_interface_file ppf sourcefile in - let file_module = Sig_analyser.analyse_signature sourcefile !Location.input_name ast signat in + let (ast, signat, input_file) = process_interface_file ppf file in + let file_module = Sig_analyser.analyse_signature file + !Location.input_name ast signat + in file_module.Odoc_module.m_top_deps <- Odoc_dep.intf_dependencies ast ; @@ -254,10 +259,6 @@ let process_file ppf sourcefile = incr Odoc_global.errors ; None ) - else - ( - raise (Failure (Odoc_messages.unknown_extension sourcefile)) - ) (** Remove the class elements after the stop special comment. *) let rec remove_class_elements_after_stop eles = |