summaryrefslogtreecommitdiff
path: root/ocamldoc/odoc_man.ml
diff options
context:
space:
mode:
authorMaxence Guesdon <maxence.guesdon@inria.fr>2010-08-24 09:45:45 +0000
committerMaxence Guesdon <maxence.guesdon@inria.fr>2010-08-24 09:45:45 +0000
commit0936bb2811303dba3510d476253a3653903e9f58 (patch)
tree1c17a8df5ef96f4b786ade6cb0243ffbe25783fa /ocamldoc/odoc_man.ml
parent575555eecd11fcc745e0f1e88d090764b3291b63 (diff)
downloadocaml-0936bb2811303dba3510d476253a3653903e9f58.tar.gz
use first-class modules to allow composition of custom generators
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@10652 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'ocamldoc/odoc_man.ml')
-rw-r--r--ocamldoc/odoc_man.ml37
1 files changed, 24 insertions, 13 deletions
diff --git a/ocamldoc/odoc_man.ml b/ocamldoc/odoc_man.ml
index eb6ec4d7d0..612bc11a02 100644
--- a/ocamldoc/odoc_man.ml
+++ b/ocamldoc/odoc_man.ml
@@ -21,6 +21,11 @@ open Class
open Module
open Search
+let man_suffix = ref Odoc_messages.default_man_suffix
+let man_section = ref Odoc_messages.default_man_section
+
+let man_mini = ref false
+
let new_buf () = Buffer.create 1024
let bp = Printf.bprintf
let bs = Buffer.add_string
@@ -202,6 +207,9 @@ class virtual info =
self#man_of_custom b info.M.i_custom
end
+module Generator =
+struct
+
(** This class is used to create objects which can generate a simple html documentation. *)
class man =
let re_slash = Str.regexp_string "/" in
@@ -210,7 +218,7 @@ class man =
(** Get a file name from a complete name. *)
method file_name name =
- let s = Printf.sprintf "%s.%s" name !Args.man_suffix in
+ let s = Printf.sprintf "%s.%s" name !man_suffix in
Str.global_replace re_slash "slash" s
(** Escape special sequences of characters in a string. *)
@@ -229,7 +237,7 @@ class man =
(** Open a file for output. Add the target directory.*)
method open_out file =
- let f = Filename.concat !Args.target_dir file in
+ let f = Filename.concat !Global.target_dir file in
open_out f
(** Print groff string for a text, without correction of blanks. *)
@@ -693,10 +701,10 @@ class man =
let chanout = self#open_out file in
let b = new_buf () in
bs b (".TH \""^cl.cl_name^"\" ");
- bs b !Odoc_args.man_section ;
+ bs b !man_section ;
bs b (" "^(Odoc_misc.string_of_date ~hour: false date)^" ");
bs b "OCamldoc ";
- bs b ("\""^(match !Args.title with Some t -> t | None -> "")^"\"\n");
+ bs b ("\""^(match !Global.title with Some t -> t | None -> "")^"\"\n");
let abstract =
match cl.cl_info with
@@ -752,10 +760,10 @@ class man =
let chanout = self#open_out file in
let b = new_buf () in
bs b (".TH \""^ct.clt_name^"\" ");
- bs b !Odoc_args.man_section ;
+ bs b !man_section ;
bs b (" "^(Odoc_misc.string_of_date ~hour: false date)^" ");
bs b "OCamldoc ";
- bs b ("\""^(match !Args.title with Some t -> t | None -> "")^"\"\n");
+ bs b ("\""^(match !Global.title with Some t -> t | None -> "")^"\"\n");
let abstract =
match ct.clt_info with
@@ -809,10 +817,10 @@ class man =
let chanout = self#open_out file in
let b = new_buf () in
bs b (".TH \""^mt.mt_name^"\" ");
- bs b !Odoc_args.man_section ;
+ bs b !man_section ;
bs b (" "^(Odoc_misc.string_of_date ~hour: false date)^" ");
bs b "OCamldoc ";
- bs b ("\""^(match !Args.title with Some t -> t | None -> "")^"\"\n");
+ bs b ("\""^(match !Global.title with Some t -> t | None -> "")^"\"\n");
let abstract =
match mt.mt_info with
@@ -887,10 +895,10 @@ class man =
let chanout = self#open_out file in
let b = new_buf () in
bs b (".TH \""^m.m_name^"\" ");
- bs b !Odoc_args.man_section ;
+ bs b !man_section ;
bs b (" "^(Odoc_misc.string_of_date ~hour: false date)^" ");
bs b "OCamldoc ";
- bs b ("\""^(match !Args.title with Some t -> t | None -> "")^"\"\n");
+ bs b ("\""^(match !Global.title with Some t -> t | None -> "")^"\"\n");
let abstract =
match m.m_info with
@@ -1014,10 +1022,10 @@ class man =
let chanout = self#open_out file in
let b = new_buf () in
bs b (".TH \""^name^"\" ");
- bs b !Odoc_args.man_section ;
+ bs b !man_section ;
bs b (" "^(Odoc_misc.string_of_date ~hour: false date)^" ");
bs b "OCamldoc ";
- bs b ("\""^(match !Args.title with Some t -> t | None -> "")^"\"\n");
+ bs b ("\""^(match !Global.title with Some t -> t | None -> "")^"\"\n");
bs b ".SH NAME\n";
bs b (name^" \\- all "^name^" elements\n\n");
@@ -1069,10 +1077,13 @@ class man =
| [Res_class cl] -> self#generate_for_class cl
| [Res_class_type ct] -> self#generate_for_class_type ct
| l ->
- if !Args.man_mini then
+ if !man_mini then
()
else
self#generate_for_group l
in
List.iter f groups
end
+end
+
+module type Man_generator = module type of Generator