2022-12-26 15:33:04 -05:00
|
|
|
/*!
|
|
|
|
This crate provides functionality for compiling [Sass](https://sass-lang.com/) to CSS.
|
2020-04-18 18:53:18 -04:00
|
|
|
|
2023-01-25 03:35:46 +00:00
|
|
|
This crate targets compatibility with the reference implementation in Dart. If
|
2022-12-28 22:32:18 -05:00
|
|
|
upgrading from the [now deprecated](https://sass-lang.com/blog/libsass-is-deprecated)
|
|
|
|
`libsass`, one may have to modify their stylesheets. These changes will not differ
|
|
|
|
from those necessary to upgrade to `dart-sass`, and in general such changes should
|
|
|
|
be quite rare.
|
|
|
|
|
|
|
|
This crate is capable of compiling Bootstrap 4 and 5, bulma and bulma-scss, Bourbon,
|
|
|
|
as well as most other large Sass libraries with complete accuracy. For the vast
|
|
|
|
majority of use cases there should be no perceptible differences from the reference
|
|
|
|
implementation.
|
|
|
|
|
2020-04-18 18:53:18 -04:00
|
|
|
## Use as library
|
|
|
|
```
|
2020-06-26 08:03:43 -04:00
|
|
|
fn main() -> Result<(), Box<grass::Error>> {
|
2022-12-26 15:33:04 -05:00
|
|
|
let css = grass::from_string(
|
|
|
|
"a { b { color: &; } }".to_owned(),
|
|
|
|
&grass::Options::default()
|
|
|
|
)?;
|
|
|
|
assert_eq!(css, "a b {\n color: a b;\n}\n");
|
2020-04-18 18:53:18 -04:00
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
## Use as binary
|
|
|
|
```bash
|
|
|
|
cargo install grass
|
|
|
|
grass input.scss
|
|
|
|
```
|
|
|
|
*/
|
2020-03-01 09:08:13 -05:00
|
|
|
|
2023-01-06 10:54:34 +00:00
|
|
|
#![cfg_attr(doc, feature(doc_cfg))]
|
2023-01-18 01:37:59 +00:00
|
|
|
#![warn(clippy::all, clippy::cargo, clippy::dbg_macro)]
|
2020-01-20 11:00:01 -05:00
|
|
|
#![deny(missing_debug_implementations)]
|
|
|
|
#![allow(
|
|
|
|
clippy::use_self,
|
|
|
|
clippy::missing_docs_in_private_items,
|
|
|
|
clippy::unreachable,
|
2020-02-02 10:27:08 -05:00
|
|
|
clippy::module_name_repetitions,
|
2020-05-24 17:41:24 -04:00
|
|
|
// filter isn't fallible
|
2021-07-03 23:17:31 -04:00
|
|
|
clippy::manual_filter_map,
|
2020-05-31 05:32:19 -04:00
|
|
|
clippy::new_ret_no_self,
|
2020-06-07 23:11:43 -04:00
|
|
|
renamed_and_removed_lints,
|
|
|
|
clippy::unknown_clippy_lints,
|
2020-06-24 07:05:14 -04:00
|
|
|
clippy::single_match,
|
2020-08-19 06:20:04 -04:00
|
|
|
clippy::unimplemented,
|
2020-11-16 03:25:55 -05:00
|
|
|
clippy::option_if_let_else,
|
2022-05-31 09:50:48 -04:00
|
|
|
clippy::branches_sharing_code,
|
2022-09-02 17:00:07 -04:00
|
|
|
clippy::derive_partial_eq_without_eq,
|
2020-03-30 15:43:15 -04:00
|
|
|
|
2020-02-14 18:28:09 -05:00
|
|
|
// temporarily allowed while under heavy development.
|
|
|
|
// eventually these allows should be refactored away
|
|
|
|
// to no longer be necessary
|
|
|
|
clippy::too_many_lines,
|
|
|
|
clippy::cast_possible_truncation,
|
|
|
|
clippy::single_match_else,
|
2020-04-21 18:22:26 -04:00
|
|
|
clippy::redundant_pub_crate,
|
2020-07-03 12:56:19 -04:00
|
|
|
// the api is changing too often to allot this
|
|
|
|
clippy::missing_errors_doc,
|
2020-11-16 03:25:55 -05:00
|
|
|
clippy::missing_const_for_fn,
|
2020-11-16 14:17:49 -05:00
|
|
|
clippy::multiple_crate_versions,
|
2020-05-31 05:32:19 -04:00
|
|
|
|
|
|
|
clippy::wrong_self_convention,
|
|
|
|
clippy::items_after_statements,
|
2020-07-08 22:38:56 -04:00
|
|
|
// this is only available on nightly
|
|
|
|
clippy::unnested_or_patterns,
|
2022-12-26 15:33:04 -05:00
|
|
|
clippy::uninlined_format_args,
|
|
|
|
|
|
|
|
// todo:
|
|
|
|
clippy::cast_sign_loss,
|
|
|
|
clippy::cast_lossless,
|
|
|
|
clippy::cast_precision_loss,
|
|
|
|
clippy::float_cmp,
|
|
|
|
clippy::wildcard_imports,
|
|
|
|
clippy::comparison_chain,
|
|
|
|
clippy::bool_to_int_with_if,
|
2022-12-28 17:50:25 -05:00
|
|
|
|
|
|
|
unknown_lints,
|
2020-01-20 11:00:01 -05:00
|
|
|
)]
|
|
|
|
|
2023-01-08 10:52:53 -05:00
|
|
|
pub use grass_compiler::*;
|
2022-02-04 09:41:10 +11:00
|
|
|
|
2023-01-06 10:54:34 +00:00
|
|
|
/// Include CSS in your binary at compile time from a Sass source file
|
2021-07-22 21:23:09 -04:00
|
|
|
///
|
2023-01-07 19:47:04 +00:00
|
|
|
/// ```
|
2023-01-08 00:33:39 +00:00
|
|
|
/// static CSS: &str = grass::include!("../static/_index.scss");
|
2021-07-22 21:23:09 -04:00
|
|
|
/// ```
|
2020-06-16 19:38:30 -04:00
|
|
|
///
|
2023-01-06 10:54:34 +00:00
|
|
|
/// This requires the `"macro"` feature, which is not enabled by default.
|
|
|
|
///
|
|
|
|
/// By default `grass` will track files using [`include_str!`]. This allows incremental
|
|
|
|
/// compilation to be updated when any Sass files are modified.
|
|
|
|
///
|
|
|
|
/// If compiling with a nightly version of rust, `grass` can make use of
|
|
|
|
/// [proc_macro::tracked_path](https://github.com/rust-lang/rust/issues/99515)
|
|
|
|
/// in order to force incremental recompilation, which is more robust and potentially
|
|
|
|
/// faster. This is enabled by the `"nightly"` feature.
|
|
|
|
///
|
|
|
|
/// ###### Limitations
|
|
|
|
///
|
|
|
|
/// Compilation options are not configurable with this macro. The default values
|
|
|
|
/// for all options are used, except for output style, which is compressed.
|
|
|
|
#[macro_export]
|
|
|
|
#[cfg(any(feature = "macro", doc))]
|
|
|
|
#[cfg_attr(doc, doc(cfg(feature = "macro")))]
|
|
|
|
macro_rules! include {
|
|
|
|
($path:literal) => {
|
2023-01-06 11:19:16 +00:00
|
|
|
$crate::__internal::include_sass::include_sass!($path);
|
2023-01-06 10:54:34 +00:00
|
|
|
};
|
2020-01-20 11:00:01 -05:00
|
|
|
}
|
2020-06-16 20:40:19 -04:00
|
|
|
|
2023-01-06 10:54:34 +00:00
|
|
|
#[doc(hidden)]
|
|
|
|
#[cfg(feature = "macro")]
|
2023-01-06 11:19:16 +00:00
|
|
|
pub mod __internal {
|
|
|
|
#[doc(hidden)]
|
|
|
|
pub use include_sass;
|
|
|
|
}
|