From 40e4d368cf228ef3c2de0eb88e8034ad6cad8bbe Mon Sep 17 00:00:00 2001 From: Yiffy Dev Date: Mon, 4 Nov 2024 22:06:29 +0500 Subject: [PATCH] fix: found that macro name was nasty. Also my team starts a production with sabry, so lets call it release --- README.md | 28 +++++++++---------- examples/define-styles/src/lib.rs | 10 +++---- examples/use-styles/build.rs | 4 +-- sabry_build/src/buildmagic.rs | 2 +- sabry_procmacro/src/lib.rs | 16 +++++------ sabry_procmacro/tests/macros.rs | 12 ++++---- sabry_procmacro_impl/src/impls/mod.rs | 2 +- .../src/impls/{sassy.rs => scssy.rs} | 4 +-- sabry_procmacro_impl/src/impls/usey.rs | 2 +- tests/macros.rs | 20 ++++++------- 10 files changed, 50 insertions(+), 50 deletions(-) rename sabry_procmacro_impl/src/impls/{sassy.rs => scssy.rs} (92%) diff --git a/README.md b/README.md index 0a4e396..ae87410 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ At first, I'll show how this crate "tastes". With SABRY, its in your power to: Write arbitrary SASS/SCSS code and ship it *as a crate* however you please: with modules, with feature flags, etc. Say "bye" to manual copying, cli-tools and consts. ```rust -sabry::sassy!(tokens {"@mixin colored{color: red;}"}); +sabry::scssy!(tokens {"@mixin colored{color: red;}"}); ``` @@ -146,10 +146,10 @@ sabry = {version = "0.0.1"} And a proc-macro ```rust // lib.rs -use sabry::sassy; +use sabry::scssy; -sassy!(mixins "tests/assets/mixin-module.scss"); -sassy!(styles {" +scssy!(mixins "tests/assets/mixin-module.scss"); +scssy!(styles {" $primary-color: black; @mixin colored($col: primary) { @if $col == primary { @@ -290,7 +290,7 @@ use leptos::prelude::*; use sabry::styly; styly!(scope {" - // assuming we have tokens!() macro generated by `sassy!`, which is handled by `buildy` + // assuming we have tokens!() macro generated by `scssy!`, which is handled by `buildy` @use 'tokens'; h1 { @include tokens.sectionhead(); @@ -427,9 +427,9 @@ For example `{ie = "9", saf_ios = "13.2"}` will try to generate CSS supported on ## Detailed guide -### Style definition with `sassy!` +### Style definition with `scssy!` -The `sassy!` macro is available with *procmacro* feature which is enabled by default. +The `scssy!` macro is available with *procmacro* feature which is enabled by default. It does accept the following syntax: `$name(:$syntax)? ({ $code })|($filename)`, where @@ -440,13 +440,13 @@ It does accept the following syntax: `$name(:$syntax)? ({ $code })|($filename)`, Examples: ```rust -use sabry::sassy; +use sabry::scssy; -sassy!(module1 {"$primary-color: red;"}); -sassy!(module2 "tests/assets/mixin-module.scss"); -sassy!(module3:sass "tests/assets/mixin-module.sass"); +scssy!(module1 {"$primary-color: red;"}); +scssy!(module2 "tests/assets/mixin-module.scss"); +scssy!(module3:sass "tests/assets/mixin-module.sass"); // works, but there are catches. -sassy!(module4:sass {" +scssy!(module4:sass {" @mixin colored($col: primary) @if $col == primary color: white @@ -457,7 +457,7 @@ sassy!(module4:sass {" You may omit the syntax specifier - sabry uses SCSS as the default one. -The given code to `sassy!` is not checked to be valid code in given syntax (wip). +The given code to `scssy!` is not checked to be valid code in given syntax (wip). > SASS support inside of rust files is experimental. If you do want to use SASS tabbed syntax - consider to use files path instead of sass-in-rust option. @@ -590,7 +590,7 @@ sabry::buildy( )?; ``` -Exactly this kind of macros is produced by [`sassy!`](#style-definition-with-sassy). +Exactly this kind of macros is produced by [`scssy!`](#style-definition-with-scssy). ### Scoping diff --git a/examples/define-styles/src/lib.rs b/examples/define-styles/src/lib.rs index 9850a64..0640d6e 100644 --- a/examples/define-styles/src/lib.rs +++ b/examples/define-styles/src/lib.rs @@ -1,8 +1,8 @@ -use sabry::sassy; +use sabry::scssy; -sassy!(style "src/style.scss"); +scssy!(style "src/style.scss"); -sassy!(utils {" +scssy!(utils {" @mixin flex($direction, $align, $justify, $gap: .5rem) { display: flex; list-style: none; @@ -31,7 +31,7 @@ sassy!(utils {" } "}); -sassy!(theme {" +scssy!(theme {" $thm-surface-primary: #2b2a29; $thm-surface-secondary: #6C6C6C; $thm-surface-tertiary: #4C4C4C; @@ -77,7 +77,7 @@ sassy!(theme {" } "}); -sassy!(tokens {" +scssy!(tokens {" @use 'theme'; @mixin clickable($style: accent, $scale: 1.2, $clickscale: 0.9){ diff --git a/examples/use-styles/build.rs b/examples/use-styles/build.rs index d8b254f..ec066dc 100644 --- a/examples/use-styles/build.rs +++ b/examples/use-styles/build.rs @@ -1,9 +1,9 @@ use define_styles::{theme, tokens, utils as utils_dup}; -use sabry::{sassy, usey}; +use sabry::{scssy, usey}; // This module will have the same name as define_styles_example::utils // and sabry is configured to merge them -sassy!(utils {" +scssy!(utils {" @mixin nonclickable(){ display: none; } diff --git a/sabry_build/src/buildmagic.rs b/sabry_build/src/buildmagic.rs index 7ea2af9..bd476a7 100644 --- a/sabry_build/src/buildmagic.rs +++ b/sabry_build/src/buildmagic.rs @@ -34,7 +34,7 @@ type BuilderResult = Result<(), SabryBuildError>; /// ).expect("Sabry failed to build CSS"); /// ``` /// -/// Also you could use style-macros defined anywhere with `sabry::sassy!` procmacro: +/// Also you could use style-macros defined anywhere with `sabry::scssy!` procmacro: /// ```ignore /// buildy( /// sabry::usey!( diff --git a/sabry_procmacro/src/lib.rs b/sabry_procmacro/src/lib.rs index 6500413..aed8a2c 100644 --- a/sabry_procmacro/src/lib.rs +++ b/sabry_procmacro/src/lib.rs @@ -2,7 +2,7 @@ use proc_macro::TokenStream; use sabry_procmacro_impl::impls::{ - sassy::sassy_macro_impl, styly::styly_macro_impl, usey::usey_macro_impl, + scssy::scssy_macro_impl, styly::styly_macro_impl, usey::usey_macro_impl, }; /// Macro that makes sass code rusty. @@ -13,28 +13,28 @@ use sabry_procmacro_impl::impls::{ /// ## Usage /// /// ```ignore -/// sassy!(scssmodule { +/// scssy!(scssmodule { /// /* SCSS */ /// }); -/// sassy!(sassmodule:sass { +/// scssy!(sassmodule:sass { /// /* SASS (WIP) */ /// }); -/// sassy!(scssmod2:scss { +/// scssy!(scssmod2:scss { /// /* SCSS */ /// }); /// ``` /// Or read code from file /// ```ignore -/// sassy!(filemodule "src/styles/a.scss"); -/// sassy!(filemodule:sass "src/styles/b.sass"); +/// scssy!(filemodule "src/styles/a.scss"); +/// scssy!(filemodule:sass "src/styles/b.sass"); /// ``` /// /// \[SCSS syntax requires 'scss' feature\] /// \[SASS syntax requires 'sass' feature (WIP)\] /// #[proc_macro] -pub fn sassy(input: TokenStream) -> TokenStream { - sassy_macro_impl(input.into()).into() +pub fn scssy(input: TokenStream) -> TokenStream { + scssy_macro_impl(input.into()).into() } /// Macro that brings sass code into app diff --git a/sabry_procmacro/tests/macros.rs b/sabry_procmacro/tests/macros.rs index 22bd4a3..84376af 100644 --- a/sabry_procmacro/tests/macros.rs +++ b/sabry_procmacro/tests/macros.rs @@ -1,8 +1,8 @@ use std::{collections::HashSet, fs}; -use sabry_procmacro::{sassy, usey}; +use sabry_procmacro::{scssy, usey}; -sassy!(scmod:scss {" +scssy!(scmod:scss {" @mixin abc(){ color: red; } @@ -10,18 +10,18 @@ sassy!(scmod:scss {" @include abc; } "}); -sassy!(samod:sass {" +scssy!(samod:sass {" @mixin abc() color: green .sel1 @include abc "}); -sassy!(scmicromod:scss "sabry_procmacro/tests/scmicro.scss"); -sassy!(samicromod:sass "sabry_procmacro/tests/samicro.sass"); +scssy!(scmicromod:scss "sabry_procmacro/tests/scmicro.scss"); +scssy!(samicromod:sass "sabry_procmacro/tests/samicro.sass"); #[test] -fn sassy_contract() { +fn scssy_contract() { assert_eq!(scmod!(syntax), "scss"); assert_eq!( scmod!(), diff --git a/sabry_procmacro_impl/src/impls/mod.rs b/sabry_procmacro_impl/src/impls/mod.rs index 009df1f..47a6939 100644 --- a/sabry_procmacro_impl/src/impls/mod.rs +++ b/sabry_procmacro_impl/src/impls/mod.rs @@ -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; diff --git a/sabry_procmacro_impl/src/impls/sassy.rs b/sabry_procmacro_impl/src/impls/scssy.rs similarity index 92% rename from sabry_procmacro_impl/src/impls/sassy.rs rename to sabry_procmacro_impl/src/impls/scssy.rs index ef5d401..b82718d 100644 --- a/sabry_procmacro_impl/src/impls/sassy.rs +++ b/sabry_procmacro_impl/src/impls/scssy.rs @@ -11,7 +11,7 @@ use super::{ArbitraryStyleBlock, ArbitraryStyleSyntax}; /// `$syntax`: sass/scss /// /// `$code`: intended to be valid based on $syntax -pub fn sassy_macro_impl(input: TokenStream) -> TokenStream { +pub fn scssy_macro_impl(input: TokenStream) -> TokenStream { let MacroSyntax { ident, syntax: mode, @@ -28,7 +28,7 @@ pub fn sassy_macro_impl(input: TokenStream) -> TokenStream { } let sourcesass = code.to_string(); - let macro_doc = format!("Arbitrary {:?} code declared with `sassy!`. Pretty usable in tandem with `usey!` and `magic()` at build time", mode); + 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] diff --git a/sabry_procmacro_impl/src/impls/usey.rs b/sabry_procmacro_impl/src/impls/usey.rs index 56b2ba5..95d2dc8 100644 --- a/sabry_procmacro_impl/src/impls/usey.rs +++ b/sabry_procmacro_impl/src/impls/usey.rs @@ -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 diff --git a/tests/macros.rs b/tests/macros.rs index eb583b4..f8f2ea0 100644 --- a/tests/macros.rs +++ b/tests/macros.rs @@ -1,10 +1,10 @@ use sabry::styly; pub mod sass { - use sabry::sassy; + use sabry::scssy; - sassy!(mixins_sass:sass "tests/assets/mixin-module.sass"); - sassy!(mixins_inline_sass:sass {" + scssy!(mixins_sass:sass "tests/assets/mixin-module.sass"); + scssy!(mixins_inline_sass:sass {" @mixin color($color: black) @if $color == black color: white @@ -24,8 +24,8 @@ pub mod sass { &:hover transform: translateX(10%) "}); - sassy!(module_sass:sass "tests/assets/module-forward.sass"); - sassy!(module_inline_sass:sass {" + scssy!(module_sass:sass "tests/assets/module-forward.sass"); + scssy!(module_inline_sass:sass {" @forward 'mixins_a' @forward 'mixins_c' "}); @@ -36,10 +36,10 @@ pub mod sass { } pub mod scss { - use sabry::sassy; + use sabry::scssy; - sassy!(mixins_scss:scss "tests/assets/mixin-module.scss"); - sassy!(mixins_inline_scss:scss {" + scssy!(mixins_scss:scss "tests/assets/mixin-module.scss"); + scssy!(mixins_inline_scss:scss {" @mixin surface($color: black){ @if $color == black{ color: white; @@ -64,8 +64,8 @@ pub mod scss { } } "}); - sassy!(module_scss:scss "tests/assets/module-forward.scss"); - sassy!(module_inline_scss:scss {" + scssy!(module_scss:scss "tests/assets/module-forward.scss"); + scssy!(module_inline_scss:scss {" @forward 'mixins_a'; @forward 'mixins_c'; "});