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

Hiroyuki Katsura hiroyuki.katsura.0513 at gmail.com
Sun Aug 11 04:42:21 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 | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/generator/rust.ml b/generator/rust.ml
index 1f5cefa62..3a07c3b53 100644
--- a/generator/rust.ml
+++ b/generator/rust.ml
@@ -52,6 +52,14 @@ let translate_bad_symbols s =
   else
     s
 
+(* output longdesc to the rust file *)
+let pr_longdesc name longdesc indent_depth =
+  let l = pod2text name longdesc in
+  List.iter (fun x ->
+      indent indent_depth;
+      pr "/// %s\n" x;
+    ) l
+
 let generate_rust () =
   generate_header ~copyrights CStyle LGPLv2plus;
 
@@ -398,6 +406,8 @@ extern \"C\" {
           style = (ret, args, optargs) } as f) ->
       let cname = snake2caml name in
       pr "    /// %s\n" shortdesc;
+      pr "    ///\n";
+      pr_longdesc name longdesc 1;
       pr "    #[allow(non_snake_case)]\n";
       pr "    pub fn %s" name;
 
-- 
2.20.1 (Apple Git-117)




More information about the Libguestfs mailing list