diff options
Diffstat (limited to 'ocamldoc/odoc_analyse.ml')
-rw-r--r-- | ocamldoc/odoc_analyse.ml | 71 |
1 files changed, 56 insertions, 15 deletions
diff --git a/ocamldoc/odoc_analyse.ml b/ocamldoc/odoc_analyse.ml index 07b03d643d..28cdf08a52 100644 --- a/ocamldoc/odoc_analyse.ml +++ b/ocamldoc/odoc_analyse.ml @@ -11,7 +11,8 @@ (* $Id$ *) -(** Analysis of source files. This module is strongly inspired from driver/main.ml :-) *) +(** Analysis of source files. This module is strongly inspired from + driver/main.ml :-) *) let print_DEBUG s = print_string s ; print_newline () @@ -152,7 +153,7 @@ module Sig_analyser = Odoc_sig.Analyser (Odoc_comments.Basic_info_retriever) driver/error.ml file. We do this because there are some differences between the possibly raised exceptions in the bytecode (error.ml) and opt (opterros.ml) compilers - and we don't want to take care of this. Besisdes, this + and we don't want to take care of this. Besises, these differences only concern code generation (i believe).*) let process_error exn = let report ppf = function @@ -196,7 +197,11 @@ let process_error exn = let process_file ppf sourcefile = if !Odoc_args.verbose then ( - let f = match sourcefile with Odoc_args.Impl_file f | Odoc_args.Intf_file f -> f in + let f = match sourcefile with + Odoc_args.Impl_file f + | Odoc_args.Intf_file f -> f + | Odoc_args.Text_file f -> f + in print_string (Odoc_messages.analysing f) ; print_newline (); ); @@ -204,20 +209,20 @@ let process_file ppf sourcefile = Odoc_args.Impl_file file -> ( try - let (parsetree_typedtree_opt, input_file) = process_implementation_file ppf file in - match parsetree_typedtree_opt with + let (parsetree_typedtree_opt, input_file) = process_implementation_file ppf file in + match parsetree_typedtree_opt with None -> None - | Some (parsetree, typedtree) -> + | Some (parsetree, typedtree) -> let file_module = Ast_analyser.analyse_typed_tree file - !Location.input_name parsetree typedtree - in + !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 () + print_string Odoc_messages.ok; + print_newline () ); remove_preprocessed input_file; Some file_module @@ -237,8 +242,8 @@ let process_file ppf sourcefile = try 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 + !Location.input_name ast signat + in file_module.Odoc_module.m_top_deps <- Odoc_dep.intf_dependencies ast ; @@ -260,6 +265,45 @@ let process_file ppf sourcefile = incr Odoc_global.errors ; None ) + | Odoc_args.Text_file file -> + try + let mod_name = + String.capitalize (Filename.basename (Filename.chop_extension file)) + in + let txt = + try Odoc_text.Texter.text_of_string (Odoc_misc.input_file_as_string file) + with Odoc_text.Text_syntax (l, c, s) -> + raise (Failure (Odoc_messages.text_parse_error l c s)) + in + let m = + { + Odoc_module.m_name = mod_name ; + Odoc_module.m_type = Types.Tmty_signature [] ; + Odoc_module.m_info = None ; + Odoc_module.m_is_interface = true ; + Odoc_module.m_file = file ; + Odoc_module.m_kind = Odoc_module.Module_struct + [Odoc_module.Element_module_comment txt] ; + Odoc_module.m_loc = + { Odoc_types.loc_impl = None ; + Odoc_types.loc_inter = Some (file, 0) } ; + Odoc_module.m_top_deps = [] ; + Odoc_module.m_code = None ; + Odoc_module.m_code_intf = None ; + Odoc_module.m_text_only = true ; + } + in + Some m + with + | Sys_error s + | Failure s -> + prerr_endline s; + incr Odoc_global.errors ; + None + | e -> + process_error e ; + incr Odoc_global.errors ; + None (** Remove the class elements between the stop special comments. *) let rec remove_class_elements_between_stop keep eles = @@ -480,6 +524,3 @@ let load_modules file = with Sys_error s -> raise (Failure s) - - -(* eof $Id$ *) |