mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-21 22:53:37 +00:00
generator: Change optgroups so second element is a list of functions.
Before this commit it was a list of function names (ie. strings) making it hard if you wanted to get back to the original function definition.
This commit is contained in:
@@ -360,11 +360,11 @@ and generate_availability_pod () =
|
||||
pr "=over 4\n";
|
||||
pr "\n";
|
||||
List.iter (
|
||||
fun (group, functions) ->
|
||||
fun (group, fns) ->
|
||||
pr "=item B<%s>\n" group;
|
||||
pr "\n";
|
||||
pr "The following functions:\n";
|
||||
List.iter (pr "L</guestfs_%s>\n") functions;
|
||||
List.iter (pr "L</guestfs_%s>\n") (List.map (fun { name = n } -> n) fns);
|
||||
pr "\n"
|
||||
) optgroups;
|
||||
pr "=back\n";
|
||||
|
||||
@@ -26,14 +26,19 @@ let optgroups =
|
||||
let h = Hashtbl.create 13 in
|
||||
List.iter (
|
||||
function
|
||||
| { name = name; optional = Some group } ->
|
||||
let names = try Hashtbl.find h group with Not_found -> [] in
|
||||
Hashtbl.replace h group (name :: names)
|
||||
| { optional = Some group } as fn ->
|
||||
let fns = try Hashtbl.find h group with Not_found -> [] in
|
||||
Hashtbl.replace h group (fn :: fns)
|
||||
| _ -> ()
|
||||
) daemon_functions;
|
||||
let groups = Hashtbl.fold (fun k _ ks -> k :: ks) h [] in
|
||||
let groups =
|
||||
List.map (
|
||||
fun group -> group, List.sort compare (Hashtbl.find h group)
|
||||
fun group ->
|
||||
(* Ensure the functions are sorted on the name field. *)
|
||||
let fns = Hashtbl.find h group in
|
||||
let cmp { name = n1 } { name = n2 } = compare n1 n2 in
|
||||
let fns = List.sort cmp fns in
|
||||
group, fns
|
||||
) groups in
|
||||
List.sort (fun x y -> compare (fst x) (fst y)) groups
|
||||
|
||||
Reference in New Issue
Block a user