Skip to content

Commit 2d9479a

Browse files
committed
Add documentation and make matchers more flexible
1 parent e357682 commit 2d9479a

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

src/macros.rs

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,30 @@ pub use syn::{parse, parse_str, DeriveInput};
5050
/// decl_derive!([Interesting, attributes(interesting_ignore)] => derive_interesting);
5151
/// # };
5252
/// ```
53+
///
54+
/// ### Decl Attributes & Doc Comments
55+
/// ```
56+
/// # fn main() {}
57+
/// fn derive_interesting(_input: synstructure::Structure) -> proc_macro2::TokenStream {
58+
/// quote::quote! { ... }
59+
/// }
60+
///
61+
/// # const _IGNORE: &'static str = stringify! {
62+
/// decl_derive! {
63+
/// [Interesting] =>
64+
/// #[allow(some_lint)]
65+
/// /// Documentation Comments
66+
/// derive_interesting
67+
/// }
68+
/// # };
69+
/// ```
5370
#[macro_export]
5471
macro_rules! decl_derive {
5572
// XXX: Switch to using this variant everywhere?
56-
([$derives:ident $($derive_t:tt)*] => $(#[$attrs:meta])* $inner:path) => {
73+
([$derives:ident $($derive_t:tt)*] => $(#[$($attrs:tt)*])* $inner:path) => {
5774
#[proc_macro_derive($derives $($derive_t)*)]
5875
#[allow(non_snake_case)]
59-
$(#[$attrs])*
76+
$(#[$($attrs)*])*
6077
pub fn $derives(
6178
i: $crate::macros::TokenStream
6279
) -> $crate::macros::TokenStream {
@@ -102,12 +119,11 @@ macro_rules! decl_derive {
102119
/// decl_attribute!([interesting] => attribute_interesting);
103120
/// # };
104121
/// ```
105-
/// ```
106122
#[macro_export]
107123
macro_rules! decl_attribute {
108-
([$attribute:ident] => $(#[$attrs:meta])* $inner:path) => {
124+
([$attribute:ident] => $(#[$($attrs:tt)*])* $inner:path) => {
109125
#[proc_macro_attribute]
110-
$(#[$attrs])*
126+
$(#[$($attrs)*])*
111127
pub fn $attribute(
112128
attr: $crate::macros::TokenStream,
113129
i: $crate::macros::TokenStream,

0 commit comments

Comments
 (0)