# HG changeset patch
# User Rob Hoes <[email protected]>
[ocamldoc] Nicer display of types with polymorphic parameters

Signed-off-by: Rob Hoes <[email protected]>

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] = '<span class="type">' + params[i] + 
'</span>';
+                       u = params[i];
+                       if (u[0] == '?')
+                               optional = ' <span 
class="optional">(optional)</span>';
+                       else
+                               optional = '';
+                       a = u.indexOf(':');
+                       if (a > -1)
+                               u = u.substr(a + 1);
+                       params[i] = '<span class="type">' + u + optional + 
'</span>';
                }
                html = params.join('<span class="arrow">\u2192</span>');
+               // 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;
+}
# HG changeset patch
# User Rob Hoes <[email protected]>
[ocamldoc] Nicer display of types with polymorphic parameters

Signed-off-by: Rob Hoes <[email protected]>

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] = '<span class="type">' + params[i] + 
'</span>';
+                       u = params[i];
+                       if (u[0] == '?')
+                               optional = ' <span 
class="optional">(optional)</span>';
+                       else
+                               optional = '';
+                       a = u.indexOf(':');
+                       if (a > -1)
+                               u = u.substr(a + 1);
+                       params[i] = '<span class="type">' + u + optional + 
'</span>';
                }
                html = params.join('<span class="arrow">\u2192</span>');
+               // 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;
+}
_______________________________________________
xen-api mailing list
[email protected]
http://lists.xensource.com/mailman/listinfo/xen-api

Reply via email to