[Libguestfs] [PATCH 1/2] Rust bindings: Add long description

Hiroyuki Katsura hiroyuki.katsura.0513 at gmail.com
Tue Aug 13 04:04:27 UTC 2019


`cargo doc` will generate docs with long descriptions.

I did not add the settings of outputting these docs to `/website`.
This is because
 - by publishing this crate to crates.io, users can see the docs in
 `docs.rs` like `https://docs.rs/guestfs/<version>/guestfs/`. It is easy
 to hold multiple documents corresponding to each version.
 - the style of the documents generated by `cargo doc` is far different
 from the documents which already exist.
---
 generator/rust.ml | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/generator/rust.ml b/generator/rust.ml
index 1f5cefa62..f62205185 100644
--- a/generator/rust.ml
+++ b/generator/rust.ml
@@ -52,6 +52,13 @@ let translate_bad_symbols s =
   else
     s

+(* output longdesc to the rust file *)
+let pr_longdesc name longdesc =
+  (* Lines should be at most 100 characters *)
+  (* And Each line begins with '    /// ' *)
+  let l = pod2text ~width:92 name longdesc in
+  List.iter (pr "    /// %s\n") l
+
 let generate_rust () =
   generate_header ~copyrights CStyle LGPLv2plus;

@@ -398,6 +405,8 @@ extern \"C\" {
           style = (ret, args, optargs) } as f) ->
       let cname = snake2caml name in
       pr "    /// %s\n" shortdesc;
+      pr "    ///\n";
+      pr_longdesc name longdesc;
       pr "    #[allow(non_snake_case)]\n";
       pr "    pub fn %s" name;

--
2.20.1 (Apple Git-117)




More information about the Libguestfs mailing list