summaryrefslogtreecommitdiff
path: root/ocamldoc/odoc_info.ml
diff options
context:
space:
mode:
authorMaxence Guesdon <maxence.guesdon@inria.fr>2003-12-21 11:56:56 +0000
committerMaxence Guesdon <maxence.guesdon@inria.fr>2003-12-21 11:56:56 +0000
commit5fbdbc16c69060b029dc2c8d7350a524bc4b733d (patch)
tree6ca3f11960a3410b47caee3afec460d119f87ca6 /ocamldoc/odoc_info.ml
parent750ecaff2c070163bde6954539ce693e46717be8 (diff)
downloadocaml-5fbdbc16c69060b029dc2c8d7350a524bc4b733d.tar.gz
fix in info_string_of_info
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@6035 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'ocamldoc/odoc_info.ml')
-rw-r--r--ocamldoc/odoc_info.ml90
1 files changed, 90 insertions, 0 deletions
diff --git a/ocamldoc/odoc_info.ml b/ocamldoc/odoc_info.ml
index 4e11dfe2ed..ab5210db3f 100644
--- a/ocamldoc/odoc_info.ml
+++ b/ocamldoc/odoc_info.ml
@@ -182,6 +182,96 @@ let text_of_string = Odoc_text.Texter.text_of_string
let text_string_of_text = Odoc_text.Texter.string_of_text
+
+let escape_arobas s =
+ let len = String.length s in
+ let b = Buffer.create len in
+ for i = 0 to len - 1 do
+ match s.[i] with
+ '@' -> Buffer.add_string b "\\@"
+ | c -> Buffer.add_char b c
+ done;
+ Buffer.contents b
+
+let info_string_of_info i =
+ let b = Buffer.create 256 in
+ let p = Printf.bprintf in
+ (
+ match i.i_desc with
+ None -> ()
+ | Some t -> p b "%s" (escape_arobas (text_string_of_text t))
+ );
+ List.iter
+ (fun s -> p b "\n@author %s" (escape_arobas s))
+ i.i_authors;
+ (
+ match i.i_version with
+ None -> ()
+ | Some s -> p b "\n@version %s" (escape_arobas s)
+ );
+ (
+ (* TODO: escape characters ? *)
+ let f_see_ref = function
+ See_url s -> Printf.sprintf "<%s>" s
+ | See_file s -> Printf.sprintf "'%s'" s
+ | See_doc s -> Printf.sprintf "\"%s\"" s
+ in
+ List.iter
+ (fun (sref, t) ->
+ p b "\n@see %s %s"
+ (escape_arobas (f_see_ref sref))
+ (escape_arobas (text_string_of_text t))
+ )
+ i.i_sees
+ );
+ (
+ match i.i_since with
+ None -> ()
+ | Some s -> p b "\n@since %s" (escape_arobas s)
+ );
+ (
+ match i.i_deprecated with
+ None -> ()
+ | Some t ->
+ p b "\n@deprecated %s"
+ (escape_arobas (text_string_of_text t))
+ );
+ List.iter
+ (fun (s, t) ->
+ p b "\n@param %s %s"
+ (escape_arobas s)
+ (escape_arobas (text_string_of_text t))
+ )
+ i.i_params;
+ List.iter
+ (fun (s, t) ->
+ p b "\n@raise %s %s"
+ (escape_arobas s)
+ (escape_arobas (text_string_of_text t))
+ )
+ i.i_raised_exceptions;
+ (
+ match i.i_return_value with
+ None -> ()
+ | Some t ->
+ p b "\n@return %s"
+ (escape_arobas (text_string_of_text t))
+ );
+ List.iter
+ (fun (s, t) ->
+ p b "\n@%s %s" s
+ (escape_arobas (text_string_of_text t))
+ )
+ i.i_raised_exceptions;
+ List.iter
+ (fun (s, t) ->
+ p b "\n@%s %s" s
+ (escape_arobas (text_string_of_text t))
+ )
+ i.i_custom;
+
+ Buffer.contents b
+
let info_of_string s =
let dummy =
{