diff options
author | Maxence Guesdon <maxence.guesdon@inria.fr> | 2003-02-21 13:49:35 +0000 |
---|---|---|
committer | Maxence Guesdon <maxence.guesdon@inria.fr> | 2003-02-21 13:49:35 +0000 |
commit | a12edec956c097bbe14142162b6fd36c5d40d3f5 (patch) | |
tree | 2bfca6d279c53c6a161948b348d8c9bf1c742f4a | |
parent | f665df40f1062539810c4936ddbe5ec62ee41adf (diff) | |
download | ocaml-a12edec956c097bbe14142162b6fd36c5d40d3f5.tar.gz |
ajout options pour odoc_texi, par olivier andrieu
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@5396 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
-rw-r--r-- | ocamldoc/odoc_args.ml | 6 | ||||
-rw-r--r-- | ocamldoc/odoc_args.mli | 6 | ||||
-rw-r--r-- | ocamldoc/odoc_info.mli | 6 | ||||
-rw-r--r-- | ocamldoc/odoc_messages.ml | 4 | ||||
-rw-r--r-- | ocamldoc/odoc_texi.ml | 64 |
5 files changed, 63 insertions, 23 deletions
diff --git a/ocamldoc/odoc_args.ml b/ocamldoc/odoc_args.ml index 2e86402301..9d761e2cdf 100644 --- a/ocamldoc/odoc_args.ml +++ b/ocamldoc/odoc_args.ml @@ -134,6 +134,10 @@ let with_index = ref true let esc_8bits = ref false +let info_section = ref "Objective Caml" + +let info_entry = ref [] + let files = ref [] let f_latex_title s = @@ -252,6 +256,8 @@ let options = ref [ (* tex only options *) "-noindex", Arg.Clear with_index, M.no_index ; "-esc8", Arg.Set esc_8bits, M.esc_8bits ; + "-info-section", Arg.String ((:=) info_section), M.info_section ; + "-info-entry", Arg.String (fun s -> info_entry := !info_entry @ [ s ]), M.info_entry ; (* dot only options *) "-dot-colors", Arg.String (fun s -> dot_colors := Str.split (Str.regexp_string ",") s), M.dot_colors ; diff --git a/ocamldoc/odoc_args.mli b/ocamldoc/odoc_args.mli index 13945f9987..e2837819e6 100644 --- a/ocamldoc/odoc_args.mli +++ b/ocamldoc/odoc_args.mli @@ -132,6 +132,12 @@ val with_index : bool ref (** The flag which indicates if we must escape accentuated characters (for TeXinfo).*) val esc_8bits : bool ref +(** The Info directory section *) +val info_section : string ref + +(** The Info directory entries to insert *) +val info_entry : string list ref + (** Include all modules or only the ones on the command line, for the dot ouput. *) val dot_include_all : bool ref diff --git a/ocamldoc/odoc_info.mli b/ocamldoc/odoc_info.mli index cb77ed8809..85203f9711 100644 --- a/ocamldoc/odoc_info.mli +++ b/ocamldoc/odoc_info.mli @@ -939,6 +939,12 @@ module Args : (** The flag which indicates if we must escape accentuated characters (for TeXinfo).*) val esc_8bits : bool ref + (** The Info directory section *) + val info_section : string ref + + (** The Info directory entries to insert *) + val info_entry : string list ref + (** Include all modules or only the ones on the command line, for the dot ouput. *) val dot_include_all : bool ref diff --git a/ocamldoc/odoc_messages.ml b/ocamldoc/odoc_messages.ml index 45ba7da343..2fcebc3b3b 100644 --- a/ocamldoc/odoc_messages.ml +++ b/ocamldoc/odoc_messages.ml @@ -130,7 +130,9 @@ let merge_custom = ('c', "merge custom @-tags") let merge_all = ('A', "merge all") let no_index = " Do not build index for Info files "^texi_only -let esc_8bits = " Escape accentuated characters in Info files "^texi_only^"\n" +let esc_8bits = " Escape accentuated characters in Info files "^texi_only +let info_section = "Specify section of Info directory "^texi_only +let info_entry = "Specify Info directory entry "^texi_only^"\n" let options_can_be = " <options> can be one or more of the following characters:" let string_of_options_list l = diff --git a/ocamldoc/odoc_texi.ml b/ocamldoc/odoc_texi.ml index 8bcaf356bd..de3bd7f4d5 100644 --- a/ocamldoc/odoc_texi.ml +++ b/ocamldoc/odoc_texi.ml @@ -20,11 +20,6 @@ open Exception open Class open Module -(** {2 Command-line options} *) - -let with_index = Args.with_index -let esc_8bits = Args.esc_8bits - (** {2 Some small helper functions} *) let puts_nl chan s = @@ -145,7 +140,7 @@ struct (Str.regexp "}", "@}") ; (Str.regexp "\\.\\.\\.", "@dots{}") ; ] @ - (if !esc_8bits + (if !Args.esc_8bits then [ (Str.regexp "à", "@`a") ; (Str.regexp "â", "@^a") ; @@ -222,6 +217,15 @@ struct let ifinfo s = String.concat "\n" [ "@ifinfo" ; s ; "@end ifinfo" ; "" ] + + (** [install-info] informations *) + let dirsection sec = + "@dircategory " ^ (escape sec) + + let direntry ent = + [ "@direntry" ] @ + (List.map escape ent) @ + [ "@end direntry" ] end @@ -392,7 +396,7 @@ class texi = method index (ind : indices) ent = Verbatim - (if !with_index + (if !Args.with_index then (assert(List.mem ind indices_to_build) ; String.concat "" [ "@" ; indices ind ; "index " ; @@ -998,13 +1002,20 @@ class texi = (** Writes the header of the TeX document. *) - method generate_texi_header chan m_list = - let title, filename = - match !Args.title with - | None -> ("", "doc.info") - | Some s -> - let s' = self#escape s in - (s', s' ^ ".info") + method generate_texi_header chan texi_filename m_list = + let title = match !Args.title with + | None -> "" + | Some s -> self#escape s in + let filename = + if texi_filename <> "ocamldoc.texi" + then + (if Filename.check_suffix texi_filename ".texi" + then Filename.chop_suffix texi_filename ".texi" + else texi_filename) ^ ".info" + else + if title <> "" + then title ^ ".info" + else "doc.info" in (* write a standard Texinfo header *) List.iter @@ -1016,13 +1027,22 @@ class texi = "@settitle " ^ title ; "@c %**end of header" ; ] ; - (if !with_index then + (if !Args.with_index then List.map - (fun (_, shortname) -> - "@defcodeindex " ^ shortname) - indices_names + (fun ind -> + "@defcodeindex " ^ (indices ind)) + indices_to_build else []) ; + [ Texi.dirsection !Args.info_section ] ; + + Texi.direntry + (if !Args.info_entry <> [] + then !Args.info_entry + else [ Printf.sprintf "* %s: (%s)." + title + (Filename.chop_suffix filename ".info") ]) ; + [ "@ifinfo" ; "This file was generated by Ocamldoc using the Texinfo generator." ; "@end ifinfo" ; @@ -1043,7 +1063,7 @@ class texi = (* write a top menu *) Texi.generate_menu chan ((List.map (fun m -> `Module m) m_list) @ - (if !with_index then + (if !Args.with_index then let indices_names_to_build = List.map indices indices_to_build in List.rev (List.fold_left @@ -1060,7 +1080,7 @@ class texi = (** Writes the header of the TeX document. *) method generate_texi_trailer chan = nl chan ; - if !with_index + if !Args.with_index then let indices_names_to_build = List.map indices indices_to_build in List.iter (puts_nl chan) @@ -1127,14 +1147,14 @@ class texi = if !Args.out_file = Odoc_messages.default_out_file then "ocamldoc.texi" else !Args.out_file in - if !with_index + if !Args.with_index then List.iter self#scan_for_index (List.map (fun m -> `Module m) module_list) ; try let chanout = open_out (Filename.concat !Args.target_dir filename) in if !Args.with_header - then self#generate_texi_header chanout module_list ; + then self#generate_texi_header chanout filename module_list ; List.iter (self#generate_for_module chanout) module_list ; |