drop redundant feature flags, as behavour is consistent between sass syntax types

This commit is contained in:
Yiffy Dev 2024-10-30 17:42:26 +05:00 • committed by spushk
commit 7bdb7158d1
Signed by: spushk
GPG key ID: 7797B761E105E8AA
10 changed files with 6 additions and 66 deletions

View file

@ -43,22 +43,10 @@ sabry_build = {workspace = true, optional = true}
sabry_intrnl = {workspace = true} sabry_intrnl = {workspace = true}
[features] [features]
default = ["scss"] default = ["procmacro"]
procmacro = [ procmacro = [
"dep:sabry_procmacro" "dep:sabry_procmacro"
] ]
sass = [
"procmacro",
"sabry_procmacro/sass",
"sabry_intrnl/sass",
"sabry_build/sass"
]
scss = [
"procmacro",
"sabry_procmacro/scss",
"sabry_intrnl/scss",
"sabry_build/scss"
]
build = [ build = [
"dep:sabry_build" "dep:sabry_build"
] ]

View file

@ -6,4 +6,4 @@ rust-version = "1.82"
publish = false publish = false
[dependencies] [dependencies]
sabry = {path = "../../", features = ["sass"]} sabry = {path = "../../"}

View file

@ -23,11 +23,11 @@ tracing = { version = "0.1", optional = true }
http = "1" http = "1"
# sabry with sass # sabry with sass
sabry = {path = "../../", features = ["sass"]} sabry = {path = "../../"}
[build-dependencies] [build-dependencies]
# sabry for build with sass # sabry for build with sass
sabry = {path = "../../", features = ["build", "sass"]} sabry = {path = "../../", features = ["build"]}
# lets depend on our styles # lets depend on our styles
define-styles = {path = "../define-styles"} define-styles = {path = "../define-styles"}

View file

@ -6,10 +6,10 @@ rust-version = "1.82"
publish = false publish = false
[dependencies] [dependencies]
sabry = {path = "../../", features = ["sass"]} sabry = {path = "../../"}
[build-dependencies] [build-dependencies]
sabry = {path = "../../", features = ["build", "sass"]} sabry = {path = "../../", features = ["build"]}
define-styles = {path = "../define-styles"} define-styles = {path = "../define-styles"}
[package.metadata.sabry] [package.metadata.sabry]

View file

@ -17,12 +17,4 @@ thiserror = {version = "^1.0"}
walkdir = {version = "^2.5"} walkdir = {version = "^2.5"}
[features] [features]
sass = [
"sabry_procmacro_impl/sass",
"sabry_intrnl/sass"
]
scss = [
"sabry_procmacro_impl/scss",
"sabry_intrnl/scss"
]
net-files = [] net-files = []

View file

@ -24,5 +24,3 @@ serde = {version = "^1.0", features = ["derive"]}
toml = {version = "^0.8"} toml = {version = "^0.8"}
[features] [features]
sass = []
scss = []

View file

