Handle use of `#[doc]` in the original source
authorMatt Corallo <git@bluematt.me>
Tue, 25 Apr 2023 20:20:13 +0000 (20:20 +0000)
committerMatt Corallo <git@bluematt.me>
Wed, 26 Apr 2023 00:07:48 +0000 (00:07 +0000)
c-bindings-gen/src/blocks.rs

index 28f30026ed0810ef0263be3a8b4636a234d59b54..e419fe095abb8dd6bd5d6dc3b403090b5b664b82 100644 (file)
@@ -442,7 +442,7 @@ fn writeln_docs_impl<'a, W: std::io::Write, I>(w: &mut W, attrs: &[syn::Attribut
                                match token_iter.next().unwrap() {
                                        TokenTree::Literal(lit) => {
                                                // Drop the first and last chars from lit as they are always "
-                                               let doc = format!("{}", lit);
+                                               let doc = format!("{}", lit).trim().replace("\n", &format!("\n{}//!", prefix));
                                                writeln!(w, "{}//!{}", prefix, &doc[1..doc.len() - 1]).unwrap();
                                        },
                                        _ => unimplemented!(),
@@ -452,7 +452,7 @@ fn writeln_docs_impl<'a, W: std::io::Write, I>(w: &mut W, attrs: &[syn::Attribut
                                match token_iter.next().unwrap() {
                                        TokenTree::Literal(lit) => {
                                                // Drop the first and last chars from lit as they are always "
-                                               let doc = format!("{}", lit);
+                                               let doc = format!("{}", lit).trim().replace("\n", &format!("\n{}///", prefix));
                                                writeln!(w, "{}///{}", prefix, &doc[1..doc.len() - 1]).unwrap();
                                        },
                                        _ => unimplemented!(),