Skip to content

Commit 3fad038

Browse files
committed
OK - fix: useless parenthesis around agruments of arguments of a type constructor in
type definitions, and aournd arguments of exceptions in exception definitions. OK - fix: blank lines in verbatim, latex, code pre, code and ele ref modes are now accepted git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@6162 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
1 parent 27181b4 commit 3fad038

10 files changed

+62
-43
lines changed

ocamldoc/Changes.txt

+24-18
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,23 @@
11
Current :
2-
OK - add: new option -customdir
2+
OK - fix: useless parenthesis around agruments of arguments of a type constructor in
3+
type definitions, and aournd arguments of exceptions in exception definitions.
4+
OK - fix: blank lines in verbatim, latex, code pre, code and ele ref modes
5+
are now accepted
6+
OK - fix: html generator: included module names were displayed with their simple
7+
name rather than their fully qualified name
8+
OK - fix: use a formatter from a buffer rather Format.str_formatter in
9+
Odoc_mist.sting_of_module_type, to avoid too much blanks
10+
OK - new module odoc_print, will work when Format.pp_print_flush is fixed
11+
OK - odoc_html: use buffers instead of string concatenation
12+
OK - odoc_man: use buffers instead of string concatenation
13+
OK - odoc_cross.ml: use hash tables modified on the fly to resolve
14+
(module | module type | exception) name aliases
15+
OK - odoc_html: replace some calls to Str. by specific functions on strings
16+
OK - odoc_cross.ml: use a Map to associate a complete name to
17+
the known elements with this name, instead of searching each time
18+
through the whole list of modules -> a gain of more than 90% in speed
19+
for cross-referecing (Odoc_cross.associate)
20+
OK - fix: Odoc_name.cut printed a '(' instead of a '.' OK - add: new option -customdir
321
OK - add: new option -i (to add a path to the directory where
422
to look for custom generators)
523
OK - add: add odoc_config.ml{,i}
@@ -20,23 +38,11 @@ OK - add: field m_code for modules, to keep the code of top modules
2038
OK - fix: display "include Foo" instead of "include module Foo" in Latex, Man, Texi
2139
OK - fix: not display comments associated to include directives
2240
OK - fix: bad display of type parameters for class and class types
23-
- need to fix display of type parameters for inherited classes/class types
24-
OK - fix: html generator: included module names were displayed with their simple
25-
name rather than their fully qualified name
26-
OK - fix: use a formatter from a buffer rather Format.str_formatter in
27-
Odoc_mist.sting_of_module_type, to avoid too much blanks
28-
OK - new module odoc_print, will work when Format.pp_print_flush is fixed
29-
- odoc_html: use buffers instead of string concatenation
30-
OK - odoc_man: use buffers instead of string concatenation
31-
- odoc_latex: use buffers instead of string concatenation
32-
OK - odoc_cross.ml: use hash tables modified on the fly to resolve
33-
(module | module type | exception) name aliases
34-
OK - odoc_html: replace some calls to Str. by specific functions on strings
35-
OK - odoc_cross.ml: use a Map to associate a complete name to
36-
the known elements with this name, instead of searching each time
37-
through the whole list of modules -> a gain of more than 90% in speed
38-
for cross-referecing (Odoc_cross.associate)
39-
OK - fix: Odoc_name.cut printed a '(' instead of a '.'
41+
42+
TODO:
43+
- need to fix display of type parameters for inherited classes/class types
44+
- odoc_latex: use buffers instead of string concatenation
45+
4046

4147

4248
======

ocamldoc/odoc_html.ml

+5-4
Original file line numberDiff line numberDiff line change
@@ -994,9 +994,9 @@ class html =
994994
bs b "</code>"
995995

