[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-API] [PATCH 3 of 5] HTML API docs: Display namespace changes in release notes


  • To: xen-api@xxxxxxxxxxxxxxxxxxx
  • From: Rob Hoes <rob.hoes@xxxxxxxxxx>
  • Date: Fri, 18 Jun 2010 14:07:57 +0100
  • Delivery-date: Fri, 18 Jun 2010 06:17:55 -0700
  • List-id: Discussion of API issues surrounding Xen <xen-api.lists.xensource.com>

 ocaml/doc/jsapi.ml |  61 +++++++++++++++++++++--------------------------------
 1 files changed, 24 insertions(+), 37 deletions(-)


# HG changeset patch
# User Rob Hoes <rob.hoes@xxxxxxxxxx>
# Date 1276866461 -3600
# Node ID 537aeec5ad8343195185697d4d68113ddc48f11c
# Parent  27da7dd543d2f12de21015ebba468bd4e5ed2af6
HTML API docs: Display namespace changes in release notes

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

diff -r 27da7dd543d2 -r 537aeec5ad83 ocaml/doc/jsapi.ml
--- a/ocaml/doc/jsapi.ml
+++ b/ocaml/doc/jsapi.ml
@@ -19,30 +19,6 @@
 and changes_t = change_t list
 with rpc
 
-let obj_change_in_release rel o =
-       let rec find_rel rel = function
-               | [] -> None
-               | (transition, release, doc) :: tl when release = rel -> Some 
(transition, o.name, doc)
-               | _ :: tl -> find_rel rel tl
-       in
-       find_rel rel o.obj_lifecycle
-       
-let msg_change_in_release rel m =
-       let rec find_rel rel = function
-               | [] -> None
-               | (transition, release, doc) :: tl when release = rel -> Some 
(transition, m.msg_name, doc)
-               | _ :: tl -> find_rel rel tl
-       in
-       find_rel rel m.msg_lifecycle
-
-let field_change_in_release rel f =
-       let rec find_rel rel = function
-               | [] -> None
-               | (transition, release, doc) :: tl when release = rel -> Some 
(transition, f.field_name, doc)
-               | _ :: tl -> find_rel rel tl
-       in
-       find_rel rel f.lifecycle
-       
 let _ =
        let api = (Datamodel.all_api) in
        let objs = Dm_api.objects_of_api api in
@@ -56,27 +32,38 @@
        let class_list = String.concat ", " (List.map (fun s -> "'" ^ s ^ "'") 
names) in
        Unixext.write_string_to_file "api/index.json" ("classes = [" ^ 
class_list ^ "]");
        
-       let new_in_release rel =
+       let changes_in_release rel =
                let search_obj obj =
+                       let changes = List.filter (fun (transition, release, 
doc) -> release = rel) obj.obj_lifecycle in
                        let obj_changes : changes_t = 
-                               match obj_change_in_release rel obj with
-                               | None -> []
-                               | Some x -> [x]
+                               List.map (fun (transition, release, doc) -> 
(transition, obj.name, doc)) changes in
+                       
+                       let changes_for_msg m =
+                               let changes = List.filter (fun (transition, 
release, doc) -> release = rel) m.msg_lifecycle in
+                               List.map (fun (transition, release, doc) -> 
(transition, m.msg_name, doc)) changes
                        in
-                               
                        let msgs = List.filter (fun m -> not 
m.msg_hide_from_docs) obj.messages in
-                       let msg_changes : changes_t = List.fold_left
-                               (fun l m -> match msg_change_in_release rel m 
with None -> l | Some x -> x :: l) [] msgs in
-                               
-                       let flds = List.filter (function Field f -> true | _ -> 
false) obj.contents in
-                       let field_changes : changes_t = List.fold_left
-                               (fun l (Field f) -> match 
field_change_in_release rel f with None -> l | Some x -> x :: l) [] flds in
-                               
+                       let msg_changes : changes_t = List.fold_left (fun l m 
-> l @ (changes_for_msg m)) [] msgs in
+                       
+                       let changes_for_field f =
+                               let changes = List.filter (fun (transition, 
release, doc) -> release = rel) f.lifecycle in
+                               let field_name = String.concat "_" f.full_name 
in
+                               List.map (fun (transition, release, doc) -> 
(transition, field_name, doc)) changes
+                       in
+                       let rec flatten_contents contents =
+                               List.fold_left (fun l -> function
+                                       | Field f -> f :: l
+                                       | Namespace (name, contents) -> 
flatten_contents contents @ l
+                               ) [] contents
+                       in
+                       let fields = flatten_contents obj.contents in
+                       let field_changes : changes_t = List.fold_left (fun l f 
-> l @ (changes_for_field f)) [] fields in
+                       
                        "{'cls': '" ^ obj.name ^ "', 'obj_changes': " ^ 
Jsonrpc.to_string (rpc_of_changes_t obj_changes) ^ ", 'field_changes': " ^ 
Jsonrpc.to_string (rpc_of_changes_t field_changes) ^ ", 'msg_changes': " ^ 
Jsonrpc.to_string (rpc_of_changes_t msg_changes) ^ "}"
                in
                let release_info = String.concat ", " (List.map search_obj 
objs) in
                Unixext.write_string_to_file ("api/" ^ rel ^ ".json") 
("release_info = [" ^ release_info ^ "]")
        in
-       List.iter new_in_release release_order;
+       List.iter changes_in_release release_order;
        let release_list = String.concat ", " (List.map (fun s -> "'" ^ s ^ 
"'") release_order) in
        Unixext.write_string_to_file "api/releases.json" ("releases = [" ^ 
release_list ^ "]");
_______________________________________________
xen-api mailing list
xen-api@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/mailman/listinfo/xen-api

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.