This commit is contained in:
connorskees 2023-01-08 00:33:39 +00:00
parent 3c1b14406a
commit bf0d912dc8
7 changed files with 26 additions and 18 deletions

View File

@ -2,8 +2,13 @@
name = "compiler"
version = "0.12.1"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
description = "Internal implementation of the grass compiler"
readme = "../README.md"
license = "MIT"
categories = ["web-programming"]
keywords = ["scss", "sass", "css", "web"]
repository = "https://github.com/connorskees/grass"
authors = ["Connor Skees <39542938+ConnorSkees@users.noreply.github.com>"]
[lib]
name = "compiler"

View File

@ -2286,7 +2286,7 @@ impl<'a> Visitor<'a> {
args.positional
.into_iter()
.map(|arg| Ok(arg.to_css_string(span, self.options.is_compressed())?))
.map(|arg| arg.to_css_string(span, self.options.is_compressed()))
.collect::<SassResult<Vec<_>>>()?
}
};
@ -2389,7 +2389,7 @@ impl<'a> Visitor<'a> {
buffer.push_str(&evaluated);
}
if let Some(rest_arg) = args.rest.clone() {
if let Some(rest_arg) = args.rest {
let rest = self.visit_expr(rest_arg)?;
if !first {
buffer.push_str(", ");
@ -2749,9 +2749,7 @@ impl<'a> Visitor<'a> {
// );
}
let result = div(left, right, self.options, span)?;
result
div(left, right, self.options, span)?
}
BinaryOp::Rem => {
let right = self.visit_expr(rhs)?;

View File

@ -721,7 +721,7 @@ impl<'a> Serializer<'a> {
while let Some(elem) = elems.next() {
if self.inspect {
let needs_parens = Self::elem_needs_parens(sep, &elem);
let needs_parens = Self::elem_needs_parens(sep, elem);
if needs_parens {
self.buffer.push(b'(');
}
@ -923,9 +923,9 @@ impl<'a> Serializer<'a> {
fn visit_value(&mut self, value: &Value, span: Span) -> SassResult<()> {
match value {
Value::Dimension(num) => self.visit_number(&num)?,
Value::Color(color) => self.visit_color(&color),
Value::Calculation(calc) => self.visit_calculation(&calc)?,
Value::Dimension(num) => self.visit_number(num)?,
Value::Color(color) => self.visit_color(color),
Value::Calculation(calc) => self.visit_calculation(calc)?,
Value::List(elems, sep, brackets) => self.visit_list(elems, *sep, *brackets, span)?,
Value::True => self.buffer.extend_from_slice(b"true"),
Value::False => self.buffer.extend_from_slice(b"false"),
@ -935,7 +935,7 @@ impl<'a> Serializer<'a> {
}
}
Value::Map(map) => self.visit_map(map, span)?,
Value::FunctionRef(func) => self.visit_function_ref(&*func, span)?,
Value::FunctionRef(func) => self.visit_function_ref(func, span)?,
Value::String(s, QuoteKind::Quoted) => self.visit_quoted_string(false, s),
Value::String(s, QuoteKind::None) => self.visit_unquoted_string(s),
Value::ArgList(arglist) => self.visit_arglist(arglist, span)?,

View File

@ -2,6 +2,14 @@
name = "include_sass"
version = "0.12.1"
edition = "2021"
description = "Internal implementation of the grass::include! macro"
readme = "../README.md"
license = "MIT"
categories = ["web-programming"]
keywords = ["scss", "sass", "css", "web"]
repository = "https://github.com/connorskees/grass"
authors = ["Connor Skees <39542938+ConnorSkees@users.noreply.github.com>"]
include = ["src", "Cargo.toml", "../README.md", "../CHANGELOG.md", "../LICENSE"]
[lib]
proc-macro = true

View File

@ -103,10 +103,7 @@ pub fn include_sass(item: TokenStream) -> TokenStream {
) {
Ok(css) => css,
Err(e) => {
let err = syn::Error::new(
input.span(),
format!("Failed to compile Sass\n{}", e.to_string()),
);
let err = syn::Error::new(input.span(), format!("Failed to compile Sass\n{}", e));
return syn::Error::into_compile_error(err).into();
}
};

View File

@ -7,7 +7,7 @@ license = "MIT"
categories = ["command-line-utilities", "web-programming"]
keywords = ["scss", "sass", "css", "web"]
repository = "https://github.com/connorskees/grass"
authors = ["ConnorSkees <39542938+ConnorSkees@users.noreply.github.com>"]
authors = ["Connor Skees <39542938+ConnorSkees@users.noreply.github.com>"]
edition = "2021"
include = ["src", "Cargo.toml", "README.md", "CHANGELOG.md", "Cargo.lock", "LICENSE"]
default-run = "grass"

View File

@ -85,7 +85,7 @@ pub use compiler::*;
/// Include CSS in your binary at compile time from a Sass source file
///
/// ```
/// static CSS: &str = grass::include!("../static/_main.scss");
/// static CSS: &str = grass::include!("../static/_index.scss");
/// ```
///
/// This requires the `"macro"` feature, which is not enabled by default.