fix: found that macro name was nasty. Also my team starts a production with sabry, so lets call it release
This commit is contained in:
parent
23ec12cd00
commit
aff9e5e402
3 changed files with 50 additions and 50 deletions
|
|
@ -6,7 +6,7 @@ use regex::Regex;
|
|||
use sabry_intrnl::syntax::ostrta::OneSyntaxToRuleThemAll;
|
||||
use syn::{braced, parse::Parse, Ident, LitStr, Token};
|
||||
|
||||
pub mod sassy;
|
||||
pub mod scssy;
|
||||
pub mod styly;
|
||||
pub mod usey;
|
||||
|
||||
|
|
|
|||
64
sabry_procmacro_impl/src/impls/scssy.rs
Normal file
64
sabry_procmacro_impl/src/impls/scssy.rs
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
use proc_macro2::TokenStream;
|
||||
use quote::quote;
|
||||
use sabry_intrnl::scoper::ArbitraryScope;
|
||||
use syn::{parse::Parse, Ident};
|
||||
|
||||
use super::{ArbitraryStyleBlock, ArbitraryStyleSyntax};
|
||||
|
||||
/// Syntax:
|
||||
/// `#ident(:$syntax)? { $code }`
|
||||
///
|
||||
/// `$syntax`: sass/scss
|
||||
///
|
||||
/// `$code`: intended to be valid based on $syntax
|
||||
pub fn scssy_macro_impl(input: TokenStream) -> TokenStream {
|
||||
let MacroSyntax {
|
||||
ident,
|
||||
syntax: mode,
|
||||
code,
|
||||
} = match syn::parse2::<MacroSyntax>(input) {
|
||||
Ok(m) => m,
|
||||
Err(e) => return e.to_compile_error(),
|
||||
};
|
||||
|
||||
// quick raffia syntax check
|
||||
match ArbitraryScope::from_source(mode.0, ident.clone(), &code.code) {
|
||||
Ok(_) => {}
|
||||
Err(e) => return syn::Error::new(code.span, format!("{e:?}")).into_compile_error(),
|
||||
}
|
||||
|
||||
let sourcesass = code.to_string();
|
||||
let macro_doc = format!("Arbitrary {:?} code declared with `scssy!`. Pretty usable in tandem with `usey!` and `magic()` at build time", mode);
|
||||
|
||||
quote! {
|
||||
#[doc = #macro_doc]
|
||||
#[macro_export]
|
||||
macro_rules! #ident {
|
||||
() => {#sourcesass};
|
||||
(syntax) => {#mode};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct MacroSyntax {
|
||||
ident: Ident,
|
||||
syntax: ArbitraryStyleSyntax,
|
||||
code: ArbitraryStyleBlock,
|
||||
}
|
||||
|
||||
impl Parse for MacroSyntax {
|
||||
fn parse(input: syn::parse::ParseStream) -> syn::Result<Self> {
|
||||
let ident = input.parse::<Ident>()?;
|
||||
let mode = input.parse::<ArbitraryStyleSyntax>()?;
|
||||
let code = input.parse::<ArbitraryStyleBlock>()?;
|
||||
|
||||
Ok(Self {
|
||||
ident,
|
||||
syntax: mode,
|
||||
code,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {}
|
||||
|
|
@ -32,7 +32,7 @@ impl StyleCall {
|
|||
let call_code = &self.call;
|
||||
let call_path = &self.call.path;
|
||||
let call_bang = &self.call.bang_token;
|
||||
// the following calls are expected by macro genereted by `sassy!`
|
||||
// the following calls are expected by macro genereted by `scssy!`
|
||||
let call_syntax = quote! {#call_path #call_bang (syntax)};
|
||||
|
||||
let module_name = call_path
|
||||
|
|
|
|||
Loading…
Reference in a new issue