Skip to content

Commit 997691c

Browse files
authored
Merge PR #165: Make rsass-macros more release-ready.
Adds to #163 - Rename rsass-macro to rsass-macros, as I will add a second macro for including css from scss in a file. - Add rsass-macros to the workspace. - Add some documentaion.
2 parents 571f54d + b475953 commit 997691c

File tree

8 files changed

+73
-32
lines changed

8 files changed

+73
-32
lines changed

Diff for: CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ project adheres to
1616
- Tests are restructured to fail faster for simple things, while
1717
macos and windows testing is added to the github action (appveyor
1818
is removed).
19+
* Added macros (PR #163, #165).
20+
- The workspace now includes a `rsass-macros` crate that can be used to
21+
compile sass to css strings at compile time in rust crates.
1922
* Changed numeric handing (mainly conversions to/from `f64`) to match
2023
improvements in how dart-sass handles numerics. This is mainly done by
2124
removing some special cases as dart-sass and rust now agrees on more of
@@ -48,6 +51,8 @@ project adheres to
4851
* Updated clap to 4.0 for the command-line interface.
4952
* Updated sass-spec test suite to 2022-12-20.
5053

54+
Thanks to @Wicpar for the initial macros implementation.
55+
5156

5257
## Release 0.26.0
5358

Diff for: Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@
33
members = [
44
"rsass",
55
"rsass-cli",
6+
"rsass-macros",
67
"spectest",
78
]

Diff for: rsass-macro/.gitignore

-13
This file was deleted.

Diff for: rsass-macro/Cargo.toml

-13
This file was deleted.

Diff for: rsass-macros/Cargo.toml

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
[package]
2+
name = "rsass-macros"
3+
version = "0.1.0"
4+
categories = ["web-programming"]
5+
keywords = ["scss", "sass", "css", "web", "macro"]
6+
description = "Sass as a rust function-like macro."
7+
documentation = "https://docs.rs/rsass-macros"
8+
repository = "https://github.com/kaj/rsass"
9+
readme = "README.md"
10+
license = "MIT OR Apache-2.0"
11+
edition = "2021"
12+
rust-version = "1.60.0"
13+
14+
[lib]
15+
proc-macro = true
16+
17+
[dependencies]
18+
rsass = { path = "../rsass", version = "0.26.1-PRE" }
19+
proc-macro2 = "1.0.32"
20+
quote = "1.0.22"
21+
syn = "1.0.106"

Diff for: rsass-macros/README.md

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# rsass-macros
2+
3+
Sass reimplemented in rust with nom.
4+
The "r" in the name might stand for the Rust programming language, for
5+
"re-implemented", or possibly for my name Rasmus.
6+
7+
This is the `rsass-macros` crate, giving rust projects access to
8+
sass-compiled strings in compile-time.
9+
To use it, add `rsass-macros` to your dependencies in a rust project.
10+
11+
cargo add rsass-macros
12+
13+
[![Crate](https://img.shields.io/crates/v/rsass-macros.svg)](https://crates.io/crates/rsass-macros)
14+
[![docs](https://docs.rs/rsass-macros/badge.svg)](https://docs.rs/rsass-macros)
15+
[![Github build](https://github.com/kaj/rsass/workflows/CI/badge.svg)](https://github.com/kaj/rsass/actions)
16+
17+
## Sass language and implementation status
18+
19+
The sass language [is defined in its reference
20+
doc](http://sass-lang.com/documentation/).
21+
See [the rsass crate](https://docs.rs/rsass) or the the
22+
[rsass monorepo](https://github.com/kaj/rsass/) for the
23+
implementation status.
24+
25+
## Contributing
26+
27+
Welcome!
28+
Please see the [rsass monorepo](https://github.com/kaj/rsass/)
29+
about contributing.

Diff for: rsass-macro/src/lib.rs renamed to rsass-macros/src/lib.rs

+13-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,20 @@
1-
extern crate proc_macro;
1+
//! Convert scss to css at compile-type.
2+
//! Implemented with [rsass].
23
use proc_macro::TokenStream;
34
use proc_macro2::Span;
45
use quote::ToTokens;
5-
use syn::{Error, LitStr, parse_macro_input};
66
use rsass::output::{Format, Style};
7+
use syn::{parse_macro_input, Error, LitStr};
78

9+
/// Convert a scss string to css at compile time.
10+
///
11+
/// # Examples
12+
///
13+
/// ````
14+
/// use rsass_macros::scss;
15+
/// const CSS: &str = scss!("p { em { font-style: italic; } font: serif; }");
16+
/// assert_eq!(CSS, "p{font:serif}p em{font-style:italic}\n");
17+
/// ````
818
#[proc_macro]
919
pub fn scss(tokens: TokenStream) -> TokenStream {
1020
let input = parse_macro_input!(tokens as LitStr);
@@ -26,4 +36,4 @@ pub fn scss(tokens: TokenStream) -> TokenStream {
2636
.into()
2737
}
2838
}
29-
}
39+
}
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
21
#[test]
32
fn test_macro() {
4-
const CSS: &'static str = rsass_macro::scss!(r#"
3+
const CSS: &'static str = rsass_macros::scss!(
4+
r#"
55
.class {
66
background: red;
77
&:hover {
88
background: blue;
99
}
1010
}
11-
"#);
11+
"#
12+
);
1213
assert_eq!(".class{background:red}.class:hover{background:blue}\n", CSS)
1314
}

0 commit comments

Comments
 (0)