diff --git a/bok-macro/Cargo.toml b/bok-macro/Cargo.toml index a7d7dbb..cf16946 100644 --- a/bok-macro/Cargo.toml +++ b/bok-macro/Cargo.toml @@ -13,7 +13,7 @@ categories = [ "config" ] proc-macro = true [dependencies] -syn = { version = "2.0", features = [ "full" ] } +syn = { version = "2.0", features = [ "full", "extra-traits" ] } quote = { version = "1.0" } proc-macro2 = "1.0" macro_magic = { version = "0.5", features = [ "proc_support" ] } diff --git a/bok-macro/src/repos.rs b/bok-macro/src/repos.rs index c99a8d5..4431ee3 100644 --- a/bok-macro/src/repos.rs +++ b/bok-macro/src/repos.rs @@ -102,17 +102,43 @@ pub(crate) fn repository( }; let local_attrs = local.attrs.iter().filter(|&x| { - // don't export the same thing multiple times - if let ::syn::Meta::Path(p) = &x.meta { - if p.segments.len() == 2 - && p.segments[0].ident == "macro_magic" - && p.segments[1].ident == "export_tokens" - { - return false; + match &x.meta { + ::syn::Meta::Path(p) => { + // looking for: + // #[::macro_magic::export_tokens] + if p.segments.len() == 2 + && p.segments[0].ident == "macro_magic" + && p.segments[1].ident == "export_tokens" + { + false + } else { + true + } } - return true; - }; - true + ::syn::Meta::List(ml) => { + // looking for: + // #[derive(::bok::Repository, Debug)] + if ml.path.segments.len() > 0 && ml.path.is_ident("derive") { + use ::syn::{punctuated::Punctuated, *}; + if let Ok(v) = ml.parse_args_with( + Punctuated::<::syn::Path, Token![,]>::parse_terminated, + ) { + if v.len() == 2 + && v[0].segments.len() == 2 + && v[0].segments[0].ident.to_string() == "bok" + && v[0].segments[1].ident.to_string() + == "Repository" + && v[1].segments.len() == 1 + && v[1].segments[0].ident.to_string() == "Debug" + { + return false; + } + } + } + true + } + _ => true, + } }); let generics = local.generics; let ident = local.ident; @@ -134,7 +160,6 @@ pub(crate) fn repository( .named .iter() .find(|&x| { - // let Some(id) = &x.ident else { return false; }; diff --git a/bok-utils/Cargo.toml b/bok-utils/Cargo.toml index bad462d..59fae52 100644 --- a/bok-utils/Cargo.toml +++ b/bok-utils/Cargo.toml @@ -17,5 +17,5 @@ macro_magic = { version = "0.5" } prettyplease = "0.2" proc-macro2 = "1.0" quote = "1.0" -syn = { version = "2", features = [ "full", "parsing" ] } +syn = { version = "2", features = [ "full", "parsing", "extra-traits" ] } sha3 = { version = "0.10" } diff --git a/bok-utils/src/pkgs/mod.rs b/bok-utils/src/pkgs/mod.rs index 7785f3d..69bc9e6 100644 --- a/bok-utils/src/pkgs/mod.rs +++ b/bok-utils/src/pkgs/mod.rs @@ -73,7 +73,7 @@ impl Pkgs2 { } } /// This repository extends both Pkgs1 and Pkgs2 -#[::bok::repository(Pkgs1)] #[::bok::repository(Pkgs2)] +#[::bok::repository(Pkgs1)] #[derive(::std::default::Default)] pub struct Pkgs3 {}