WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-api

[Xen-API] [PATCH] [ocamldoc] Nicer display of types with polymorphic par

To: xen-api <xen-api@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-API] [PATCH] [ocamldoc] Nicer display of types with polymorphic parameters
From: Rob Hoes <rob.hoes@xxxxxxxxxx>
Date: Fri, 4 Dec 2009 13:37:35 +0000
Delivery-date: Fri, 04 Dec 2009 05:37:35 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-api-request@lists.xensource.com?subject=help>
List-id: Discussion of API issues surrounding Xen <xen-api.lists.xensource.com>
List-post: <mailto:xen-api@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-api>, <mailto:xen-api-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-api>, <mailto:xen-api-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-api-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Rob Hoes <rob.hoes@xxxxxxxxxx>
[ocamldoc] Nicer display of types with polymorphic parameters

Signed-off-by: Rob Hoes <rob.hoes@xxxxxxxxxx>

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;
+}

Attachment: doc-better-types
Description: Text document

_______________________________________________
xen-api mailing list
xen-api@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/mailman/listinfo/xen-api
<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-API] [PATCH] [ocamldoc] Nicer display of types with polymorphic parameters, Rob Hoes <=