# HG changeset patch # User Rob Hoes [ocamldoc] Nicer display of types with polymorphic parameters Signed-off-by: Rob Hoes diff -r a0e8f6224d87 ocaml/doc/ocamldoc.js --- a/ocaml/doc/ocamldoc.js Thu Dec 03 10:10:16 2009 +0000 +++ b/ocaml/doc/ocamldoc.js Fri Dec 04 13:37:13 2009 +0000 @@ -149,9 +149,22 @@ if (t != '') { params = t.split('->'); for (i in params) { - params[i] = '' + params[i] + ''; + u = params[i]; + if (u[0] == '?') + optional = ' (optional)'; + else + optional = ''; + a = u.indexOf(':'); + if (a > -1) + u = u.substr(a + 1); + params[i] = '' + u + optional + ''; } html = params.join('\u2192'); + // the following is obviously a bit inefficient... + for (i = 0; i < 25; i++) + html = html.replaceAll("'" + String.fromCharCode(0x61 + i), + String.fromCharCode(0x3b1 + i)); + html = html.replaceAll('*', '\u00d7'); } else html = '[none]'; diff -r a0e8f6224d87 ocaml/doc/odoc_json.ml --- a/ocaml/doc/odoc_json.ml Thu Dec 03 10:10:16 2009 +0000 +++ b/ocaml/doc/odoc_json.ml Fri Dec 04 13:37:13 2009 +0000 @@ -393,9 +393,13 @@ Object (name :: loc :: info :: params :: kind :: manifest @ []) (* @ code *) method json_of_type_parameter (texp, covar, contravar) = - Object ["covariant", String (string_of_bool covar); "contravariant", String (string_of_bool contravar); "type", self#json_of_type_expr texp] + Object ["covariant", String (string_of_bool covar); "contravariant", String (string_of_bool contravar); "type", self#json_of_type_expr_param texp] method json_of_type_expr t = + Odoc_info.reset_type_names (); + String (Odoc_info.string_of_type_expr t) + + method json_of_type_expr_param t = String (Odoc_info.string_of_type_expr t) method json_of_type_kind priv = function diff -r a0e8f6224d87 ocaml/doc/style.css --- a/ocaml/doc/style.css Thu Dec 03 10:10:16 2009 +0000 +++ b/ocaml/doc/style.css Fri Dec 04 13:37:13 2009 +0000 @@ -267,3 +267,7 @@ color: #cc6600; } +.optional { + font-size: 70%; + vertical-align: top; +}