MCPcopy Index your code
hub / github.com/connorskees/grass

github.com/connorskees/grass @0.13.4

Chat with this repo
repository ↗ · DeepWiki ↗ · release 0.13.4 ↗ · + Follow
1,392 symbols 5,267 edges 178 files 111 documented · 8%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

grass

This crate aims to provide a high level interface for compiling Sass into plain CSS. It offers a very limited API, currently exposing only 2 functions.

In addition to a library, this crate also includes a binary that is intended to act as an invisible replacement to the Sass commandline executable.

This crate aims to achieve complete feature parity with the dart-sass reference implementation. A deviation from the dart-sass implementation can be considered a bug except for in the case of error messages and error spans.

Documentation
crates.io

Status

grass has reached a stage where one can be quite confident in its output. For the average user there should not be perceptible differences from dart-sass.

Every commit of grass is tested against bootstrap v5.0.2, and every release is tested against the last 2,500 commits of bootstrap's main branch.

That said, there are a number of known missing features and bugs. The rough edges of grass largely include @forward and more complex uses of @use. We support basic usage of these rules, but more advanced features such as @importing modules containing @forward with prefixes may not behave as expected.

All known missing features and bugs are tracked in #19.

grass is not a drop-in replacement for libsass and does not intend to be. If you are upgrading to grass from libsass, you may have to make modifications to your stylesheets, though these changes should not differ from those you would have to make if upgrading to dart-sass.

Performance

grass is benchmarked against dart-sass and sassc (libsass) here. In general, grass appears to be ~2x faster than dart-sass and ~1.7x faster than sassc.

Cargo Features

commandline

(enabled by default): build a binary using clap

random

(enabled by default): enable the builtin functions random([$limit]) and unique-id()

macro

(disabled by default): enable the macro grass::include! for compiling Sass to CSS at compile time

nightly

(disabled by default): currently only used by grass::include! to enable proc_macro::tracked_path

Testing

As much as possible this library attempts to follow the same philosophy for testing as rust-analyzer. Namely, all one should have to do is run cargo test to run all its tests. This library maintains a test suite distinct from the sass-spec, though it does include some spec tests verbatim. This has the benefit of allowing tests to be run without ruby as well as allowing the tests more granular than they are in the official spec.

Having said that, to run the official test suite,

# This script expects node >=v14.14.0. Check version with `node --version`
git clone https://github.com/connorskees/grass --recursive
cd grass && cargo b --release
cd sass-spec && npm install
npm run sass-spec -- --impl=dart-sass --command '../target/release/grass'

The spec runner does not work on Windows.

Using a modified version of the spec runner that ignores warnings and error spans (but does include error messages), grass achieves the following results:

2023-07-09
PASSING: 6230
FAILING: 545
TOTAL: 6905

The majority of the failing tests are purely aesthetic, relating to whitespace around comments in expanded mode or error messages.

Versioning

The minimum supported rust version (MSRV) of grass is 1.70.0. An increase to the MSRV will correspond with a minor version bump. The current MSRV is not a hard minimum, but future bugfix versions of grass are not guaranteed to work on versions prior to this.

grass currently targets dart-sass version 1.54.3. An increase to this number will correspond to either a minor or bugfix version bump, depending on the changes.

Extension points exported contracts — how you extend this code

Fs (Interface)
A trait to allow replacing the file system lookup mechanisms. As it stands, this is imperfect: it’s still using the typ [4 …
crates/compiler/src/fs.rs
MapView (Interface)
(no doc) [7 implementers]
crates/compiler/src/utils/map_view.rs
BaseParser (Interface)
(no doc) [7 implementers]
crates/compiler/src/parse/base.rs
Logger (Interface)
A trait to allow replacing logging mechanisms [3 implementers]
crates/compiler/src/logger.rs
StylesheetParser (Interface)
Default implementations are oriented towards the SCSS syntax, as both CSS and SCSS share the behavior [3 implementers]
crates/compiler/src/parse/stylesheet.rs

Core symbols most depended-on inside this repo

toks_mut
called by 290
crates/compiler/src/parse/css.rs
span
called by 256
crates/compiler/src/ast/args.rs
clone
called by 243
crates/compiler/src/utils/map_view.rs
toks
called by 204
crates/compiler/src/parse/css.rs
next
called by 172
crates/compiler/src/lexer.rs
get_err
called by 146
crates/compiler/src/ast/args.rs
span_from
called by 141
crates/compiler/src/lexer.rs
whitespace
called by 137
crates/compiler/src/parse/base.rs

Shape

Method 894
Function 331
Class 121
Enum 40
Interface 6

Languages

Rust100%

Modules by API surface

crates/compiler/src/parse/stylesheet.rs87 symbols
crates/compiler/src/evaluate/visitor.rs83 symbols
crates/compiler/src/ast/stmt.rs57 symbols
crates/compiler/src/serializer.rs56 symbols
crates/compiler/src/value/number.rs47 symbols
crates/lib/tests/use.rs41 symbols
crates/compiler/src/parse/value.rs39 symbols
crates/compiler/src/builtin/modules/mod.rs38 symbols
crates/compiler/src/color/mod.rs37 symbols
crates/compiler/src/value/mod.rs32 symbols
crates/compiler/src/parse/base.rs31 symbols
crates/compiler/src/parse/sass.rs30 symbols

For agents

$ claude mcp add grass \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact