2002-03-27 08:20:32 -08:00
|
|
|
(***********************************************************************)
|
2012-08-01 05:09:31 -07:00
|
|
|
(* *)
|
2002-03-27 08:20:32 -08:00
|
|
|
(* OCamldoc *)
|
|
|
|
(* *)
|
|
|
|
(* Maxence Guesdon, projet Cristal, INRIA Rocquencourt *)
|
|
|
|
(* *)
|
|
|
|
(* Copyright 2001 Institut National de Recherche en Informatique et *)
|
|
|
|
(* en Automatique. All rights reserved. This file is distributed *)
|
|
|
|
(* under the terms of the Q Public License version 1.0. *)
|
|
|
|
(* *)
|
|
|
|
(***********************************************************************)
|
|
|
|
|
|
|
|
(** The man pages generator. *)
|
2004-12-03 06:42:09 -08:00
|
|
|
open Odoc_info
|
2002-03-27 08:20:32 -08:00
|
|
|
open Parameter
|
|
|
|
open Value
|
|
|
|
open Type
|
2014-05-04 16:08:45 -07:00
|
|
|
open Extension
|
2002-03-27 08:20:32 -08:00
|
|
|
open Exception
|
2004-12-03 06:42:09 -08:00
|
|
|
open Class
|
2002-03-27 08:20:32 -08:00
|
|
|
open Module
|
|
|
|
open Search
|
|
|
|
|
2010-08-24 02:45:45 -07:00
|
|
|
let man_suffix = ref Odoc_messages.default_man_suffix
|
|
|
|
let man_section = ref Odoc_messages.default_man_section
|
|
|
|
|
|
|
|
let man_mini = ref false
|
|
|
|
|
2004-03-14 05:52:01 -08:00
|
|
|
let new_buf () = Buffer.create 1024
|
|
|
|
let bp = Printf.bprintf
|
|
|
|
let bs = Buffer.add_string
|
2002-03-27 08:20:32 -08:00
|
|
|
|
2013-12-09 00:33:44 -08:00
|
|
|
let linebreak = "\n.sp\n";;
|
|
|
|
|
2002-03-27 08:20:32 -08:00
|
|
|
(** A class used to get a [text] for info structures. *)
|
|
|
|
class virtual info =
|
|
|
|
object (self)
|
|
|
|
(** The list of pairs [(tag, f)] where [f] is a function taking
|
2004-12-03 06:42:09 -08:00
|
|
|
the [text] associated to [tag] and returning man code.
|
2002-03-27 08:20:32 -08:00
|
|
|
Add a pair here to handle a tag.*)
|
|
|
|
val mutable tag_functions = ([] : (string * (Odoc_info.text -> string)) list)
|
|
|
|
|
|
|
|
(** Return man code for a [text]. *)
|
2004-03-14 05:52:01 -08:00
|
|
|
method virtual man_of_text : Buffer.t -> Odoc_info.text -> unit
|
2002-03-27 08:20:32 -08:00
|
|
|
|
2013-12-09 00:33:44 -08:00
|
|
|
method str_man_of_text t =
|
|
|
|
let b = Buffer.create 256 in
|
|
|
|
self#man_of_text b t ;
|
|
|
|
Buffer.contents b
|
|
|
|
|
2004-03-14 05:52:01 -08:00
|
|
|
(** Print groff string for an author list. *)
|
2013-12-09 00:33:44 -08:00
|
|
|
method str_man_of_author_list l =
|
2002-03-27 08:20:32 -08:00
|
|
|
match l with
|
2013-12-09 00:33:44 -08:00
|
|
|
[] -> ""
|
2002-03-27 08:20:32 -08:00
|
|
|
| _ ->
|
2013-12-09 00:33:44 -08:00
|
|
|
let b = Buffer.create 256 in
|
2004-03-14 05:52:01 -08:00
|
|
|
bs b ".B \"";
|
2006-01-04 08:55:50 -08:00
|
|
|
bs b Odoc_messages.authors;
|
|
|
|
bs b "\"\n:\n";
|
2004-03-14 05:52:01 -08:00
|
|
|
bs b (String.concat ", " l);
|
2013-12-09 00:33:44 -08:00
|
|
|
bs b "\n";
|
|
|
|
(*bs b "\n.sp\n"*)
|
|
|
|
Buffer.contents b
|
2004-03-14 05:52:01 -08:00
|
|
|
|
|
|
|
(** Print groff string for the given optional version information.*)
|
2013-12-09 00:33:44 -08:00
|
|
|
method str_man_of_version_opt v_opt =
|
2002-03-27 08:20:32 -08:00
|
|
|
match v_opt with
|
2013-12-09 00:33:44 -08:00
|
|
|
None -> ""
|
2004-12-03 06:42:09 -08:00
|
|
|
| Some v ->
|
2013-12-09 00:33:44 -08:00
|
|
|
let b = Buffer.create 256 in
|
2006-01-04 08:55:50 -08:00
|
|
|
bs b ".B \"";
|
|
|
|
bs b Odoc_messages.version;
|
|
|
|
bs b "\"\n:\n";
|
|
|
|
bs b v;
|
2013-12-09 00:33:44 -08:00
|
|
|
bs b "\n";
|
|
|
|
(*".sp\n"*)
|
|
|
|
Buffer.contents b
|
2004-03-14 05:52:01 -08:00
|
|
|
|
2010-05-31 04:52:13 -07:00
|
|
|
(** Printf groff string for the \@before information. *)
|
2013-12-09 00:33:44 -08:00
|
|
|
method str_man_of_before = function
|
|
|
|
[] -> ""
|
2010-05-31 04:52:13 -07:00
|
|
|
| l ->
|
2013-12-09 00:33:44 -08:00
|
|
|
let b = Buffer.create 256 in
|
|
|
|
let rec iter = function
|
|
|
|
[] -> ()
|
|
|
|
| (v, text) :: q ->
|
2010-05-31 04:52:13 -07:00
|
|
|
bp b ".B \"%s" Odoc_messages.before;
|
|
|
|
bs b v;
|
|
|
|
bs b "\"\n";
|
|
|
|
self#man_of_text b text;
|
|
|
|
bs b "\n";
|
2013-12-09 00:33:44 -08:00
|
|
|
bs b "\n";
|
|
|
|
match q with
|
|
|
|
[] -> ()
|
|
|
|
| _ -> bs b linebreak ; iter q
|
|
|
|
in
|
|
|
|
iter l;
|
|
|
|
Buffer.contents b
|
2010-05-31 04:52:13 -07:00
|
|
|
|
2004-03-14 05:52:01 -08:00
|
|
|
(** Print groff string for the given optional since information.*)
|
2013-12-09 00:33:44 -08:00
|
|
|
method str_man_of_since_opt s_opt =
|
2002-03-27 08:20:32 -08:00
|
|
|
match s_opt with
|
2013-12-09 00:33:44 -08:00
|
|
|
None -> ""
|
2004-12-03 06:42:09 -08:00
|
|
|
| Some s ->
|
2013-12-09 00:33:44 -08:00
|
|
|
let b = Buffer.create 256 in
|
2006-01-04 08:55:50 -08:00
|
|
|
bs b ".B \"";
|
|
|
|
bs b Odoc_messages.since;
|
|
|
|
bs b "\"\n";
|
|
|
|
bs b s;
|
2013-12-09 00:33:44 -08:00
|
|
|
bs b "\n";(*".sp\n"*)
|
|
|
|
Buffer.contents b
|
2004-03-14 05:52:01 -08:00
|
|
|
|
|
|
|
(** Print groff string for the given list of raised exceptions.*)
|
2013-12-09 00:33:44 -08:00
|
|
|
method str_man_of_raised_exceptions l =
|
2002-03-27 08:20:32 -08:00
|
|
|
match l with
|
2013-12-09 00:33:44 -08:00
|
|
|
[] -> ""
|
2002-03-27 08:20:32 -08:00
|
|
|
| _ ->
|
2013-12-09 00:33:44 -08:00
|
|
|
let b = Buffer.create 256 in
|
|
|
|
let rec iter = function
|
|
|
|
[] -> ()
|
|
|
|
| (s, t) :: q ->
|
|
|
|
bs b ".B \"";
|
|
|
|
bs b Odoc_messages.raises;
|
|
|
|
bs b (" "^s^"\"\n");
|
|
|
|
self#man_of_text b t;
|
|
|
|
bs b "\n";
|
|
|
|
match q with
|
|
|
|
[] -> ()
|
|
|
|
| _ -> bs b linebreak; iter q
|
|
|
|
in
|
|
|
|
iter l;
|
|
|
|
Buffer.contents b
|
2004-03-14 05:52:01 -08:00
|
|
|
|
|
|
|
(** Print groff string for the given "see also" reference. *)
|
2013-12-09 00:33:44 -08:00
|
|
|
method str_man_of_see (see_ref, t) =
|
2004-12-03 06:42:09 -08:00
|
|
|
let t_ref =
|
2002-07-23 07:12:03 -07:00
|
|
|
match see_ref with
|
|
|
|
Odoc_info.See_url s -> [ Odoc_info.Link (s, t) ]
|
|
|
|
| Odoc_info.See_file s -> (Odoc_info.Code s) :: (Odoc_info.Raw " ") :: t
|
|
|
|
| Odoc_info.See_doc s -> (Odoc_info.Italic [Odoc_info.Raw s]) :: (Odoc_info.Raw " ") :: t
|
2002-03-27 08:20:32 -08:00
|
|
|
in
|
2013-12-09 00:33:44 -08:00
|
|
|
self#str_man_of_text t_ref
|
2002-03-27 08:20:32 -08:00
|
|
|
|
2004-03-14 05:52:01 -08:00
|
|
|
(** Print groff string for the given list of "see also" references.*)
|
2013-12-09 00:33:44 -08:00
|
|
|
method str_man_of_sees l =
|
2002-03-27 08:20:32 -08:00
|
|
|
match l with
|
2013-12-09 00:33:44 -08:00
|
|
|
[] -> ""
|
2002-03-27 08:20:32 -08:00
|
|
|
| _ ->
|
2013-12-09 00:33:44 -08:00
|
|
|
let b = Buffer.create 256 in
|
|
|
|
let rec iter = function
|
|
|
|
[] -> ()
|
|
|
|
| see :: q ->
|
|
|
|
bs b ".B \"";
|
|
|
|
bs b Odoc_messages.see_also;
|
|
|
|
bs b "\"\n";
|
|
|
|
bs b (self#str_man_of_see see);
|
|
|
|
bs b "\n";
|
|
|
|
match q with
|
|
|
|
[] -> ()
|
|
|
|
| _ -> bs b linebreak; iter q
|
|
|
|
in
|
|
|
|
iter l;
|
|
|
|
Buffer.contents b
|
2004-03-14 05:52:01 -08:00
|
|
|
|
|
|
|
(** Print groff string for the given optional return information.*)
|
2013-12-09 00:33:44 -08:00
|
|
|
method str_man_of_return_opt return_opt =
|
2002-03-27 08:20:32 -08:00
|
|
|
match return_opt with
|
2013-12-09 00:33:44 -08:00
|
|
|
None -> ""
|
2004-12-03 06:42:09 -08:00
|
|
|
| Some s ->
|
2013-12-09 00:33:44 -08:00
|
|
|
let b = Buffer.create 256 in
|
2006-01-04 08:55:50 -08:00
|
|
|
bs b ".B ";
|
|
|
|
bs b Odoc_messages.returns;
|
|
|
|
bs b "\n";
|
|
|
|
self#man_of_text b s;
|
2013-12-09 00:33:44 -08:00
|
|
|
bs b "\n";
|
|
|
|
Buffer.contents b
|
2004-03-14 05:52:01 -08:00
|
|
|
|
|
|
|
(** Print man code for the given list of custom tagged texts. *)
|
2013-12-09 00:33:44 -08:00
|
|
|
method str_man_of_custom l =
|
|
|
|
List.fold_left
|
|
|
|
(fun acc (tag, text) ->
|
|
|
|
try
|
|
|
|
let f = List.assoc tag tag_functions in
|
|
|
|
let buf = Buffer.create 50 in
|
|
|
|
Buffer.add_string buf (f text);
|
|
|
|
(Buffer.contents buf) :: acc
|
2002-07-23 07:12:03 -07:00
|
|
|
with
|
|
|
|
Not_found ->
|
2013-12-09 00:33:44 -08:00
|
|
|
Odoc_info.warning (Odoc_messages.tag_not_handled tag);
|
|
|
|
acc
|
2002-07-23 07:12:03 -07:00
|
|
|
)
|
2013-12-09 00:33:44 -08:00
|
|
|
[] l
|
2002-03-27 08:20:32 -08:00
|
|
|
|
2004-03-14 05:52:01 -08:00
|
|
|
(** Print the groff string to display an optional info structure. *)
|
2013-12-09 00:33:44 -08:00
|
|
|
method man_of_info ?(margin=0) b info_opt =
|
2002-07-23 07:12:03 -07:00
|
|
|
match info_opt with
|
2004-03-14 05:52:01 -08:00
|
|
|
None -> ()
|
2002-03-27 08:20:32 -08:00
|
|
|
| Some info ->
|
2002-07-23 07:12:03 -07:00
|
|
|
let module M = Odoc_info in
|
2013-12-09 00:33:44 -08:00
|
|
|
let l =
|
|
|
|
(
|
2006-01-04 08:55:50 -08:00
|
|
|
match info.M.i_deprecated with
|
2013-12-09 00:33:44 -08:00
|
|
|
None -> []
|
2004-12-03 06:42:09 -08:00
|
|
|
| Some d ->
|
2013-12-09 00:33:44 -08:00
|
|
|
let b = Buffer.create 256 in
|
2006-01-04 08:55:50 -08:00
|
|
|
bs b ".B \"";
|
|
|
|
bs b Odoc_messages.deprecated;
|
|
|
|
bs b "\"\n";
|
|
|
|
self#man_of_text b d;
|
2013-12-09 00:33:44 -08:00
|
|
|
bs b "\n";
|
|
|
|
[ Buffer.contents b ]
|
|
|
|
) @
|
|
|
|
(
|
|
|
|
match info.M.i_desc with
|
|
|
|
None -> []
|
|
|
|
| Some d when d = [Odoc_info.Raw ""] -> []
|
|
|
|
| Some d ->
|
|
|
|
[ (self#str_man_of_text d)^"\n" ]
|
|
|
|
) @
|
|
|
|
[
|
|
|
|
self#str_man_of_author_list info.M.i_authors;
|
|
|
|
self#str_man_of_version_opt info.M.i_version;
|
|
|
|
self#str_man_of_before info.M.i_before;
|
|
|
|
self#str_man_of_since_opt info.M.i_since;
|
|
|
|
self#str_man_of_raised_exceptions info.M.i_raised_exceptions;
|
|
|
|
self#str_man_of_return_opt info.M.i_return_value;
|
|
|
|
self#str_man_of_sees info.M.i_sees;
|
|
|
|
] @
|
|
|
|
(self#str_man_of_custom info.M.i_custom)
|
|
|
|
in
|
|
|
|
let l = List.filter ((<>) "") l in
|
|
|
|
Buffer.add_string b (String.concat "\n.sp\n" l)
|
2002-03-27 08:20:32 -08:00
|
|
|
end
|
|
|
|
|
2010-08-24 02:45:45 -07:00
|
|
|
module Generator =
|
|
|
|
struct
|
|
|
|
|
2002-03-27 08:20:32 -08:00
|
|
|
(** This class is used to create objects which can generate a simple html documentation. *)
|
|
|
|
class man =
|
2002-04-22 02:41:52 -07:00
|
|
|
let re_slash = Str.regexp_string "/" in
|
2002-03-27 08:20:32 -08:00
|
|
|
object (self)
|
|
|
|
inherit info
|
|
|
|
|
2002-04-22 02:41:52 -07:00
|
|
|
(** Get a file name from a complete name. *)
|
2004-12-03 06:42:09 -08:00
|
|
|
method file_name name =
|
2010-08-24 02:45:45 -07:00
|
|
|
let s = Printf.sprintf "%s.%s" name !man_suffix in
|
2002-04-22 02:41:52 -07:00
|
|
|
Str.global_replace re_slash "slash" s
|
2002-03-27 08:20:32 -08:00
|
|
|
|
|
|
|
(** Escape special sequences of characters in a string. *)
|
2005-08-13 13:59:37 -07:00
|
|
|
method escape (s : string) =
|
|
|
|
let len = String.length s in
|
|
|
|
let b = Buffer.create len in
|
|
|
|
for i = 0 to len - 1 do
|
2006-01-04 08:55:50 -08:00
|
|
|
match s.[i] with
|
|
|
|
'\\' -> Buffer.add_string b "\\(rs"
|
|
|
|
| '.' -> Buffer.add_string b "\\&."
|
2008-10-29 06:30:24 -07:00
|
|
|
| '\'' -> Buffer.add_string b "\\&'"
|
|
|
|
| '-' -> Buffer.add_string b "\\-"
|
2006-01-04 08:55:50 -08:00
|
|
|
| c -> Buffer.add_char b c
|
2005-08-13 13:59:37 -07:00
|
|
|
done;
|
|
|
|
Buffer.contents b
|
2002-03-27 08:20:32 -08:00
|
|
|
|
|
|
|
(** Open a file for output. Add the target directory.*)
|
|
|
|
method open_out file =
|
2010-08-24 02:45:45 -07:00
|
|
|
let f = Filename.concat !Global.target_dir file in
|
2002-03-27 08:20:32 -08:00
|
|
|
open_out f
|
2004-12-03 06:42:09 -08:00
|
|
|
|
2004-03-14 05:52:01 -08:00
|
|
|
(** Print groff string for a text, without correction of blanks. *)
|
2004-12-03 06:42:09 -08:00
|
|
|
method private man_of_text2 b t =
|
2004-03-14 05:52:01 -08:00
|
|
|
List.iter (self#man_of_text_element b) t
|
|
|
|
|
|
|
|
(** Print the groff string for a text, with blanks corrected. *)
|
|
|
|
method man_of_text b t =
|
|
|
|
let b2 = new_buf () in
|
|
|
|
self#man_of_text2 b2 t ;
|
|
|
|
let s = Buffer.contents b2 in
|
2002-03-27 08:20:32 -08:00
|
|
|
let s2 = Str.global_replace (Str.regexp "\n[ ]*") "\n" s in
|
2004-03-14 05:52:01 -08:00
|
|
|
bs b (Str.global_replace (Str.regexp "\n\n") "\n" s2)
|
2002-03-27 08:20:32 -08:00
|
|
|
|
2002-09-16 03:52:13 -07:00
|
|
|
(** Return the given string without no newlines. *)
|
|
|
|
method remove_newlines s =
|
|
|
|
Str.global_replace (Str.regexp "[ ]*\n[ ]*") " " s
|
2004-12-03 06:42:09 -08:00
|
|
|
|
2004-03-14 05:52:01 -08:00
|
|
|
(** Print the groff string for a text element. *)
|
2014-05-04 16:08:45 -07:00
|
|
|
method man_of_text_element b txt =
|
|
|
|
match txt with
|
2005-08-13 13:59:37 -07:00
|
|
|
| Odoc_info.Raw s -> bs b (self#escape s)
|
2004-12-03 06:42:09 -08:00
|
|
|
| Odoc_info.Code s ->
|
2004-03-14 05:52:01 -08:00
|
|
|
bs b "\n.B ";
|
2006-01-04 08:55:50 -08:00
|
|
|
bs b ((Str.global_replace (Str.regexp "\n") "\n.B " (self#escape s))^"\n")
|
2004-12-03 06:42:09 -08:00
|
|
|
| Odoc_info.CodePre s ->
|
2004-03-14 05:52:01 -08:00
|
|
|
bs b "\n.B ";
|
2006-01-04 08:55:50 -08:00
|
|
|
bs b ((Str.global_replace (Str.regexp "\n") "\n.B " (self#escape s))^"\n")
|
2004-12-03 06:42:09 -08:00
|
|
|
| Odoc_info.Verbatim s ->
|
2006-01-04 08:55:50 -08:00
|
|
|
bs b (self#escape s)
|
2002-07-23 07:12:03 -07:00
|
|
|
| Odoc_info.Bold t
|
|
|
|
| Odoc_info.Italic t
|
|
|
|
| Odoc_info.Emphasize t
|
|
|
|
| Odoc_info.Center t
|
|
|
|
| Odoc_info.Left t
|
2004-12-03 06:42:09 -08:00
|
|
|
| Odoc_info.Right t ->
|
2006-01-04 08:55:50 -08:00
|
|
|
self#man_of_text2 b t
|
2002-07-23 07:12:03 -07:00
|
|
|
| Odoc_info.List tl ->
|
2004-03-14 05:52:01 -08:00
|
|
|
List.iter
|
2006-01-04 08:55:50 -08:00
|
|
|
(fun t -> bs b "\n.sp\n \\-"; self#man_of_text2 b t; bs b "\n")
|
2004-03-14 05:52:01 -08:00
|
|
|
tl;
|
|
|
|
bs b "\n"
|
2002-07-23 07:12:03 -07:00
|
|
|
| Odoc_info.Enum tl ->
|
2004-03-14 05:52:01 -08:00
|
|
|
List.iter
|
2006-01-04 08:55:50 -08:00
|
|
|
(fun t -> bs b "\n.sp\n \\-"; self#man_of_text2 b t; bs b "\n")
|
2004-03-14 05:52:01 -08:00
|
|
|
tl;
|
|
|
|
bs b "\n"
|
2002-07-23 07:12:03 -07:00
|
|
|
| Odoc_info.Newline ->
|
2004-03-14 05:52:01 -08:00
|
|
|
bs b "\n.sp\n"
|
2002-07-23 07:12:03 -07:00
|
|
|
| Odoc_info.Block t ->
|
2004-03-14 05:52:01 -08:00
|
|
|
bs b "\n.sp\n";
|
2006-01-04 08:55:50 -08:00
|
|
|
self#man_of_text2 b t;
|
|
|
|
bs b "\n.sp\n"
|
2002-07-23 07:12:03 -07:00
|
|
|
| Odoc_info.Title (n, l_opt, t) ->
|
2004-03-14 05:52:01 -08:00
|
|
|
self#man_of_text2 b [Odoc_info.Code (Odoc_info.string_of_text t)]
|
2002-07-23 07:12:03 -07:00
|
|
|
| Odoc_info.Latex _ ->
|
|
|
|
(* don't care about LaTeX stuff in HTML. *)
|
2004-03-14 05:52:01 -08:00
|
|
|
()
|
2002-07-23 07:12:03 -07:00
|
|
|
| Odoc_info.Link (s, t) ->
|
2004-03-14 05:52:01 -08:00
|
|
|
self#man_of_text2 b t
|
2009-12-18 03:52:23 -08:00
|
|
|
| Odoc_info.Ref (name, _, _) ->
|
2004-03-14 05:52:01 -08:00
|
|
|
self#man_of_text_element b
|
2002-07-23 07:12:03 -07:00
|
|
|
(Odoc_info.Code (Odoc_info.use_hidden_modules name))
|
|
|
|
| Odoc_info.Superscript t ->
|
2004-03-14 05:52:01 -08:00
|
|
|
bs b "^{"; self#man_of_text2 b t
|
2002-07-23 07:12:03 -07:00
|
|
|
| Odoc_info.Subscript t ->
|
2004-03-14 05:52:01 -08:00
|
|
|
bs b "_{"; self#man_of_text2 b t
|
2006-01-04 08:55:50 -08:00
|
|
|
| Odoc_info.Module_list _ ->
|
|
|
|
()
|
|
|
|
| Odoc_info.Index_list ->
|
|
|
|
()
|
|
|
|
| Odoc_info.Custom (s,t) -> self#man_of_custom_text b s t
|
2010-03-08 08:54:13 -08:00
|
|
|
| Odoc_info.Target (target, code) -> self#man_of_Target b ~target ~code
|
2006-01-04 08:55:50 -08:00
|
|
|
|
|
|
|
method man_of_custom_text b s t = ()
|
2002-03-27 08:20:32 -08:00
|
|
|
|
2010-03-08 08:54:13 -08:00
|
|
|
method man_of_Target b ~target ~code =
|
2014-12-21 03:46:14 -08:00
|
|
|
if String.lowercase_ascii target = "man" then bs b code else ()
|
2010-03-08 08:54:13 -08:00
|
|
|
|
2004-03-14 05:52:01 -08:00
|
|
|
(** Print groff string to display code. *)
|
|
|
|
method man_of_code b s = self#man_of_text b [ Code s ]
|
2002-03-27 08:20:32 -08:00
|
|
|
|
2004-12-03 06:42:09 -08:00
|
|
|
(** Take a string and return the string where fully qualified idents
|
2002-03-27 08:20:32 -08:00
|
|
|
have been replaced by idents relative to the given module name.*)
|
|
|
|
method relative_idents m_name s =
|
2004-12-03 06:42:09 -08:00
|
|
|
let f str_t =
|
2002-07-23 07:12:03 -07:00
|
|
|
let match_s = Str.matched_string str_t in
|
2004-12-03 06:42:09 -08:00
|
|
|
Odoc_info.apply_if_equal
|
|
|
|
Odoc_info.use_hidden_modules
|
2002-07-23 07:12:03 -07:00
|
|
|
match_s
|
|
|
|
(Name.get_relative m_name match_s)
|
2002-03-27 08:20:32 -08:00
|
|
|
in
|
2016-01-19 15:02:30 -08:00
|
|
|
Str.global_substitute
|
|
|
|
(Str.regexp "\\([A-Z]\\([a-zA-Z_'0-9]\\)*\\.\\)+\\([a-z][a-zA-Z_'0-9]*\\)")
|
|
|
|
f
|
|
|
|
s
|
2002-03-27 08:20:32 -08:00
|
|
|
|
2004-03-14 05:52:01 -08:00
|
|
|
(** Print groff string to display a [Types.type_expr].*)
|
|
|
|
method man_of_type_expr b m_name t =
|
2002-03-27 08:20:32 -08:00
|
|
|
let s = String.concat "\n"
|
2004-03-05 06:57:52 -08:00
|
|
|
(Str.split (Str.regexp "\n") (Odoc_print.string_of_type_expr t))
|
2002-03-27 08:20:32 -08:00
|
|
|
in
|
|
|
|
let s2 = Str.global_replace (Str.regexp "\n") "\n.B " s in
|
2004-03-14 05:52:01 -08:00
|
|
|
bs b "\n.B ";
|
|
|
|
bs b (self#relative_idents m_name s2);
|
|
|
|
bs b "\n"
|
2002-03-27 08:20:32 -08:00
|
|
|
|
2004-03-14 05:52:01 -08:00
|
|
|
(** Print groff string to display a [Types.class_type].*)
|
|
|
|
method man_of_class_type_expr b m_name t =
|
2002-04-05 01:20:29 -08:00
|
|
|
let s = String.concat "\n"
|
2004-03-05 06:57:52 -08:00
|
|
|
(Str.split (Str.regexp "\n") (Odoc_print.string_of_class_type t))
|
2002-04-05 01:20:29 -08:00
|
|
|
in
|
|
|
|
let s2 = Str.global_replace (Str.regexp "\n") "\n.B " s in
|
2004-03-14 05:52:01 -08:00
|
|
|
bs b "\n.B ";
|
|
|
|
bs b (self#relative_idents m_name s2);
|
|
|
|
bs b "\n"
|
2002-04-05 01:20:29 -08:00
|
|
|
|
2004-03-14 05:52:01 -08:00
|
|
|
(** Print groff string to display a [Types.type_expr list].*)
|
2014-10-14 08:51:30 -07:00
|
|
|
method man_of_cstr_args ?par b m_name sep l =
|
|
|
|
let s =
|
|
|
|
match l with
|
|
|
|
| Cstr_tuple l ->
|
|
|
|
Odoc_str.string_of_type_list ?par sep l
|
|
|
|
| Cstr_record l ->
|
|
|
|
Odoc_str.string_of_record l
|
|
|
|
in
|
2002-03-27 08:20:32 -08:00
|
|
|
let s2 = Str.global_replace (Str.regexp "\n") "\n.B " s in
|
2004-03-14 05:52:01 -08:00
|
|
|
bs b "\n.B ";
|
|
|
|
bs b (self#relative_idents m_name s2);
|
|
|
|
bs b "\n"
|
2002-03-27 08:20:32 -08:00
|
|
|
|
2004-03-14 05:52:01 -08:00
|
|
|
(** Print groff string to display the parameters of a type.*)
|
|
|
|
method man_of_type_expr_param_list b m_name t =
|
2003-09-05 08:40:12 -07:00
|
|
|
match t.ty_parameters with
|
2004-03-14 05:52:01 -08:00
|
|
|
[] -> ()
|
2003-09-05 08:40:12 -07:00
|
|
|
| l ->
|
2006-01-04 08:55:50 -08:00
|
|
|
let s = Odoc_str.string_of_type_param_list t in
|
|
|
|
let s2 = Str.global_replace (Str.regexp "\n") "\n.B " s in
|
|
|
|
bs b "\n.B ";
|
|
|
|
bs b (self#relative_idents m_name s2);
|
|
|
|
bs b "\n"
|
2003-09-05 08:40:12 -07:00
|
|
|
|
2004-03-14 05:52:01 -08:00
|
|
|
(** Print groff string to display a [Types.module_type]. *)
|
|
|
|
method man_of_module_type b m_name t =
|
2002-03-27 08:20:32 -08:00
|
|
|
let s = String.concat "\n"
|
2004-03-05 06:57:52 -08:00
|
|
|
(Str.split (Str.regexp "\n") (Odoc_print.string_of_module_type t))
|
2002-03-27 08:20:32 -08:00
|
|
|
in
|
|
|
|
let s2 = Str.global_replace (Str.regexp "\n") "\n.B " s in
|
2004-03-14 05:52:01 -08:00
|
|
|
bs b "\n.B ";
|
|
|
|
bs b (self#relative_idents m_name s2);
|
|
|
|
bs b "\n"
|
2002-03-27 08:20:32 -08:00
|
|
|
|
2004-03-14 05:52:01 -08:00
|
|
|
(** Print groff string code for a value. *)
|
|
|
|
method man_of_value b v =
|
2002-03-27 08:20:32 -08:00
|
|
|
Odoc_info.reset_type_names () ;
|
2004-03-14 05:52:01 -08:00
|
|
|
bs b "\n.I val ";
|
|
|
|
bs b (Name.simple v.val_name);
|
|
|
|
bs b " \n: ";
|
|
|
|
self#man_of_type_expr b (Name.father v.val_name) v.val_type;
|
|
|
|
bs b ".sp\n";
|
|
|
|
self#man_of_info b v.val_info;
|
|
|
|
bs b "\n.sp\n"
|
|
|
|
|
2014-05-04 16:08:45 -07:00
|
|
|
(** Print groff string code for a type extension. *)
|
|
|
|
method man_of_type_extension b m_name te =
|
|
|
|
Odoc_info.reset_type_names () ;
|
|
|
|
bs b ".I type ";
|
|
|
|
(
|
|
|
|
match te.te_type_parameters with
|
|
|
|
[] -> ()
|
|
|
|
| l ->
|
|
|
|
let s = Odoc_str.string_of_type_extension_param_list te in
|
|
|
|
let s2 = Str.global_replace (Str.regexp "\n") "\n.B " s in
|
|
|
|
bs b "\n.B ";
|
|
|
|
bs b (self#relative_idents m_name s2);
|
|
|
|
bs b "\n";
|
|
|
|
bs b ".I "
|
|
|
|
);
|
|
|
|
bs b (self#relative_idents m_name te.te_type_name);
|
|
|
|
bs b " \n";
|
|
|
|
bs b "+=";
|
|
|
|
if te.te_private = Asttypes.Private then bs b " private";
|
|
|
|
bs b "\n ";
|
|
|
|
List.iter
|
|
|
|
(fun x ->
|
|
|
|
let father = Name.father x.xt_name in
|
|
|
|
bs b ("| "^(Name.simple x.xt_name));
|
|
|
|
(
|
|
|
|
match x.xt_args, x.xt_ret with
|
2014-10-14 08:51:30 -07:00
|
|
|
| Cstr_tuple [], None -> bs b "\n"
|
2014-05-04 16:08:45 -07:00
|
|
|
| l, None ->
|
|
|
|
bs b "\n.B of ";
|
2014-10-14 08:51:30 -07:00
|
|
|
self#man_of_cstr_args ~par: false b father " * " l;
|
|
|
|
| Cstr_tuple [], Some r ->
|
2014-05-04 16:08:45 -07:00
|
|
|
bs b "\n.B : ";
|
|
|
|
self#man_of_type_expr b father r;
|
|
|
|
| l, Some r ->
|
|
|
|
bs b "\n.B : ";
|
2014-10-14 08:51:30 -07:00
|
|
|
self#man_of_cstr_args ~par: false b father " * " l;
|
2014-05-04 16:08:45 -07:00
|
|
|
bs b ".B -> ";
|
|
|
|
self#man_of_type_expr b father r;
|
|
|
|
);
|
|
|
|
(
|
|
|
|
match x.xt_alias with
|
|
|
|
None -> ()
|
|
|
|
| Some xa ->
|
|
|
|
bs b ".B = ";
|
|
|
|
bs b
|
|
|
|
(
|
|
|
|
match xa.xa_xt with
|
|
|
|
None -> xa.xa_name
|
|
|
|
| Some x -> x.xt_name
|
|
|
|
);
|
|
|
|
bs b "\n"
|
|
|
|
);
|
|
|
|
(
|
|
|
|
match x.xt_text with
|
|
|
|
None ->
|
|
|
|
bs b " "
|
|
|
|
| Some t ->
|
|
|
|
bs b ".I \" \"\n";
|
|
|
|
bs b "(* ";
|
|
|
|
self#man_of_info b (Some t);
|
|
|
|
bs b " *)\n "
|
|
|
|
)
|
|
|
|
)
|
|
|
|
te.te_constructors;
|
|
|
|
bs b "\n.sp\n";
|
|
|
|
self#man_of_info b te.te_info;
|
|
|
|
bs b "\n.sp\n"
|
|
|
|
|
2004-03-14 05:52:01 -08:00
|
|
|
(** Print groff string code for an exception. *)
|
|
|
|
method man_of_exception b e =
|
2002-03-27 08:20:32 -08:00
|
|
|
Odoc_info.reset_type_names () ;
|
2004-03-14 05:52:01 -08:00
|
|
|
bs b "\n.I exception ";
|
|
|
|
bs b (Name.simple e.ex_name);
|
|
|
|
bs b " \n";
|
|
|
|
(
|
2014-05-04 16:08:45 -07:00
|
|
|
match e.ex_args, e.ex_ret with
|
2014-10-14 08:51:30 -07:00
|
|
|
| Cstr_tuple [], None -> ()
|
2014-05-04 16:08:45 -07:00
|
|
|
| l, None ->
|
2004-03-14 05:52:01 -08:00
|
|
|
bs b ".B of ";
|
2014-10-14 08:51:30 -07:00
|
|
|
self#man_of_cstr_args
|
2006-01-04 08:55:50 -08:00
|
|
|
~par: false
|
|
|
|
b (Name.father e.ex_name) " * " e.ex_args
|
2014-10-14 08:51:30 -07:00
|
|
|
| Cstr_tuple [], Some r ->
|
2014-05-04 16:08:45 -07:00
|
|
|
bs b ".B : ";
|
|
|
|
self#man_of_type_expr b (Name.father e.ex_name) r
|
|
|
|
| l, Some r ->
|
|
|
|
bs b ".B : ";
|
2014-10-14 08:51:30 -07:00
|
|
|
self#man_of_cstr_args
|
2014-05-04 16:08:45 -07:00
|
|
|
~par: false
|
|
|
|
b (Name.father e.ex_name) " * " l;
|
|
|
|
bs b ".B -> ";
|
|
|
|
self#man_of_type_expr b (Name.father e.ex_name) r
|
2004-03-14 05:52:01 -08:00
|
|
|
);
|
|
|
|
(
|
|
|
|
match e.ex_alias with
|
|
|
|
None -> ()
|
2004-12-03 06:42:09 -08:00
|
|
|
| Some ea ->
|
2006-01-04 08:55:50 -08:00
|
|
|
bs b " = ";
|
2004-12-03 06:42:09 -08:00
|
|
|
bs b
|
2006-01-04 08:55:50 -08:00
|
|
|
(
|
2004-03-14 05:52:01 -08:00
|
|
|
match ea.ea_ex with
|
2006-01-04 08:55:50 -08:00
|
|
|
None -> ea.ea_name
|
2004-03-14 05:52:01 -08:00
|
|
|
| Some e -> e.ex_name
|
|
|
|
)
|
|
|
|
);
|
|
|
|
bs b "\n.sp\n";
|
|
|
|
self#man_of_info b e.ex_info;
|
|
|
|
bs b "\n.sp\n"
|
2002-03-27 08:20:32 -08:00
|
|
|
|
2004-03-14 05:52:01 -08:00
|
|
|
(** Print groff string for a type. *)
|
|
|
|
method man_of_type b t =
|
2002-03-27 08:20:32 -08:00
|
|
|
Odoc_info.reset_type_names () ;
|
|
|
|
let father = Name.father t.ty_name in
|
2014-05-22 06:38:29 -07:00
|
|
|
let field_comment = function
|
|
|
|
| None -> ()
|
|
|
|
| Some t ->
|
|
|
|
bs b " (* ";
|
|
|
|
self#man_of_info b (Some t);
|
|
|
|
bs b " *) "
|
|
|
|
in
|
2004-03-14 05:52:01 -08:00
|
|
|
bs b ".I type ";
|
|
|
|
self#man_of_type_expr_param_list b father t;
|
|
|
|
(
|
2004-12-03 06:42:09 -08:00
|
|
|
match t.ty_parameters with
|
2006-01-04 08:55:50 -08:00
|
|
|
[] -> ()
|
2004-03-14 05:52:01 -08:00
|
|
|
| _ -> bs b ".I "
|
|
|
|
);
|
|
|
|
bs b (Name.simple t.ty_name);
|
|
|
|
bs b " \n";
|
2007-10-09 03:29:37 -07:00
|
|
|
let priv = t.ty_private = Asttypes.Private in
|
2004-03-14 05:52:01 -08:00
|
|
|
(
|
2004-12-03 06:42:09 -08:00
|
|
|
match t.ty_manifest with
|
2006-01-04 08:55:50 -08:00
|
|
|
None -> ()
|
2014-05-22 06:38:29 -07:00
|
|
|
| Some (Object_type l) ->
|
|
|
|
bs b "= ";
|
|
|
|
if priv then bs b "private ";
|
|
|
|
bs b "<";
|
|
|
|
List.iter (fun r ->
|
|
|
|
bs b (r.of_name^" : ");
|
|
|
|
self#man_of_type_expr b father r.of_type;
|
|
|
|
bs b ";";
|
|
|
|
field_comment r.of_text ;
|
|
|
|
) l;
|
|
|
|
bs b "\n >\n"
|
|
|
|
| Some (Other typ) ->
|
2006-01-04 08:55:50 -08:00
|
|
|
bs b "= ";
|
2007-10-09 03:29:37 -07:00
|
|
|
if priv then bs b "private ";
|
2006-01-04 08:55:50 -08:00
|
|
|
self#man_of_type_expr b father typ
|
2004-03-14 05:52:01 -08:00
|
|
|
);
|
2003-07-04 02:31:03 -07:00
|
|
|
(
|
|
|
|
match t.ty_kind with
|
2004-12-03 06:42:09 -08:00
|
|
|
Type_abstract -> ()
|
2007-10-09 03:29:37 -07:00
|
|
|
| Type_variant l ->
|
2014-05-22 06:38:29 -07:00
|
|
|
bs b "=";
|
|
|
|
if priv then bs b " private";
|
|
|
|
bs b "\n ";
|
|
|
|
List.iter (fun constr ->
|
|
|
|
bs b ("| "^constr.vc_name);
|
|
|
|
let print_text t =
|
|
|
|
bs b " (* ";
|
|
|
|
self#man_of_info b (Some t);
|
|
|
|
bs b " *)\n "
|
|
|
|
in
|
|
|
|
match constr.vc_args, constr.vc_text,constr.vc_ret with
|
2014-10-14 08:51:30 -07:00
|
|
|
| Cstr_tuple [], None, None -> bs b "\n "
|
|
|
|
| Cstr_tuple [], (Some t), None ->
|
2014-05-22 06:38:29 -07:00
|
|
|
print_text t
|
|
|
|
| l, None, None ->
|
|
|
|
bs b "\n.B of ";
|
2014-10-14 08:51:30 -07:00
|
|
|
self#man_of_cstr_args ~par: false b father " * " l;
|
2014-05-22 06:38:29 -07:00
|
|
|
bs b " "
|
|
|
|
| l, (Some t), None ->
|
|
|
|
bs b "\n.B of ";
|
2014-10-14 08:51:30 -07:00
|
|
|
self#man_of_cstr_args ~par: false b father " * " l;
|
2014-05-22 06:38:29 -07:00
|
|
|
bs b ".I \" \"\n";
|
|
|
|
print_text t
|
2014-10-14 08:51:30 -07:00
|
|
|
| Cstr_tuple [], None, Some r ->
|
2014-05-22 06:38:29 -07:00
|
|
|
bs b "\n.B : ";
|
|
|
|
self#man_of_type_expr b father r;
|
|
|
|
bs b " "
|
2014-10-14 08:51:30 -07:00
|
|
|
| Cstr_tuple [], (Some t), Some r ->
|
2014-05-22 06:38:29 -07:00
|
|
|
bs b "\n.B : ";
|
|
|
|
self#man_of_type_expr b father r;
|
|
|
|
bs b ".I \" \"\n";
|
|
|
|
print_text t
|
|
|
|
| l, None, Some r ->
|
|
|
|
bs b "\n.B : ";
|
2014-10-14 08:51:30 -07:00
|
|
|
self#man_of_cstr_args ~par: false b father " * " l;
|
2014-05-22 06:38:29 -07:00
|
|
|
bs b ".B -> ";
|
|
|
|
self#man_of_type_expr b father r;
|
|
|
|
bs b " "
|
|
|
|
| l, (Some t), Some r ->
|
|
|
|
bs b "\n.B of ";
|
2014-10-14 08:51:30 -07:00
|
|
|
self#man_of_cstr_args ~par: false b father " * " l;
|
2014-05-22 06:38:29 -07:00
|
|
|
bs b ".B -> ";
|
|
|
|
self#man_of_type_expr b father r;
|
|
|
|
bs b ".I \" \"\n";
|
|
|
|
print_text t
|
|
|
|
) l
|
|
|
|
|
2007-10-09 03:29:37 -07:00
|
|
|
| Type_record l ->
|
2004-03-14 05:52:01 -08:00
|
|
|
bs b "= ";
|
2006-01-04 08:55:50 -08:00
|
|
|
if priv then bs b "private ";
|
|
|
|
bs b "{";
|
2014-05-22 06:38:29 -07:00
|
|
|
List.iter (fun r ->
|
|
|
|
bs b (if r.rf_mutable then "\n\n.B mutable \n" else "\n ");
|
|
|
|
bs b (r.rf_name^" : ");
|
|
|
|
self#man_of_type_expr b father r.rf_type;
|
|
|
|
bs b ";";
|
|
|
|
field_comment r.rf_text ;
|
|
|
|
) l;
|
2004-03-14 05:52:01 -08:00
|
|
|
bs b "\n }\n"
|
2014-05-04 16:08:45 -07:00
|
|
|
| Type_open ->
|
|
|
|
bs b "= ..";
|
|
|
|
bs b "\n"
|
2004-03-14 05:52:01 -08:00
|
|
|
);
|
|
|
|
bs b "\n.sp\n";
|
|
|
|
self#man_of_info b t.ty_info;
|
|
|
|
bs b "\n.sp\n"
|
|
|
|
|
|
|
|
(** Print groff string for a class attribute. *)
|
|
|
|
method man_of_attribute b a =
|
|
|
|
bs b ".I val ";
|
2008-07-23 01:55:36 -07:00
|
|
|
if a.att_virtual then bs b ("virtual ");
|
2004-03-14 05:52:01 -08:00
|
|
|
if a.att_mutable then bs b (Odoc_messages.mutab^" ");
|
|
|
|
bs b ((Name.simple a.att_value.val_name)^" : ");
|
|
|
|
self#man_of_type_expr b (Name.father a.att_value.val_name) a.att_value.val_type;
|
|
|
|
bs b "\n.sp\n";
|
|
|
|
self#man_of_info b a.att_value.val_info;
|
|
|
|
bs b "\n.sp\n"
|
|
|
|
|
|
|
|
(** Print groff string for a class method. *)
|
|
|
|
method man_of_method b m =
|
|
|
|
bs b ".I method ";
|
|
|
|
if m.met_private then bs b "private ";
|
|
|
|
if m.met_virtual then bs b "virtual ";
|
|
|
|
bs b ((Name.simple m.met_value.val_name)^" : ");
|
2004-12-03 06:42:09 -08:00
|
|
|
self#man_of_type_expr b
|
2006-01-04 08:55:50 -08:00
|
|
|
(Name.father m.met_value.val_name) m.met_value.val_type;
|
2004-03-14 05:52:01 -08:00
|
|
|
bs b "\n.sp\n";
|
|
|
|
self#man_of_info b m.met_value.val_info;
|
|
|
|
bs b "\n.sp\n"
|
2002-03-27 08:20:32 -08:00
|
|
|
|
|
|
|
(** Groff for a list of parameters. *)
|
2004-03-14 05:52:01 -08:00
|
|
|
method man_of_parameter_list b m_name l =
|
2002-03-27 08:20:32 -08:00
|
|
|
match l with
|
2004-03-14 05:52:01 -08:00
|
|
|
[] -> ()
|
2002-03-27 08:20:32 -08:00
|
|
|
| _ ->
|
2004-03-14 05:52:01 -08:00
|
|
|
bs b "\n.B ";
|
2006-01-04 08:55:50 -08:00
|
|
|
bs b Odoc_messages.parameters;
|
|
|
|
bs b ": \n";
|
|
|
|
List.iter
|
2004-03-14 05:52:01 -08:00
|
|
|
(fun p ->
|
2006-01-04 08:55:50 -08:00
|
|
|
bs b ".sp\n";
|
2004-03-14 05:52:01 -08:00
|
|
|
bs b "\"";
|
2006-01-04 08:55:50 -08:00
|
|
|
bs b (Parameter.complete_name p);
|
|
|
|
bs b "\"\n";
|
2004-03-14 05:52:01 -08:00
|
|
|
self#man_of_type_expr b m_name (Parameter.typ p);
|
2006-01-04 08:55:50 -08:00
|
|
|
bs b "\n";
|
2004-03-14 05:52:01 -08:00
|
|
|
self#man_of_parameter_description b p;
|
2006-01-04 08:55:50 -08:00
|
|
|
bs b "\n"
|
2004-03-14 05:52:01 -08:00
|
|
|
)
|
|
|
|
l;
|
|
|
|
bs b "\n"
|
2002-03-27 08:20:32 -08:00
|
|
|
|
|
|
|
(** Groff for the description of a function parameter. *)
|
2004-03-14 05:52:01 -08:00
|
|
|
method man_of_parameter_description b p =
|
2002-03-27 08:20:32 -08:00
|
|
|
match Parameter.names p with
|
2004-03-14 05:52:01 -08:00
|
|
|
[] -> ()
|
2002-03-27 08:20:32 -08:00
|
|
|
| name :: [] ->
|
2002-07-23 07:12:03 -07:00
|
|
|
(
|
2002-03-27 08:20:32 -08:00
|
|
|
(* Only one name, no need for label for the description. *)
|
2002-07-23 07:12:03 -07:00
|
|
|
match Parameter.desc_by_name p name with
|
2004-03-14 05:52:01 -08:00
|
|
|
None -> ()
|
|
|
|
| Some t -> bs b "\n "; self#man_of_text b t
|
2002-07-23 07:12:03 -07:00
|
|
|
)
|
2002-03-27 08:20:32 -08:00
|
|
|
| l ->
|
|
|
|
(* A list of names, we display those with a description. *)
|
2006-01-04 08:55:50 -08:00
|
|
|
List.iter
|
2004-03-14 05:52:01 -08:00
|
|
|
(fun n ->
|
|
|
|
match Parameter.desc_by_name p n with
|
|
|
|
None -> ()
|
2004-12-03 06:42:09 -08:00
|
|
|
| Some t ->
|
2006-01-04 08:55:50 -08:00
|
|
|
self#man_of_code b (n^" : ");
|
|
|
|
self#man_of_text b t
|
2002-07-23 07:12:03 -07:00
|
|
|
)
|
2004-03-14 05:52:01 -08:00
|
|
|
l
|
2002-03-27 08:20:32 -08:00
|
|
|
|
2004-03-14 05:52:01 -08:00
|
|
|
(** Print groff string for a list of module parameters. *)
|
|
|
|
method man_of_module_parameter_list b m_name l =
|
2002-03-27 08:20:32 -08:00
|
|
|
match l with
|
2004-03-14 05:52:01 -08:00
|
|
|
[] -> ()
|
2002-03-27 08:20:32 -08:00
|
|
|
| _ ->
|
2004-03-14 05:52:01 -08:00
|
|
|
bs b ".B \"";
|
2006-01-04 08:55:50 -08:00
|
|
|
bs b Odoc_messages.parameters;
|
|
|
|
bs b ":\"\n";
|
2004-03-14 05:52:01 -08:00
|
|
|
List.iter
|
|
|
|
(fun (p, desc_opt) ->
|
2006-01-04 08:55:50 -08:00
|
|
|
bs b ".sp\n";
|
2004-03-14 05:52:01 -08:00
|
|
|
bs b ("\""^p.mp_name^"\"\n");
|
2013-12-16 19:52:50 -08:00
|
|
|
Misc.may (self#man_of_module_type b m_name) p.mp_type;
|
2006-01-04 08:55:50 -08:00
|
|
|
bs b "\n";
|
2004-03-14 05:52:01 -08:00
|
|
|
(
|
2006-01-04 08:55:50 -08:00
|
|
|
match desc_opt with
|
2004-03-14 05:52:01 -08:00
|
|
|
None -> ()
|
|
|
|
| Some t -> self#man_of_text b t
|
2006-01-04 08:55:50 -08:00
|
|
|
);
|
2004-03-14 05:52:01 -08:00
|
|
|
bs b "\n"
|
|
|
|
)
|
|
|
|
l;
|
|
|
|
bs b "\n\n"
|
2002-03-27 08:20:32 -08:00
|
|
|
|
2004-03-14 05:52:01 -08:00
|
|
|
(** Print groff string for a class. *)
|
|
|
|
method man_of_class b c =
|
2002-03-27 08:20:32 -08:00
|
|
|
Odoc_info.reset_type_names () ;
|
2002-04-03 04:56:09 -08:00
|
|
|
let father = Name.father c.cl_name in
|
2004-03-14 05:52:01 -08:00
|
|
|
bs b ".I class ";
|
|
|
|
if c.cl_virtual then bs b "virtual ";
|
2002-03-27 08:20:32 -08:00
|
|
|
(
|
|
|
|
match c.cl_type_parameters with
|
2002-07-23 07:12:03 -07:00
|
|
|
[] -> ()
|
2004-12-03 06:42:09 -08:00
|
|
|
| l ->
|
2006-01-04 08:55:50 -08:00
|
|
|
bs b (Odoc_str.string_of_class_type_param_list l);
|
|
|
|
bs b " "
|
2002-04-03 04:56:09 -08:00
|
|
|
);
|
2004-03-14 05:52:01 -08:00
|
|
|
bs b (Name.simple c.cl_name);
|
|
|
|
bs b " : " ;
|
2004-12-03 06:42:09 -08:00
|
|
|
self#man_of_class_type_expr b father c.cl_type;
|
2004-03-14 05:52:01 -08:00
|
|
|
bs b "\n.sp\n";
|
|
|
|
self#man_of_info b c.cl_info;
|
|
|
|
bs b "\n.sp\n"
|
|
|
|
|
|
|
|
(** Print groff string for a class type. *)
|
|
|
|
method man_of_class_type b ct =
|
2002-03-27 08:20:32 -08:00
|
|
|
Odoc_info.reset_type_names () ;
|
2004-03-14 05:52:01 -08:00
|
|
|
bs b ".I class type ";
|
|
|
|
if ct.clt_virtual then bs b "virtual " ;
|
2002-03-27 08:20:32 -08:00
|
|
|
(
|
|
|
|
match ct.clt_type_parameters with
|
2002-07-23 07:12:03 -07:00
|
|
|
[] -> ()
|
2004-12-03 06:42:09 -08:00
|
|
|
| l ->
|
2006-01-04 08:55:50 -08:00
|
|
|
bs b (Odoc_str.string_of_class_type_param_list l);
|
|
|
|
bs b " "
|
2002-04-03 04:56:09 -08:00
|
|
|
);
|
2004-03-14 05:52:01 -08:00
|
|
|
bs b (Name.simple ct.clt_name);
|
|
|
|
bs b " = " ;
|
|
|
|
self#man_of_class_type_expr b (Name.father ct.clt_name) ct.clt_type;
|
2004-12-03 06:42:09 -08:00
|
|
|
bs b "\n.sp\n";
|
2004-03-14 05:52:01 -08:00
|
|
|
self#man_of_info b ct.clt_info;
|
|
|
|
bs b "\n.sp\n"
|
|
|
|
|
|
|
|
(** Print groff string for a module. *)
|
|
|
|
method man_of_module b m =
|
|
|
|
bs b ".I module ";
|
|
|
|
bs b (Name.simple m.m_name);
|
|
|
|
bs b " : ";
|
|
|
|
self#man_of_module_type b (Name.father m.m_name) m.m_type;
|
|
|
|
bs b "\n.sp\n";
|
|
|
|
self#man_of_info b m.m_info;
|
|
|
|
bs b "\n.sp\n"
|
|
|
|
|
|
|
|
(** Print groff string for a module type. *)
|
|
|
|
method man_of_modtype b mt =
|
|
|
|
bs b ".I module type ";
|
|
|
|
bs b (Name.simple mt.mt_name);
|
|
|
|
bs b " = ";
|
2004-12-03 06:42:09 -08:00
|
|
|
(match mt.mt_type with
|
2004-03-14 05:52:01 -08:00
|
|
|
None -> ()
|
2004-12-03 06:42:09 -08:00
|
|
|
| Some t ->
|
2006-01-04 08:55:50 -08:00
|
|
|
self#man_of_module_type b (Name.father mt.mt_name) t
|
2004-03-14 05:52:01 -08:00
|
|
|
);
|
|
|
|
bs b "\n.sp\n";
|
|
|
|
self#man_of_info b mt.mt_info;
|
|
|
|
bs b "\n.sp\n"
|
|
|
|
|
|
|
|
(** Print groff string for a module comment.*)
|
|
|
|
method man_of_module_comment b text =
|
2008-10-29 06:30:24 -07:00
|
|
|
bs b "\n.PP\n";
|
2004-03-14 05:52:01 -08:00
|
|
|
self#man_of_text b [Code ("=== "^(Odoc_misc.string_of_text text)^" ===")];
|
2008-10-29 06:30:24 -07:00
|
|
|
bs b "\n.PP\n"
|
2004-03-14 05:52:01 -08:00
|
|
|
|
|
|
|
(** Print groff string for a class comment.*)
|
|
|
|
method man_of_class_comment b text =
|
2008-10-29 06:30:24 -07:00
|
|
|
bs b "\n.PP\n";
|
2004-03-14 05:52:01 -08:00
|
|
|
self#man_of_text b [Code ("=== "^(Odoc_misc.string_of_text text)^" ===")];
|
2008-10-29 06:30:24 -07:00
|
|
|
bs b "\n.PP\n"
|
2004-03-14 05:52:01 -08:00
|
|
|
|
2014-05-22 01:35:56 -07:00
|
|
|
method man_of_recfield b modname f =
|
|
|
|
bs b ".I ";
|
|
|
|
if f.rf_mutable then bs b (Odoc_messages.mutab^" ");
|
|
|
|
bs b (f.rf_name^" : ");
|
|
|
|
self#man_of_type_expr b modname f.rf_type;
|
|
|
|
bs b "\n.sp\n";
|
|
|
|
self#man_of_info b f.rf_text;
|
|
|
|
bs b "\n.sp\n"
|
|
|
|
|
|
|
|
method man_of_const b modname c =
|
|
|
|
bs b ".I ";
|
|
|
|
bs b (c.vc_name^" ");
|
|
|
|
(match c.vc_args with
|
2014-10-14 08:51:30 -07:00
|
|
|
| Cstr_tuple [] -> ()
|
|
|
|
| Cstr_tuple (h::q) ->
|
2014-05-22 01:35:56 -07:00
|
|
|
bs b "of ";
|
|
|
|
self#man_of_type_expr b modname h;
|
|
|
|
List.iter
|
|
|
|
(fun ty ->
|
|
|
|
bs b " * ";
|
|
|
|
self#man_of_type_expr b modname ty)
|
|
|
|
q
|
2014-10-14 08:51:30 -07:00
|
|
|
| Cstr_record _ -> bs b "{ ... }"
|
2014-05-22 01:35:56 -07:00
|
|
|
);
|
|
|
|
bs b "\n.sp\n";
|
|
|
|
self#man_of_info b c.vc_text;
|
|
|
|
bs b "\n.sp\n"
|
|
|
|
|
2004-03-14 05:52:01 -08:00
|
|
|
(** Print groff string for an included module. *)
|
|
|
|
method man_of_included_module b m_name im =
|
|
|
|
bs b ".I include ";
|
2002-03-27 08:20:32 -08:00
|
|
|
(
|
|
|
|
match im.im_module with
|
2004-03-14 05:52:01 -08:00
|
|
|
None -> bs b im.im_name
|
2002-03-27 08:20:32 -08:00
|
|
|
| Some mmt ->
|
2004-12-03 06:42:09 -08:00
|
|
|
let name =
|
2002-07-23 07:12:03 -07:00
|
|
|
match mmt with
|
|
|
|
Mod m -> m.m_name
|
|
|
|
| Modtype mt -> mt.mt_name
|
|
|
|
in
|
2004-03-14 05:52:01 -08:00
|
|
|
bs b (self#relative_idents m_name name)
|
|
|
|
);
|
|
|
|
bs b "\n.sp\n";
|
|
|
|
self#man_of_info b im.im_info;
|
|
|
|
bs b "\n.sp\n"
|
2002-03-27 08:20:32 -08:00
|
|
|
|
|
|
|
(** Generate the man page for the given class.*)
|
|
|
|
method generate_for_class cl =
|
|
|
|
Odoc_info.reset_type_names () ;
|
|
|
|
let file = self#file_name cl.cl_name in
|
|
|
|
try
|
2002-07-23 07:12:03 -07:00
|
|
|
let chanout = self#open_out file in
|
2006-01-04 08:55:50 -08:00
|
|
|
let b = new_buf () in
|
|
|
|
bs b (".TH \""^cl.cl_name^"\" ");
|
2010-08-24 02:45:45 -07:00
|
|
|
bs b !man_section ;
|
2015-08-13 02:59:04 -07:00
|
|
|
bs b (" source: "^Odoc_misc.current_date^" ");
|
2004-03-14 05:52:01 -08:00
|
|
|
bs b "OCamldoc ";
|
2010-08-24 02:45:45 -07:00
|
|
|
bs b ("\""^(match !Global.title with Some t -> t | None -> "")^"\"\n");
|
2002-07-23 07:12:03 -07:00
|
|
|
|
2006-01-04 08:55:50 -08:00
|
|
|
let abstract =
|
|
|
|
match cl.cl_info with
|
|
|
|
None | Some { i_desc = None } -> "no description"
|
|
|
|
| Some { i_desc = Some t } ->
|
|
|
|
let s = Odoc_info.string_of_text (Odoc_info.first_sentence_of_text t) in
|
|
|
|
self#remove_newlines s
|
|
|
|
in
|
2002-09-16 03:52:13 -07:00
|
|
|
|
2006-01-04 08:55:50 -08:00
|
|
|
bs b ".SH NAME\n";
|
|
|
|
bs b (cl.cl_name^" \\- "^abstract^"\n");
|
2004-03-14 05:52:01 -08:00
|
|
|
bs b (".SH "^Odoc_messages.clas^"\n");
|
|
|
|
bs b (Odoc_messages.clas^" "^cl.cl_name^"\n");
|
|
|
|
bs b (".SH "^Odoc_messages.documentation^"\n");
|
|
|
|
bs b ".sp\n";
|
|
|
|
self#man_of_class b cl;
|
2002-07-23 07:12:03 -07:00
|
|
|
|
|
|
|
(* parameters *)
|
2004-03-14 05:52:01 -08:00
|
|
|
self#man_of_parameter_list b "" cl.cl_parameters;
|
2002-07-23 07:12:03 -07:00
|
|
|
(* a large blank *)
|
2004-03-14 05:52:01 -08:00
|
|
|
bs b "\n.sp\n.sp\n";
|
2002-03-27 08:20:32 -08:00
|
|
|
|
|
|
|
(*
|
|
|
|
(* class inheritance *)
|
2002-07-23 07:12:03 -07:00
|
|
|
self#generate_class_inheritance_info chanout cl;
|
2002-03-27 08:20:32 -08:00
|
|
|
*)
|
2002-07-23 07:12:03 -07:00
|
|
|
(* the various elements *)
|
2004-12-03 06:42:09 -08:00
|
|
|
List.iter
|
2002-07-23 07:12:03 -07:00
|
|
|
(fun element ->
|
|
|
|
match element with
|
|
|
|
Class_attribute a ->
|
2004-03-14 05:52:01 -08:00
|
|
|
self#man_of_attribute b a
|
2002-07-23 07:12:03 -07:00
|
|
|
| Class_method m ->
|
2004-03-14 05:52:01 -08:00
|
|
|
self#man_of_method b m
|
2002-07-23 07:12:03 -07:00
|
|
|
| Class_comment t ->
|
2004-03-14 05:52:01 -08:00
|
|
|
self#man_of_class_comment b t
|
2002-07-23 07:12:03 -07:00
|
|
|
)
|
|
|
|
(Class.class_elements cl);
|
|
|
|
|
2006-01-04 08:55:50 -08:00
|
|
|
Buffer.output_buffer chanout b;
|
2002-07-23 07:12:03 -07:00
|
|
|
close_out chanout
|
2002-03-27 08:20:32 -08:00
|
|
|
with
|
2002-07-23 07:12:03 -07:00
|
|
|
Sys_error s ->
|
|
|
|
incr Odoc_info.errors ;
|
|
|
|
prerr_endline s
|
2002-03-27 08:20:32 -08:00
|
|
|
|
|
|
|
(** Generate the man page for the given class type.*)
|
|
|
|
method generate_for_class_type ct =
|
|
|
|
Odoc_info.reset_type_names () ;
|
|
|
|
let file = self#file_name ct.clt_name in
|
|
|
|
try
|
2002-07-23 07:12:03 -07:00
|
|
|
let chanout = self#open_out file in
|
2006-01-04 08:55:50 -08:00
|
|
|
let b = new_buf () in
|
|
|
|
bs b (".TH \""^ct.clt_name^"\" ");
|
2010-08-24 02:45:45 -07:00
|
|
|
bs b !man_section ;
|
2015-08-13 02:59:04 -07:00
|
|
|
bs b (" source: "^Odoc_misc.current_date^" ");
|
2004-03-14 05:52:01 -08:00
|
|
|
bs b "OCamldoc ";
|
2010-08-24 02:45:45 -07:00
|
|
|
bs b ("\""^(match !Global.title with Some t -> t | None -> "")^"\"\n");
|
2002-07-23 07:12:03 -07:00
|
|
|
|
2006-01-04 08:55:50 -08:00
|
|
|
let abstract =
|
|
|
|
match ct.clt_info with
|
|
|
|
None | Some { i_desc = None } -> "no description"
|
|
|
|
| Some { i_desc = Some t } ->
|
|
|
|
let s = Odoc_info.string_of_text (Odoc_info.first_sentence_of_text t) in
|
|
|
|
self#remove_newlines s
|
|
|
|
in
|
2002-09-16 03:52:13 -07:00
|
|
|
|
2004-03-14 05:52:01 -08:00
|
|
|
bs b ".SH NAME\n";
|
2006-01-04 08:55:50 -08:00
|
|
|
bs b (ct.clt_name^" \\- "^abstract^"\n");
|
2004-03-14 05:52:01 -08:00
|
|
|
bs b (".SH "^Odoc_messages.class_type^"\n");
|
|
|
|
bs b (Odoc_messages.class_type^" "^ct.clt_name^"\n");
|
|
|
|
bs b (".SH "^Odoc_messages.documentation^"\n");
|
|
|
|
bs b ".sp\n";
|
2004-12-03 06:42:09 -08:00
|
|
|
|
2006-01-04 08:55:50 -08:00
|
|
|
self#man_of_class_type b ct;
|
2002-07-23 07:12:03 -07:00
|
|
|
|
|
|
|
(* a large blank *)
|
2004-03-14 05:52:01 -08:00
|
|
|
bs b "\n.sp\n.sp\n";
|
2002-03-27 08:20:32 -08:00
|
|
|
(*
|
|
|
|
(* class inheritance *)
|
2002-07-23 07:12:03 -07:00
|
|
|
self#generate_class_inheritance_info chanout cl;
|
2002-03-27 08:20:32 -08:00
|
|
|
*)
|
2002-07-23 07:12:03 -07:00
|
|
|
(* the various elements *)
|
2004-12-03 06:42:09 -08:00
|
|
|
List.iter
|
2002-07-23 07:12:03 -07:00
|
|
|
(fun element ->
|
|
|
|
match element with
|
|
|
|
Class_attribute a ->
|
2004-03-14 05:52:01 -08:00
|
|
|
self#man_of_attribute b a
|
2002-07-23 07:12:03 -07:00
|
|
|
| Class_method m ->
|
2004-03-14 05:52:01 -08:00
|
|
|
self#man_of_method b m
|
2002-07-23 07:12:03 -07:00
|
|
|
| Class_comment t ->
|
2004-03-14 05:52:01 -08:00
|
|
|
self#man_of_class_comment b t
|
2002-07-23 07:12:03 -07:00
|
|
|
)
|
|
|
|
(Class.class_type_elements ct);
|
|
|
|
|
2006-01-04 08:55:50 -08:00
|
|
|
Buffer.output_buffer chanout b;
|
2002-07-23 07:12:03 -07:00
|
|
|
close_out chanout
|
2002-03-27 08:20:32 -08:00
|
|
|
with
|
2002-07-23 07:12:03 -07:00
|
|
|
Sys_error s ->
|
|
|
|
incr Odoc_info.errors ;
|
|
|
|
prerr_endline s
|
2002-03-27 08:20:32 -08:00
|
|
|
|
2014-05-22 01:35:56 -07:00
|
|
|
method man_of_module_type_body b mt =
|
|
|
|
self#man_of_info b mt.mt_info;
|
|
|
|
bs b "\n.sp\n";
|
|
|
|
|
|
|
|
(* parameters for functors *)
|
|
|
|
self#man_of_module_parameter_list b "" (Module.module_type_parameters mt);
|
|
|
|
(* a large blank *)
|
|
|
|
bs b "\n.sp\n.sp\n";
|
|
|
|
|
|
|
|
(* module elements *)
|
|
|
|
List.iter
|
|
|
|
(fun ele ->
|
|
|
|
match ele with
|
|
|
|
Element_module m ->
|
|
|
|
self#man_of_module b m
|
|
|
|
| Element_module_type mt ->
|
|
|
|
self#man_of_modtype b mt
|
|
|
|
| Element_included_module im ->
|
|
|
|
self#man_of_included_module b mt.mt_name im
|
|
|
|
| Element_class c ->
|
|
|
|
self#man_of_class b c
|
|
|
|
| Element_class_type ct ->
|
|
|
|
self#man_of_class_type b ct
|
|
|
|
| Element_value v ->
|
|
|
|
self#man_of_value b v
|
|
|
|
| Element_type_extension te ->
|
|
|
|
self#man_of_type_extension b mt.mt_name te
|
|
|
|
| Element_exception e ->
|
|
|
|
self#man_of_exception b e
|
|
|
|
| Element_type t ->
|
|
|
|
self#man_of_type b t
|
|
|
|
| Element_module_comment text ->
|
|
|
|
self#man_of_module_comment b text
|
|
|
|
)
|
|
|
|
(Module.module_type_elements mt);
|
|
|
|
|
2004-12-03 06:42:09 -08:00
|
|
|
(** Generate the man file for the given module type.
|
2002-03-27 08:20:32 -08:00
|
|
|
@raise Failure if an error occurs.*)
|
|
|
|
method generate_for_module_type mt =
|
|
|
|
let file = self#file_name mt.mt_name in
|
|
|
|
try
|
2002-07-23 07:12:03 -07:00
|
|
|
let chanout = self#open_out file in
|
2006-01-04 08:55:50 -08:00
|
|
|
let b = new_buf () in
|
|
|
|
bs b (".TH \""^mt.mt_name^"\" ");
|
2010-08-24 02:45:45 -07:00
|
|
|
bs b !man_section ;
|
2015-08-13 02:59:04 -07:00
|
|
|
bs b (" source: "^Odoc_misc.current_date^" ");
|
2004-03-14 05:52:01 -08:00
|
|
|
bs b "OCamldoc ";
|
2010-08-24 02:45:45 -07:00
|
|
|
bs b ("\""^(match !Global.title with Some t -> t | None -> "")^"\"\n");
|
2002-07-23 07:12:03 -07:00
|
|
|
|
2006-01-04 08:55:50 -08:00
|
|
|
let abstract =
|
|
|
|
match mt.mt_info with
|
|
|
|
None | Some { i_desc = None } -> "no description"
|
|
|
|
| Some { i_desc = Some t } ->
|
|
|
|
let s = Odoc_info.string_of_text (Odoc_info.first_sentence_of_text t) in
|
|
|
|
self#remove_newlines s
|
|
|
|
in
|
|
|
|
bs b ".SH NAME\n";
|
|
|
|
bs b (mt.mt_name^" \\- "^abstract^"\n");
|
2004-03-14 05:52:01 -08:00
|
|
|
bs b (".SH "^Odoc_messages.module_type^"\n");
|
|
|
|
bs b (Odoc_messages.module_type^" "^mt.mt_name^"\n");
|
|
|
|
bs b (".SH "^Odoc_messages.documentation^"\n");
|
|
|
|
bs b ".sp\n";
|
|
|
|
bs b (Odoc_messages.module_type^"\n");
|
|
|
|
bs b (".BI \""^(Name.simple mt.mt_name)^"\"\n");
|
|
|
|
bs b " = ";
|
|
|
|
(
|
2006-01-04 08:55:50 -08:00
|
|
|
match mt.mt_type with
|
2004-03-14 05:52:01 -08:00
|
|
|
None -> ()
|
2004-12-03 06:42:09 -08:00
|
|
|
| Some t ->
|
2006-01-04 08:55:50 -08:00
|
|
|
self#man_of_module_type b (Name.father mt.mt_name) t
|
2004-03-14 05:52:01 -08:00
|
|
|
);
|
|
|
|
bs b "\n.sp\n";
|
2014-05-22 01:35:56 -07:00
|
|
|
self#man_of_module_type_body b mt;
|
2002-07-23 07:12:03 -07:00
|
|
|
|
2006-01-04 08:55:50 -08:00
|
|
|
Buffer.output_buffer chanout b;
|
2002-07-23 07:12:03 -07:00
|
|
|
close_out chanout
|
2002-03-27 08:20:32 -08:00
|
|
|
|
|
|
|
with
|
2002-07-23 07:12:03 -07:00
|
|
|
Sys_error s ->
|
|
|
|
incr Odoc_info.errors ;
|
|
|
|
prerr_endline s
|
2002-03-27 08:20:32 -08:00
|
|
|
|
2014-05-22 01:35:56 -07:00
|
|
|
method man_of_module_body b m =
|
|
|
|
self#man_of_info b m.m_info;
|
|
|
|
bs b "\n.sp\n";
|
|
|
|
|
|
|
|
(* parameters for functors *)
|
|
|
|
self#man_of_module_parameter_list b "" (Module.module_parameters m);
|
|
|
|
(* a large blank *)
|
|
|
|
bs b "\n.sp\n.sp\n";
|
|
|
|
|
|
|
|
(* module elements *)
|
|
|
|
List.iter
|
|
|
|
(fun ele ->
|
|
|
|
match ele with
|
|
|
|
Element_module m ->
|
|
|
|
self#man_of_module b m
|
|
|
|
| Element_module_type mt ->
|
|
|
|
self#man_of_modtype b mt
|
|
|
|
| Element_included_module im ->
|
|
|
|
self#man_of_included_module b m.m_name im
|
|
|
|
| Element_class c ->
|
|
|
|
self#man_of_class b c
|
|
|
|
| Element_class_type ct ->
|
|
|
|
self#man_of_class_type b ct
|
|
|
|
| Element_value v ->
|
|
|
|
self#man_of_value b v
|
|
|
|
| Element_type_extension te ->
|
|
|
|
self#man_of_type_extension b m.m_name te
|
|
|
|
| Element_exception e ->
|
|
|
|
self#man_of_exception b e
|
|
|
|
| Element_type t ->
|
|
|
|
self#man_of_type b t
|
|
|
|
| Element_module_comment text ->
|
|
|
|
self#man_of_module_comment b text
|
|
|
|
)
|
|
|
|
(Module.module_elements m);
|
|
|
|
|
2004-12-03 06:42:09 -08:00
|
|
|
(** Generate the man file for the given module.
|
2002-03-27 08:20:32 -08:00
|
|
|
@raise Failure if an error occurs.*)
|
|
|
|
method generate_for_module m =
|
|
|
|
let file = self#file_name m.m_name in
|
|
|
|
try
|
2002-07-23 07:12:03 -07:00
|
|
|
let chanout = self#open_out file in
|
2006-01-04 08:55:50 -08:00
|
|
|
let b = new_buf () in
|
|
|
|
bs b (".TH \""^m.m_name^"\" ");
|
2010-08-24 02:45:45 -07:00
|
|
|
bs b !man_section ;
|
2015-08-13 02:59:04 -07:00
|
|
|
bs b (" source: "^Odoc_misc.current_date^" ");
|
2004-03-14 05:52:01 -08:00
|
|
|
bs b "OCamldoc ";
|
2010-08-24 02:45:45 -07:00
|
|
|
bs b ("\""^(match !Global.title with Some t -> t | None -> "")^"\"\n");
|
2002-07-23 07:12:03 -07:00
|
|
|
|
2006-01-04 08:55:50 -08:00
|
|
|
let abstract =
|
|
|
|
match m.m_info with
|
|
|
|
None | Some { i_desc = None } -> "no description"
|
|
|
|
| Some { i_desc = Some t } ->
|
|
|
|
let s = Odoc_info.string_of_text (Odoc_info.first_sentence_of_text t) in
|
|
|
|
self#remove_newlines s
|
|
|
|
in
|
2002-09-16 03:52:13 -07:00
|
|
|
|
2006-01-04 08:55:50 -08:00
|
|
|
bs b ".SH NAME\n";
|
|
|
|
bs b (m.m_name^" \\- "^abstract^"\n");
|
2004-03-14 05:52:01 -08:00
|
|
|
bs b (".SH "^Odoc_messages.modul^"\n");
|
|
|
|
bs b (Odoc_messages.modul^" "^m.m_name^"\n");
|
|
|
|
bs b (".SH "^Odoc_messages.documentation^"\n");
|
|
|
|
bs b ".sp\n";
|
|
|
|
bs b (Odoc_messages.modul^"\n");
|
|
|
|
bs b (".BI \""^(Name.simple m.m_name)^"\"\n");
|
|
|
|
bs b " : ";
|
2006-01-04 08:55:50 -08:00
|
|
|
self#man_of_module_type b (Name.father m.m_name) m.m_type;
|
2004-03-14 05:52:01 -08:00
|
|
|
bs b "\n.sp\n";
|
2014-05-22 01:35:56 -07:00
|
|
|
self#man_of_module_body b m;
|
2006-01-04 08:55:50 -08:00
|
|
|
Buffer.output_buffer chanout b;
|
2002-07-23 07:12:03 -07:00
|
|
|
close_out chanout
|
2002-03-27 08:20:32 -08:00
|
|
|
|
|
|
|
with
|
2002-07-23 07:12:03 -07:00
|
|
|
Sys_error s ->
|
|
|
|
raise (Failure s)
|
2002-03-27 08:20:32 -08:00
|
|
|
|
|
|
|
(** Create the groups of elements to generate pages for. *)
|
2014-05-22 01:35:56 -07:00
|
|
|
method create_groups mini module_list =
|
2004-12-03 06:42:09 -08:00
|
|
|
let name res_ele =
|
2002-07-23 07:12:03 -07:00
|
|
|
match res_ele with
|
|
|
|
Res_module m -> m.m_name
|
|
|
|
| Res_module_type mt -> mt.mt_name
|
|
|
|
| Res_class c -> c.cl_name
|
|
|
|
| Res_class_type ct -> ct.clt_name
|
|
|
|
| Res_value v -> Name.simple v.val_name
|
|
|
|
| Res_type t -> Name.simple t.ty_name
|
2014-05-04 16:08:45 -07:00
|
|
|
| Res_extension x -> Name.simple x.xt_name
|
2002-07-23 07:12:03 -07:00
|
|
|
| Res_exception e -> Name.simple e.ex_name
|
|
|
|
| Res_attribute a -> Name.simple a.att_value.val_name
|
|
|
|
| Res_method m -> Name.simple m.met_value.val_name
|
2002-08-08 06:24:05 -07:00
|
|
|
| Res_section _ -> assert false
|
2012-07-26 12:21:54 -07:00
|
|
|
| Res_recfield (_,f) -> f.rf_name
|
|
|
|
| Res_const (_,f) -> f.vc_name
|
2002-03-27 08:20:32 -08:00
|
|
|
in
|
|
|
|
let all_items_pre = Odoc_info.Search.search_by_name module_list (Str.regexp ".*") in
|
2004-12-03 06:42:09 -08:00
|
|
|
let all_items = List.filter
|
2014-05-22 01:35:56 -07:00
|
|
|
(fun r ->
|
|
|
|
match r with
|
|
|
|
Res_section _ -> false
|
|
|
|
| Res_module _ | Res_module_type _
|
|
|
|
| Res_class _ | Res_class_type _ -> true
|
|
|
|
| _ -> not mini
|
|
|
|
)
|
2002-07-23 07:12:03 -07:00
|
|
|
all_items_pre
|
2002-03-27 08:20:32 -08:00
|
|
|
in
|
|
|
|
let sorted_items = List.sort (fun e1 -> fun e2 -> compare (name e1) (name e2)) all_items in
|
2004-12-03 06:42:09 -08:00
|
|
|
let rec f acc1 acc2 l =
|
2002-07-23 07:12:03 -07:00
|
|
|
match l with
|
|
|
|
[] -> acc2 :: acc1
|
|
|
|
| h :: q ->
|
|
|
|
match acc2 with
|
|
|
|
[] -> f acc1 [h] q
|
2004-12-03 06:42:09 -08:00
|
|
|
| h2 :: q2 ->
|
2002-07-23 07:12:03 -07:00
|
|
|
if (name h) = (name h2) then
|
|
|
|
if List.mem h acc2 then
|
|
|
|
f acc1 acc2 q
|
|
|
|
else
|
2004-12-03 06:42:09 -08:00
|
|
|
f acc1 (acc2 @ [h]) q
|
2002-07-23 07:12:03 -07:00
|
|
|
else
|
|
|
|
f (acc2 :: acc1) [h] q
|
2002-03-27 08:20:32 -08:00
|
|
|
in
|
|
|
|
f [] [] sorted_items
|
|
|
|
|
2004-12-03 06:42:09 -08:00
|
|
|
(** Generate a man page for a group of elements with the same name.
|
2002-03-27 08:20:32 -08:00
|
|
|
A group must not be empty.*)
|
|
|
|
method generate_for_group l =
|
2004-12-03 06:42:09 -08:00
|
|
|
let name =
|
|
|
|
Name.simple
|
2002-07-23 07:12:03 -07:00
|
|
|
(
|
|
|
|
match List.hd l with
|
|
|
|
Res_module m -> m.m_name
|
|
|
|
| Res_module_type mt -> mt.mt_name
|
|
|
|
| Res_class c -> c.cl_name
|
|
|
|
| Res_class_type ct -> ct.clt_name
|
|
|
|
| Res_value v -> v.val_name
|
|
|
|
| Res_type t -> t.ty_name
|
2014-05-04 16:08:45 -07:00
|
|
|
| Res_extension x -> x.xt_name
|
2002-07-23 07:12:03 -07:00
|
|
|
| Res_exception e -> e.ex_name
|
|
|
|
| Res_attribute a -> a.att_value.val_name
|
|
|
|
| Res_method m -> m.met_value.val_name
|
2002-08-08 06:24:05 -07:00
|
|
|
| Res_section (s,_) -> s
|
2012-07-26 12:21:54 -07:00
|
|
|
| Res_recfield (_,f) -> f.rf_name
|
|
|
|
| Res_const (_,f) -> f.vc_name
|
2002-07-23 07:12:03 -07:00
|
|
|
)
|
2002-03-27 08:20:32 -08:00
|
|
|
in
|
|
|
|
let file = self#file_name name in
|
|
|
|
try
|
2002-07-23 07:12:03 -07:00
|
|
|
let chanout = self#open_out file in
|
2006-01-04 08:55:50 -08:00
|
|
|
let b = new_buf () in
|
|
|
|
bs b (".TH \""^name^"\" ");
|
2010-08-24 02:45:45 -07:00
|
|
|
bs b !man_section ;
|
2015-08-13 02:59:04 -07:00
|
|
|
bs b (" source: "^Odoc_misc.current_date^" ");
|
2004-03-14 05:52:01 -08:00
|
|
|
bs b "OCamldoc ";
|
2010-08-24 02:45:45 -07:00
|
|
|
bs b ("\""^(match !Global.title with Some t -> t | None -> "")^"\"\n");
|
2006-01-04 08:55:50 -08:00
|
|
|
bs b ".SH NAME\n";
|
|
|
|
bs b (name^" \\- all "^name^" elements\n\n");
|
2002-07-23 07:12:03 -07:00
|
|
|
|
|
|
|
let f ele =
|
|
|
|
match ele with
|
|
|
|
Res_value v ->
|
2004-03-14 05:52:01 -08:00
|
|
|
bs b ("\n.SH "^Odoc_messages.modul^" "^(Name.father v.val_name)^"\n");
|
|
|
|
self#man_of_value b v
|
2002-07-23 07:12:03 -07:00
|
|
|
| Res_type t ->
|
2004-03-14 05:52:01 -08:00
|
|
|
bs b ("\n.SH "^Odoc_messages.modul^" "^(Name.father t.ty_name)^"\n");
|
|
|
|
self#man_of_type b t
|
2014-05-04 16:08:45 -07:00
|
|
|
| Res_extension x ->
|
|
|
|
bs b ("\n.SH "^Odoc_messages.modul^" "^(Name.father x.xt_name)^"\n");
|
|
|
|
self#man_of_type_extension b (Name.father x.xt_name) x.xt_type_extension
|
2002-07-23 07:12:03 -07:00
|
|
|
| Res_exception e ->
|
2004-03-14 05:52:01 -08:00
|
|
|
bs b ("\n.SH "^Odoc_messages.modul^" "^(Name.father e.ex_name)^"\n");
|
|
|
|
self#man_of_exception b e
|
2002-07-23 07:12:03 -07:00
|
|
|
| Res_attribute a ->
|
2004-03-14 05:52:01 -08:00
|
|
|
bs b ("\n.SH "^Odoc_messages.clas^" "^(Name.father a.att_value.val_name)^"\n");
|
|
|
|
self#man_of_attribute b a
|
2002-07-23 07:12:03 -07:00
|
|
|
| Res_method m ->
|
2004-03-14 05:52:01 -08:00
|
|
|
bs b ("\n.SH "^Odoc_messages.clas^" "^(Name.father m.met_value.val_name)^"\n");
|
|
|
|
self#man_of_method b m
|
2002-07-23 07:12:03 -07:00
|
|
|
| Res_class c ->
|
2004-03-14 05:52:01 -08:00
|
|
|
bs b ("\n.SH "^Odoc_messages.modul^" "^(Name.father c.cl_name)^"\n");
|
|
|
|
self#man_of_class b c
|
2002-07-23 07:12:03 -07:00
|
|
|
| Res_class_type ct ->
|
2004-03-14 05:52:01 -08:00
|
|
|
bs b ("\n.SH "^Odoc_messages.modul^" "^(Name.father ct.clt_name)^"\n");
|
|
|
|
self#man_of_class_type b ct
|
2014-05-22 01:35:56 -07:00
|
|
|
| Res_recfield (ty,f) ->
|
|
|
|
bs b ("\n.SH Type "^(ty.ty_name)^"\n");
|
|
|
|
self#man_of_recfield b (Name.father ty.ty_name) f
|
|
|
|
| Res_const (ty,c) ->
|
|
|
|
bs b ("\n.SH Type "^(ty.ty_name)^"\n");
|
|
|
|
self#man_of_const b (Name.father ty.ty_name) c
|
|
|
|
| Res_module m ->
|
|
|
|
if Name.father m.m_name <> "" then
|
|
|
|
begin
|
|
|
|
bs b ("\n.SH "^Odoc_messages.modul^" "^(Name.father m.m_name)^"\n");
|
|
|
|
bs b (Odoc_messages.modul^"\n");
|
|
|
|
bs b (".BI \""^(Name.simple m.m_name)^"\"\n");
|
|
|
|
bs b " : ";
|
|
|
|
self#man_of_module_type b (Name.father m.m_name) m.m_type;
|
|
|
|
end
|
|
|
|
else
|
|
|
|
begin
|
|
|
|
bs b ("\n.SH "^Odoc_messages.modul^" "^m.m_name^"\n");
|
|
|
|
bs b " : ";
|
|
|
|
self#man_of_module_type b (Name.father m.m_name) m.m_type;
|
|
|
|
end;
|
|
|
|
bs b "\n.sp\n";
|
|
|
|
self#man_of_module_body b m
|
|
|
|
|
|
|
|
| Res_module_type mt ->
|
|
|
|
bs b ("\n.SH "^Odoc_messages.modul^" "^(Name.father mt.mt_name)^"\n");
|
|
|
|
bs b (Odoc_messages.module_type^"\n");
|
|
|
|
bs b (".BI \""^(Name.simple mt.mt_name)^"\"\n");
|
|
|
|
bs b " = ";
|
|
|
|
(
|
|
|
|
match mt.mt_type with
|
|
|
|
None -> ()
|
|
|
|
| Some t ->
|
|
|
|
self#man_of_module_type b (Name.father mt.mt_name) t
|
|
|
|
);
|
|
|
|
bs b "\n.sp\n";
|
|
|
|
self#man_of_module_type_body b mt
|
|
|
|
|
|
|
|
| Res_section _ ->
|
2015-10-09 13:41:51 -07:00
|
|
|
(* normaly, we cannot have modules here. *)
|
2002-07-23 07:12:03 -07:00
|
|
|
()
|
|
|
|
in
|
|
|
|
List.iter f l;
|
2006-01-04 08:55:50 -08:00
|
|
|
Buffer.output_buffer chanout b;
|
2002-07-23 07:12:03 -07:00
|
|
|
close_out chanout
|
2002-03-27 08:20:32 -08:00
|
|
|
with
|
2002-07-23 07:12:03 -07:00
|
|
|
Sys_error s ->
|
|
|
|
incr Odoc_info.errors ;
|
|
|
|
prerr_endline s
|
2002-03-27 08:20:32 -08:00
|
|
|
|
|
|
|
(** Generate all the man pages from a module list. *)
|
|
|
|
method generate module_list =
|
2014-08-22 06:45:02 -07:00
|
|
|
let sorted_module_list = List.sort (fun m1 m2 -> compare m1.m_name m2.m_name) module_list in
|
2014-05-22 01:35:56 -07:00
|
|
|
let groups = self#create_groups !man_mini sorted_module_list in
|
2004-12-03 06:42:09 -08:00
|
|
|
let f group =
|
2002-07-23 07:12:03 -07:00
|
|
|
match group with
|
|
|
|
[] ->
|
|
|
|
()
|
|
|
|
| [Res_module m] -> self#generate_for_module m
|
|
|
|
| [Res_module_type mt] -> self#generate_for_module_type mt
|
|
|
|
| [Res_class cl] -> self#generate_for_class cl
|
|
|
|
| [Res_class_type ct] -> self#generate_for_class_type ct
|
2014-05-22 01:35:56 -07:00
|
|
|
| l -> self#generate_for_group l
|
2002-03-27 08:20:32 -08:00
|
|
|
in
|
2004-12-03 06:42:09 -08:00
|
|
|
List.iter f groups
|
2002-03-27 08:20:32 -08:00
|
|
|
end
|
2010-08-24 02:45:45 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
module type Man_generator = module type of Generator
|