text
stringlengths
12
786k
let no_docstring f x = Lexer . handle_docstrings := false ; let result = f x in Lexer . handle_docstrings := true ; result
let process_implementation_file sourcefile = init_path ( ) ; let prefixname = Filename . chop_extension sourcefile in let modulename = String . capitalize_ascii ( Filename . basename prefixname ) in Env . set_unit_name modulename ; let inputfile = preprocess sourcefile in let env = initial_env ...
let process_interface_file sourcefile = init_path ( ) ; let prefixname = Filename . chop_extension sourcefile in let modulename = String . capitalize_ascii ( Filename . basename prefixname ) in Env . set_unit_name modulename ; let inputfile = preprocess sourcefile in let ast = Pparse . file ...
module Ast_analyser = Odoc_ast . Analyser ( Odoc_comments . Basic_info_retriever )
module Sig_analyser = Odoc_sig . Analyser ( Odoc_comments . Basic_info_retriever )
let process_error exn = try Location . report_exception Format . err_formatter exn with exn -> fprintf Format . err_formatter " Compilation error ( % s ) . Use the OCaml compiler to get more details . . " @ ( Printexc . to_string exn )
let process_file sourcefile = if ! Odoc_global . verbose then ( let f = match sourcefile with Odoc_global . Impl_file f | Odoc_global . Intf_file f -> f | Odoc_global . Text_file f -> f in print_string ( Odoc_messages . analysing f ) ; print_newline ( ) ; ) ; match sourcefile with Odo...
let rec remove_class_elements_between_stop keep eles = match eles with [ ] -> [ ] | ele :: q -> match ele with Odoc_class . Class_comment [ Odoc_types . Raw " " /* ] -> remove_class_elements_between_stop ( not keep ) q | Odoc_class . Class_attribute _ | Odoc_class . Class_method _ ...
let rec remove_class_elements_between_stop_in_class_kind k = match k with Odoc_class . Class_structure ( inher , l ) -> Odoc_class . Class_structure ( inher , remove_class_elements_between_stop true l ) | Odoc_class . Class_apply _ -> k | Odoc_class . Class_constr _ -> k | Odoc_class . Cl...
let rec remove_module_elements_between_stop keep eles = let f = remove_module_elements_between_stop in match eles with [ ] -> [ ] | ele :: q -> match ele with Odoc_module . Element_module_comment [ Odoc_types . Raw " " /* ] -> f ( not keep ) q | Odoc_module . Element_module_comment _ ...
let remove_elements_between_stop module_list = List . map ( fun m -> m . Odoc_module . m_kind <- remove_module_elements_between_stop_in_module_kind m . Odoc_module . m_kind ; m ) module_list
let analyse_files ( ? init [ ] ) = files = let modules_pre = init @ ( List . fold_left ( fun acc -> fun file -> try match process_file file with None -> acc | Some m -> acc @ [ m ] with Failure s -> prerr_endline s ; incr Odoc_global . errors ; acc ) [ ] files ) in let module...
let dump_modules file ( modules : Odoc_module . t_module list ) = try let chanout = open_out_bin file in let dump = Odoc_types . make_dump modules in output_value chanout dump ; close_out chanout with Sys_error s -> raise ( Failure s )
let load_modules file = try let chanin = open_in_bin file in let dump = input_value chanin in close_in chanin ; let ( l : Odoc_module . t_module list ) = Odoc_types . open_dump dump in l with Sys_error s -> raise ( Failure s )
let current_generator = ref ( None : Odoc_gen . generator option )
let get_html_generator ( ) = match ! current_generator with None -> ( module Odoc_html . Generator : Odoc_html . Html_generator ) | Some ( Odoc_gen . Html m ) -> m | Some _ -> failwith ( M . current_generator_is_not " html " ) ; ;
let get_latex_generator ( ) = match ! current_generator with None -> ( module Odoc_latex . Generator : Odoc_latex . Latex_generator ) | Some ( Odoc_gen . Latex m ) -> m | Some _ -> failwith ( M . current_generator_is_not " latex " ) ; ;
let get_texi_generator ( ) = match ! current_generator with None -> ( module Odoc_texi . Generator : Odoc_texi . Texi_generator ) | Some ( Odoc_gen . Texi m ) -> m | Some _ -> failwith ( M . current_generator_is_not " texi " ) ; ;
let get_man_generator ( ) = match ! current_generator with None -> ( module Odoc_man . Generator : Odoc_man . Man_generator ) | Some ( Odoc_gen . Man m ) -> m | Some _ -> failwith ( M . current_generator_is_not " man " ) ; ;
let get_dot_generator ( ) = match ! current_generator with None -> ( module Odoc_dot . Generator : Odoc_dot . Dot_generator ) | Some ( Odoc_gen . Dot m ) -> m | Some _ -> failwith ( M . current_generator_is_not " dot " ) ; ;
let get_base_generator ( ) = match ! current_generator with None -> ( module Odoc_gen . Base_generator : Odoc_gen . Base ) | Some ( Odoc_gen . Base m ) -> m | Some _ -> failwith ( M . current_generator_is_not " base " ) ; ;
let extend_html_generator f = let current = get_html_generator ( ) in let module Current = ( val current : Odoc_html . Html_generator ) in let module F = ( val f : Odoc_gen . Html_functor ) in let module M = F ( Current ) in current_generator := Some ( Odoc_gen . Html ( module M : Odo...
let extend_latex_generator f = let current = get_latex_generator ( ) in let module Current = ( val current : Odoc_latex . Latex_generator ) in let module F = ( val f : Odoc_gen . Latex_functor ) in let module M = F ( Current ) in current_generator := Some ( Odoc_gen . Latex ( module M ...
let extend_texi_generator f = let current = get_texi_generator ( ) in let module Current = ( val current : Odoc_texi . Texi_generator ) in let module F = ( val f : Odoc_gen . Texi_functor ) in let module M = F ( Current ) in current_generator := Some ( Odoc_gen . Texi ( module M : Odo...
let extend_man_generator f = let current = get_man_generator ( ) in let module Current = ( val current : Odoc_man . Man_generator ) in let module F = ( val f : Odoc_gen . Man_functor ) in let module M = F ( Current ) in current_generator := Some ( Odoc_gen . Man ( module M : Odoc_man ...
let extend_dot_generator f = let current = get_dot_generator ( ) in let module Current = ( val current : Odoc_dot . Dot_generator ) in let module F = ( val f : Odoc_gen . Dot_functor ) in let module M = F ( Current ) in current_generator := Some ( Odoc_gen . Dot ( module M : Odoc_dot ...
let extend_base_generator f = let current = get_base_generator ( ) in let module Current = ( val current : Odoc_gen . Base ) in let module F = ( val f : Odoc_gen . Base_functor ) in let module M = F ( Current ) in current_generator := Some ( Odoc_gen . Base ( module M : Odoc_gen . B...
let analyse_option_string l s = List . fold_left ( fun acc -> fun ( ( c , _ ) , v ) -> if String . contains s c then acc @ v else acc ) [ ] l
let analyse_merge_options s = let l = [ ( M . merge_description , [ Odoc_types . Merge_description ] ) ; ( M . merge_author , [ Odoc_types . Merge_author ] ) ; ( M . merge_version , [ Odoc_types . Merge_version ] ) ; ( M . merge_see , [ Odoc_types . Merge_se...
let f_latex_title s = match String . split_on_char ' , ' s with | [ n ; command ] -> let n = int_of_string n in Odoc_latex . latex_titles := List . remove_assoc n ! Odoc_latex . latex_titles ; Odoc_latex . latex_titles := ( n , command ) :: ! Odoc_latex . latex_titles | _ -> ...
let f_texinfo_title s = match String . split_on_char ' , ' s with | [ n ; title ; heading ] -> let n = int_of_string n in Odoc_texi . titles_and_headings := ( n , ( title , heading ) ) :: List . remove_assoc n ! Odoc_texi . titles_and_headings ; | _ -> incr Odoc_global . ...
let add_hidden_modules s = let l = Str . split ( Str . regexp " , " ) s in List . iter ( fun n -> let name = Str . global_replace ( Str . regexp " [ \ n \ r \ t ] " ) + " " n in match name with " " -> ( ) | _ -> match name . [ 0 ] with ' A ' . . '...
let set_generator ( g : Odoc_gen . generator ) = current_generator := Some g
let anonymous f = let sf = if Filename . check_suffix f " ml " then Odoc_global . Impl_file f else if Filename . check_suffix f ! Config . interface_suffix then Odoc_global . Intf_file f else if Filename . check_suffix f " txt " then Odoc_global . Text_file f else failwith ( Odoc_messages . ...
module Options = Main_args . Make_ocamldoc_options ( struct include Main_args . Default . Odoc_args let _I s = Odoc_global . include_dirs := s :: ! Odoc_global . include_dirs let _impl s = Odoc_global . files := ! Odoc_global . files @ [ Odoc_global . Impl_file s ] let _intf s = Odoc_...
let default_options = Options . list @ [ " - initially - opened - module " , Arg . Set_string Odoc_global . initially_opened_module , M . initially_opened_module ; " - lib " , Arg . Set_string Odoc_global . library_namespace , M . library_namespace ; " - text " , Arg . ...
let options = ref default_options
let modified_options ( ) = ! options != default_options
let append_last_doc suffix = match List . rev ! options with | ( key , spec , doc ) :: tl -> options := List . rev ( ( key , spec , doc ^ suffix ) :: tl ) | [ ] -> ( )
let help_options = ref [ ]
let help_action ( ) = let msg = Arg . usage_string ( ! options @ ! help_options ) ( M . usage ^ M . options_are ) in print_string msg
let ( ) = help_options := [ " - help " , Arg . Unit help_action , M . help ; " -- help " , Arg . Unit help_action , M . help ]
let add_option o = if not ( modified_options ( ) ) then append_last_doc " \ n *** custom generator options ***\ n " ; let ( s , _ , _ ) = o in let rec iter = function [ ] -> [ o ] | ( s2 , f , m ) :: q -> if s = s2 then o :: q else ( s2 , f , m ) :: ( iter ...
let parse ( ) = if modified_options ( ) then append_last_doc " \ n " ; let options = ! options @ ! help_options in begin try Arg . parse ( Arg . align ~ limit : 13 options ) anonymous ( M . usage ^ M . options_are ) with Compenv . Exit_with_status n -> exit n end ; Odoc_glob...
type typedtree = ( Typedtree . structure * Typedtree . module_coercion )
module Typedtree_search = struct type ele = | M of string | MT of string | T of string | C of string | CT of string | X of string | E of string | P of string type tab = ( ele , Typedtree . structure_item_desc ) Hashtbl . t type tab_values = ( Odoc_module . Name . t , Typedtree . pattern ...
module Analyser = functor ( My_ir : Odoc_sig . Info_retriever ) -> struct module Sig = Odoc_sig . Analyser ( My_ir ) let file = Sig . file let file_name = Sig . file_name let get_string_of_file = Sig . get_string_of_file let prepare_file = Sig . prepare_file let get_comments_in_class = Sig ...
type class_element = Class_attribute of Odoc_value . t_attribute | Class_method of Odoc_value . t_method | Class_comment of Odoc_types . text
type cct = Cl of t_class | Cltype of t_class_type * Types . type_expr list ic_name : Name . t ; mutable ic_class : cct option ; ic_text : Odoc_types . text option ; } capp_name : Name . t ; mutable capp_class : t_class option ; capp_params : Types . type_expr list ; capp_params_code : ...
let class_parameter_text_by_name cl label = match cl . cl_info with None -> None | Some i -> try let t = List . assoc label i . Odoc_types . i_params in Some t with Not_found -> None
let rec class_elements ( ? trans = true ) cl = let rec iter_kind k = match k with Class_structure ( _ , elements ) -> elements | Class_constraint ( c_kind , _ct_kind ) -> iter_kind c_kind | Class_apply capp -> ( match capp . capp_class with Some c when trans -> class_elements ~ trans :...
let class_attributes ( ? trans = true ) cl = List . fold_left ( fun acc -> fun ele -> match ele with Class_attribute a -> acc @ [ a ] | _ -> acc ) [ ] ( class_elements ~ trans cl )
let class_methods ( ? trans = true ) cl = List . fold_left ( fun acc -> fun ele -> match ele with Class_method m -> acc @ [ m ] | _ -> acc ) [ ] ( class_elements ~ trans cl )
let class_comments ( ? trans = true ) cl = List . fold_left ( fun acc -> fun ele -> match ele with Class_comment t -> acc @ [ t ] | _ -> acc ) [ ] ( class_elements ~ trans cl )
let class_update_parameters_text cl = let f p = Odoc_parameter . update_parameter_text ( class_parameter_text_by_name cl ) p in List . iter f cl . cl_parameters
let class_type_attributes ( ? trans = true ) clt = List . fold_left ( fun acc -> fun ele -> match ele with Class_attribute a -> acc @ [ a ] | _ -> acc ) [ ] ( class_type_elements ~ trans clt )
let class_type_methods ( ? trans = true ) clt = List . fold_left ( fun acc -> fun ele -> match ele with Class_method m -> acc @ [ m ] | _ -> acc ) [ ] ( class_type_elements ~ trans clt )
let class_type_comments ( ? trans = true ) clt = List . fold_left ( fun acc -> fun ele -> match ele with Class_comment m -> acc @ [ m ] | _ -> acc ) [ ] ( class_type_elements ~ trans clt )
let class_type_parameter_text_by_name clt label = match clt . clt_info with None -> None | Some i -> try let t = List . assoc label i . Odoc_types . i_params in Some t with Not_found -> None
let simple_blank = " [ \ 013 \ 009 \ 012 ] "
module type Texter = sig val text_of_string : string -> text end
module Info_retriever = functor ( MyTexter : Texter ) -> struct let create_see _file s = try let lexbuf = Lexing . from_string s in let ( see_ref , s ) = Odoc_parser . see_info Odoc_see_lexer . main lexbuf in ( see_ref , MyTexter . text_of_string s ) with | Odoc_text . Text_syntax ( ...
module Basic_info_retriever = Info_retriever ( Odoc_text . Texter )
let info_of_string s = let dummy = { i_desc = None ; i_authors = [ ] ; i_version = None ; i_sees = [ ] ; i_since = None ; i_before = [ ] ; i_deprecated = None ; i_params = [ ] ; i_raised_exceptions = [ ] ; i_return_value = None ; i_custom = [ ] ; } in let s...
let info_of_comment_file modlist f = try let s = Odoc_misc . input_file_as_string f in let i = info_of_string s in Odoc_cross . assoc_comments_info " " modlist i with Sys_error s -> failwith s
let nb_chars = ref 0
let authors = ref ( [ ] : string list )
let version = ref ( None : string option )
let sees = ref ( [ ] : string list )
let since = ref ( None : string option )
let before = ref [ ]
let deprecated = ref ( None : string option )
let params = ref ( [ ] : ( string * string ) list )
let raised_exceptions = ref ( [ ] : ( string * string ) list )
let return_value = ref ( None : string option )
let customs = ref [ ]
let init ( ) = nb_chars := 0 ; authors := [ ] ; version := None ; sees := [ ] ; since := None ; before := [ ] ; deprecated := None ; params := [ ] ; raised_exceptions := [ ] ; return_value := None ; customs := [ ]
module S = Set . Make ( struct type t = string * ref_kind option let compare = Stdlib . compare end )
let verified_refs = ref S . empty
let add_verified v = verified_refs := S . add v ! verified_refs
let was_verified v = S . mem v ! verified_refs
module P_alias = struct type t = int let p_module m _ = ( true , match m . m_kind with Module_alias _ -> true | _ -> false ) let p_module_type mt _ = ( true , match mt . mt_kind with Some ( Module_type_alias _ ) -> true | _ -> false ) let p_class _ _ = ( false , false ) let ...
module Search_alias = Odoc_search . Search ( P_alias )
type alias_state = | Alias_to_resolve
let ( module_aliases : ( Name . t , Name . t * alias_state ) Hashtbl . t ) = Hashtbl . create 13 ; ;
let module_and_modtype_aliases = Hashtbl . create 13 ; ;
let extension_aliases = Hashtbl . create 13 ; ;
let exception_aliases = Hashtbl . create 13 ; ;
let rec build_alias_list = function [ ] -> ( ) | ( Odoc_search . Res_module m ) :: q -> ( match m . m_kind with Module_alias ma -> Hashtbl . add module_aliases m . m_name ( ma . ma_name , Alias_to_resolve ) ; Hashtbl . add module_and_modtype_aliases m . m_name ( ma . ma_nam...
let get_alias_names module_list = Hashtbl . clear module_aliases ; Hashtbl . clear module_and_modtype_aliases ; Hashtbl . clear extension_aliases ; Hashtbl . clear exception_aliases ; build_alias_list ( Search_alias . search module_list 0 )
let known_elements = ref Ele_map . empty
let add_known_element name k = try let l = Ele_map . find name ! known_elements in let s = Ele_map . remove name ! known_elements in known_elements := Ele_map . add name ( k :: l ) s with Not_found -> known_elements := Ele_map . add name [ k ] ! known_elements
let get_known_elements name = try Ele_map . find name ! known_elements with Not_found -> [ ]
let kind_name_exists kind = let pred = match kind with RK_module -> ( fun e -> match e with Odoc_search . Res_module _ -> true | _ -> false ) | RK_module_type -> ( fun e -> match e with Odoc_search . Res_module_type _ -> true | _ -> false ) | RK_class -> ( fun e -> match e with Odoc_se...
let module_exists = kind_name_exists RK_module
let module_type_exists = kind_name_exists RK_module_type
let class_exists = kind_name_exists RK_class
let class_type_exists = kind_name_exists RK_class_type
let value_exists = kind_name_exists RK_value
let type_exists = kind_name_exists RK_type