/*! # grass An implementation of the sass specification in pure rust. All functionality is currently exposed through [`StyleSheet`]. Spec progress as of 2020-04-21: | Passing | Failing | Total | |---------|---------|-------| | 2150 | 2943 | 5093 | ## Use as library ``` use grass::{SassResult, StyleSheet}; fn main() -> SassResult<()> { let sass = StyleSheet::new("a { b { color: &; } }".to_string())?; assert_eq!(sass, "a b {\n color: a b;\n}\n"); Ok(()) } ``` ## Use as binary ```bash cargo install grass grass input.scss ``` */ #![warn( clippy::all, clippy::restriction, clippy::pedantic, clippy::nursery, clippy::cargo )] #![deny(missing_debug_implementations)] #![allow( // explicit return makes some things look ugly clippy::implicit_return, // Self { .. } is less explicit than Foo { .. } clippy::use_self, // this is way too pedantic -- some things don't need docs! clippy::missing_docs_in_private_items, // unreachable!() has many valid use cases clippy::unreachable, // _ => {} has many valid use cases clippy::wildcard_enum_match_arm, // .expect() has many valid use cases, like when we know a value is `Some(..)` clippy::option_expect_used, // this is too pedantic -- we are allowed to add numbers! clippy::integer_arithmetic, // this is too pedantic for now -- the library is changing too quickly for // good docs to be written clippy::missing_errors_doc, // this incorrectly results in errors for types that derive `Debug` // https://github.com/rust-lang/rust-clippy/issues/4980 clippy::let_underscore_must_use, // this is too pedantic -- it results in some names being less explicit // than they should clippy::module_name_repetitions, // this is too pedantic -- it is sometimes useful to break up `impl`s clippy::multiple_inherent_impl, // temporarily allowed while under heavy development. // eventually these allows should be refactored away // to no longer be necessary clippy::as_conversions, clippy::todo, clippy::too_many_lines, clippy::panic, clippy::option_unwrap_used, clippy::result_unwrap_used, clippy::result_expect_used, clippy::cast_possible_truncation, clippy::single_match_else, clippy::indexing_slicing, clippy::match_same_arms, clippy::or_fun_call, clippy::redundant_pub_crate, )] #![cfg_attr(feature = "nightly", feature(track_caller))] use std::fs; use std::iter::Iterator; use std::path::Path; use codemap::{CodeMap, Span, Spanned}; use peekmore::{PeekMore, PeekMoreIterator}; use crate::atrule::{eat_include, AtRule, AtRuleKind, Function, Mixin}; pub use crate::error::{SassError, SassResult}; use crate::imports::import; use crate::lexer::Lexer; use crate::output::Css; use crate::scope::{insert_global_fn, insert_global_mixin, insert_global_var, Scope, GLOBAL_SCOPE}; use crate::selector::Selector; use crate::style::Style; pub(crate) use crate::token::Token; use crate::utils::{ devour_whitespace, eat_comment, eat_ident, eat_ident_no_interpolation, eat_variable_value, parse_quoted_string, read_until_newline, VariableDecl, }; use crate::value::Value; mod args; mod atrule; mod builtin; mod color; mod common; mod error; mod imports; mod lexer; mod output; mod scope; mod selector; mod style; mod token; mod unit; mod utils; mod value; /// Represents a parsed SASS stylesheet with nesting #[derive(Debug, Clone)] pub struct StyleSheet(Vec>); #[derive(Clone, Debug)] pub(crate) enum Stmt { /// A [`Style`](/grass/style/struct.Style) Style(Box