- fun (name, (ret, args, optargs as style), _, _, _, _, _) ->
- pr "static VALUE ruby_guestfs_%s (VALUE gv" name;
+ fun (name, (ret, args, optargs as style), _, flags, _, shortdesc, longdesc) ->
+ (* Generate rdoc. *)
+ if not (List.mem NotInDocs flags); then (
+ let doc = replace_str longdesc "C<guestfs_" "C<g." in
+ let doc =
+ if optargs <> [] then
+ doc ^ "\n\nOptional arguments are supplied in the final hash parameter, which is a hash of the argument name to its value. Pass an empty {} for no optional arguments."
+ else doc in
+ let doc =
+ if List.mem ProtocolLimitWarning flags then
+ doc ^ "\n\n" ^ protocol_limit_warning
+ else doc in
+ let doc =
+ if List.mem DangerWillRobinson flags then
+ doc ^ "\n\n" ^ danger_will_robinson
+ else doc in
+ let doc =
+ match deprecation_notice flags with
+ | None -> doc
+ | Some txt -> doc ^ "\n\n" ^ txt in
+ let doc = pod2text ~width:60 name doc in
+ let doc = String.concat "\n * " doc in
+ let doc = trim doc in
+
+ let args = List.map name_of_argt args in
+ let args = if optargs <> [] then args @ ["{optargs...}"] else args in
+ let args = String.concat ", " args in
+
+ let ret =
+ match ret with
+ | RErr -> "nil"
+ | RBool _ -> "[True|False]"
+ | RInt _ -> "fixnum"
+ | RInt64 _ -> "fixnum"
+ | RConstString _ -> "string"
+ | RConstOptString _ -> "string"
+ | RString _ -> "string"
+ | RBufferOut _ -> "string"
+ | RStruct _
+ | RHashtable _ -> "hash"
+ | RStringList _
+ | RStructList _ -> "list" in
+
+ pr "\
+/*
+ * call-seq:
+ * g.%s(%s) -> %s
+ *
+ * %s
+ *
+ * %s
+ *
+ * (For the C API documentation for this function, see
+ * +guestfs_%s+[http://libguestfs.org/guestfs.3.html#guestfs_%s]).
+ */
+" name args ret shortdesc doc name name
+ );
+
+ (* Generate the function. *)
+ pr "static VALUE\n";
+ pr "ruby_guestfs_%s (VALUE gv" name;