diff options
author | Christian Poveda Ruiz <31802960+pvdrz@users.noreply.github.com> | 2022-11-22 11:25:13 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-22 11:25:13 -0500 |
commit | f160d11d56007fe1b1125d04f0cb31af0b18fc6e (patch) | |
tree | 7b8906d8bf4919c0eab989262f1bad194027ca99 /bindgen/codegen/helpers.rs | |
parent | 34f0bacb7eb72413c9c27684cb01a205ee43037e (diff) |
Add `ParseCallbacks::process_comment` (#2347)
This method can be used to process comments and replace them with whatever the user wants.
Diffstat (limited to 'bindgen/codegen/helpers.rs')
-rw-r--r-- | bindgen/codegen/helpers.rs | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/bindgen/codegen/helpers.rs b/bindgen/codegen/helpers.rs index 5bf36acb..088c7f93 100644 --- a/bindgen/codegen/helpers.rs +++ b/bindgen/codegen/helpers.rs @@ -55,9 +55,11 @@ pub mod attributes { } pub fn doc(comment: String) -> TokenStream { - // NOTE(emilio): By this point comments are already preprocessed and in - // `///` form. Quote turns them into `#[doc]` comments, but oh well. - TokenStream::from_str(&comment).unwrap() + if comment.is_empty() { + quote!() + } else { + quote!(#[doc = #comment]) + } } pub fn link_name(name: &str) -> TokenStream { |