@ -89,18 +89,14 @@ pub enum SabryCompilerError {
/// Unification wrapper over all the Syntax enums /// Unification wrapper over all the Syntax enums
#[derive(Clone, Copy)] #[derive(Clone, Copy)]
pub enum CompilerSyntax { pub enum CompilerSyntax {
#[cfg(feature = "sass")]
Sass, Sass,
#[cfg(feature = "scss")]
Scss, Scss,
} }
impl From<raffia::Syntax> for CompilerSyntax { impl From<raffia::Syntax> for CompilerSyntax {
fn from(value: raffia::Syntax) -> Self { fn from(value: raffia::Syntax) -> Self {
match value { match value {
#[cfg(feature = "sass")]
raffia::Syntax::Sass => Self::Sass, raffia::Syntax::Sass => Self::Sass,
#[cfg(feature = "scss")]
raffia::Syntax::Scss => Self::Scss, raffia::Syntax::Scss => Self::Scss,
// TODO: fallbacky error-prone // TODO: fallbacky error-prone
_ => Self::Scss, _ => Self::Scss,
@ -111,9 +107,7 @@ impl From<raffia::Syntax> for CompilerSyntax {
impl From<CompilerSyntax> for grass::InputSyntax { impl From<CompilerSyntax> for grass::InputSyntax {
fn from(value: CompilerSyntax) -> Self { fn from(value: CompilerSyntax) -> Self {
match value { match value {
#[cfg(feature = "scss")]
CompilerSyntax::Scss => Self::Scss, CompilerSyntax::Scss => Self::Scss,
#[cfg(feature = "sass")]
CompilerSyntax::Sass => Self::Sass, CompilerSyntax::Sass => Self::Sass,
} }
} }

View file

@ -14,9 +14,3 @@ proc-macro = true
sabry_procmacro_impl = {workspace = true} sabry_procmacro_impl = {workspace = true}
[features] [features]
sass = [
"sabry_procmacro_impl/sass"
]
scss = [
"sabry_procmacro_impl/scss"
]

View file

@ -17,9 +17,3 @@ raffia = {version = "^0.9"}
regex = {version = "^1.11"} regex = {version = "^1.11"}
[features] [features]
sass = [
"sabry_intrnl/sass"
]
scss = [
"sabry_intrnl/scss"
]

View file

@ -74,18 +74,14 @@ impl ToString for ArbitraryStyleBlock {
#[derive(Clone, Copy)] #[derive(Clone, Copy)]
pub enum ArbitraryStyleSyntax { pub enum ArbitraryStyleSyntax {
#[cfg(feature = "scss")]
Scss, Scss,
#[cfg(feature = "sass")]
Sass, Sass,
} }
impl From<ArbitraryStyleSyntax> for CompilerSyntax { impl From<ArbitraryStyleSyntax> for CompilerSyntax {
fn from(value: ArbitraryStyleSyntax) -> Self { fn from(value: ArbitraryStyleSyntax) -> Self {
match value { match value {
#[cfg(feature = "sass")]
ArbitraryStyleSyntax::Sass => Self::Sass, ArbitraryStyleSyntax::Sass => Self::Sass,
#[cfg(feature = "scss")]
ArbitraryStyleSyntax::Scss => Self::Scss, ArbitraryStyleSyntax::Scss => Self::Scss,
} }
} }
@ -94,9 +90,7 @@ impl From<ArbitraryStyleSyntax> for CompilerSyntax {
impl ToTokens for ArbitraryStyleSyntax { impl ToTokens for ArbitraryStyleSyntax {
fn to_tokens(&self, tokens: &mut TokenStream) { fn to_tokens(&self, tokens: &mut TokenStream) {
match self { match self {
#[cfg(feature = "sass")]
Self::Sass => tokens.append_all(quote! {"sass"}), Self::Sass => tokens.append_all(quote! {"sass"}),
#[cfg(feature = "scss")]
Self::Scss => tokens.append_all(quote! {"scss"}), Self::Scss => tokens.append_all(quote! {"scss"}),
} }
} }
@ -114,9 +108,7 @@ impl Parse for ArbitraryStyleSyntax {
let ident = input.parse::<Ident>()?; let ident = input.parse::<Ident>()?;
match ident.to_string().as_str() { match ident.to_string().as_str() {
#[cfg(feature = "sass")]
"sass" => Ok(Self::Sass), "sass" => Ok(Self::Sass),
#[cfg(feature = "scss")]
"scss" => Ok(Self::Scss), "scss" => Ok(Self::Scss),
_ => Err(syn::Error::new( _ => Err(syn::Error::new(
ident.span(), ident.span(),
@ -132,9 +124,7 @@ impl Parse for ArbitraryStyleSyntax {
impl Debug for ArbitraryStyleSyntax { impl Debug for ArbitraryStyleSyntax {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let name = match self { let name = match self {
#[cfg(feature = "sass")]
Self::Sass => "sass", Self::Sass => "sass",
#[cfg(feature = "scss")]
Self::Scss => "scss", Self::Scss => "scss",
}; };
write!(f, "{name}") write!(f, "{name}")
@ -142,23 +132,15 @@ impl Debug for ArbitraryStyleSyntax {
} }
impl Default for ArbitraryStyleSyntax { impl Default for ArbitraryStyleSyntax {
#[cfg(feature = "scss")]
fn default() -> Self { fn default() -> Self {
Self::Scss Self::Scss
} }
#[cfg(all(feature = "sass", not(feature = "scss")))]
fn default() -> Self {
Self::Sass
}
} }
impl From<ArbitraryStyleSyntax> for raffia::Syntax { impl From<ArbitraryStyleSyntax> for raffia::Syntax {
fn from(value: ArbitraryStyleSyntax) -> Self { fn from(value: ArbitraryStyleSyntax) -> Self {
match value { match value {
#[cfg(feature = "sass")]
ArbitraryStyleSyntax::Sass => Self::Sass, ArbitraryStyleSyntax::Sass => Self::Sass,
#[cfg(feature = "scss")]
ArbitraryStyleSyntax::Scss => Self::Scss, ArbitraryStyleSyntax::Scss => Self::Scss,
} }
} }
@ -166,7 +148,6 @@ impl From<ArbitraryStyleSyntax> for raffia::Syntax {
#[cfg(test)] #[cfg(test)]
mod test { mod test {
#[cfg(feature = "sass")]
#[test] #[test]
fn arbitrary_style_block_sass() { fn arbitrary_style_block_sass() {
use super::ArbitraryStyleBlock; use super::ArbitraryStyleBlock;
@ -183,7 +164,6 @@ mod test {
assert_eq!(code, block.code); assert_eq!(code, block.code);
} }
#[cfg(feature = "scss")]
#[test] #[test]
fn arbitrary_style_block_scss() { fn arbitrary_style_block_scss() {
use super::ArbitraryStyleBlock; use super::ArbitraryStyleBlock;