996996
(** Print html code to display a [Types.type_expr list]. *)
997-
method html_of_type_expr_list b m_name sep l =
997+
method html_of_type_expr_list ?par b m_name sep l =
998998
print_DEBUG "html#html_of_type_expr_list";
999-
let s = Odoc_info.string_of_type_list sep l in
999+
let s = Odoc_info.string_of_type_list ?par sep l in
10001000
print_DEBUG "html#html_of_type_expr_list: 1";
10011001
let s2 = newline_to_indented_br s in
10021002
print_DEBUG "html#html_of_type_expr_list: 2";
@@ -1081,7 +1081,8 @@ class html =
10811081
[] -> ()
10821082
| _ ->
10831083
bs b (" "^(self#keyword "of")^" ");
1084-
self#html_of_type_expr_list b (Name.father e.ex_name) " * " e.ex_args
1084+
self#html_of_type_expr_list
1085+
~par: false b (Name.father e.ex_name) " * " e.ex_args
10851086
);
10861087
(
10871088
match e.ex_alias with
@@ -1149,7 +1150,7 @@ class html =
11491150
[] -> ()
11501151
| l ->
11511152
bs b (" " ^ (self#keyword "of") ^ " ");
1152-
self#html_of_type_expr_list b father " * " l;
1153+
self#html_of_type_expr_list ~par: false b father " * " l;
11531154
);
11541155
bs b "</code></td>\n";
11551156
(

ocamldoc/odoc_info.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ let string_of_variance t (co,cn) = Odoc_str.string_of_variance t (co, cn)
117117

118118
let string_of_type_expr t = Odoc_print.string_of_type_expr t
119119

120-
let string_of_type_list sep type_list = Odoc_str.string_of_type_list sep type_list
120+
let string_of_type_list ?par sep type_list = Odoc_str.string_of_type_list ?par sep type_list
121121

122122
let string_of_type_param_list t = Odoc_str.string_of_type_param_list t
123123

ocamldoc/odoc_info.mli

+2-2
Original file line numberDiff line numberDiff line change
@@ -618,15 +618,15 @@ val string_of_type_expr : Types.type_expr -> string
618618

619619
(** This function returns a string to represent the given list of types,
620620
with a given separator. *)
621-
val string_of_type_list : string -> Types.type_expr list -> string
621+
val string_of_type_list : ?par: bool -> string -> Types.type_expr list -> string
622622

623623
(** This function returns a string to represent the list of type parameters
624624
for the given type. *)
625625
val string_of_type_param_list : Type.t_type -> string
626626

627627
(** This function returns a string to represent the given list of
628628
type parameters of a class or class type,
629-
with a given separator. It writes in and flushes [Format.str_formatter].*)
629+
with a given separator. *)
630630
val string_of_class_type_param_list : Types.type_expr list -> string
631631

632632
(** This function returns a string representing a [Types.module_type].

ocamldoc/odoc_latex.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ class latex =
447447
| l ->
448448
Format.fprintf Format.str_formatter " %s@ %s"
449449
"of"
450-
(self#normal_type_list mod_name " * " l)
450+
(self#normal_type_list ~par: false mod_name " * " l)
451451
);
452452
Format.flush_str_formatter ()
453453
in

ocamldoc/odoc_man.ml

+7-5
Original file line numberDiff line numberDiff line change
@@ -311,8 +311,8 @@ class man =
311311
bs b "\n"
312312

313313
(** Print groff string to display a [Types.type_expr list].*)
314-
method man_of_type_expr_list b m_name sep l =
315-
let s = Odoc_str.string_of_type_list sep l in
314+
method man_of_type_expr_list ?par b m_name sep l =
315+
let s = Odoc_str.string_of_type_list ?par sep l in
316316
let s2 = Str.global_replace (Str.regexp "\n") "\n.B " s in
317317
bs b "\n.B ";
318318
bs b (self#relative_idents m_name s2);
@@ -361,7 +361,9 @@ class man =
361361
[] -> ()
362362
| _ ->
363363
bs b ".B of ";
364-
self#man_of_type_expr_list b (Name.father e.ex_name) " * " e.ex_args
364+
self#man_of_type_expr_list
365+
~par: false
366+
b (Name.father e.ex_name) " * " e.ex_args
365367
);
366368
(
367369
match e.ex_alias with
@@ -418,11 +420,11 @@ class man =
418420
bs b " *)\n "
419421
| l, None ->
420422
bs b "\n.B of ";
421-
self#man_of_type_expr_list b father " * " l;
423+
self#man_of_type_expr_list ~par: false b father " * " l;
422424
bs b " "
423425
| l, (Some t) ->
424426
bs b "\n.B of ";
425-
self#man_of_type_expr_list b father " * " l;
427+
self#man_of_type_expr_list ~par: false b father " * " l;
426428
bs b ".I \" \"\n";
427429
bs b "(* ";
428430
self#man_of_text b t;

ocamldoc/odoc_str.ml

+7-4
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,14 @@ let raw_string_of_type_list sep type_list =
6969
Format.pp_print_flush fmt ();
7070
Buffer.contents buf
7171

72-
let string_of_type_list sep type_list =
72+
let string_of_type_list ?par sep type_list =
7373
let par =
74-
match type_list with
75-
[] | [_] -> false
76-
| _ -> true
74+
match par with
75+
| Some b -> b
76+
| None ->
77+
match type_list with
78+
[] | [_] -> false
79+
| _ -> true
7780
in
7881
Printf.sprintf "%s%s%s"
7982
(if par then "(" else "")

ocamldoc/odoc_str.mli

+6-4
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,18 @@
1717
val string_of_variance : Odoc_type.t_type -> (bool * bool) -> string
1818

1919
(** This function returns a string to represent the given list of types,
20-
with a given separator. It writes in and flushes [Format.str_formatter].*)
21-
val string_of_type_list : string -> Types.type_expr list -> string
20+
with a given separator.
21+
@param par can be used to force the addition or not of parentheses around the returned string.
22+
*)
23+
val string_of_type_list : ?par: bool -> string -> Types.type_expr list -> string
2224

2325
(** This function returns a string to represent the list of type parameters
24-
for the given type. It writes in and flushes [Format.str_formatter].*)
26+
for the given type. *)
2527
val string_of_type_param_list : Odoc_type.t_type -> string
2628

2729
(** This function returns a string to represent the given list of
2830
type parameters of a class or class type,
29-
with a given separator. It writes in and flushes [Format.str_formatter].*)
31+
with a given separator. *)
3032
val string_of_class_type_param_list : Types.type_expr list -> string
3133

3234
(** @return a string to describe the given type. *)

ocamldoc/odoc_text_lexer.mll

+4-1
Original file line numberDiff line numberDiff line change
@@ -708,7 +708,10 @@ rule main = parse
708708
END_SHORTCUT_LIST
709709
)
710710
else
711-
BLANK_LINE
711+
if !latex_mode or (!open_brackets >= 1) or !code_pre_mode or !ele_ref_mode or !verb_mode then
712+
Char (Lexing.lexeme lexbuf)
713+
else
714+
BLANK_LINE
712715
}
713716

714717
| eof { EOF }

ocamldoc/odoc_to_text.ml

+5-3
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,8 @@ class virtual to_text =
201201
(self#relative_idents m_name (Odoc_info.string_of_type_expr t))
202202

203203
(** Get a string for a list of types where all idents are relative. *)
204-
method normal_type_list m_name sep t =
205-
(self#relative_idents m_name (Odoc_info.string_of_type_list sep t))
204+
method normal_type_list ?par m_name sep t =
205+
(self#relative_idents m_name (Odoc_info.string_of_type_list ?par sep t))
206206

207207
(** Get a string for a list of class or class type type parameters
208208
where all idents are relative. *)
@@ -296,7 +296,9 @@ class virtual to_text =
296296
| _ ->
297297
Format.fprintf Format.str_formatter "@ of "
298298
);
299-
let s = self#normal_type_list (Name.father e.ex_name) " * " e.ex_args in
299+
let s = self#normal_type_list
300+
~par: false (Name.father e.ex_name) " * " e.ex_args
301+
in
300302
let s2 =
301303
Format.fprintf Format.str_formatter "%s" s ;
302304
(match e.ex_alias with

0 commit comments

Comments
 (0)