Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support @use for builtin modules #80

Merged
merged 16 commits into from
Nov 2, 2020
Merged

Support @use for builtin modules #80

merged 16 commits into from
Nov 2, 2020

Conversation

kaj
Copy link
Owner

@kaj kaj commented Oct 30, 2020

A part of #60 .

This PR only deals with builtin modules.

  • Parse the @use statement to an Item.
  • Provide all the builtin modules.
  • Use correct names for existing functions in the modules and in the global scope (some differ).
  • Provide all expected functions in the standard module, or note exceptions in Support the @use directive #60.

@kaj kaj marked this pull request as draft October 30, 2020 22:21
Note that the contents of the modules is still lacking a lot.  So far,
it's just the globally availiable functions spread out over their
modules.
And expose the correct funtions globally under correct names.
And expose the correct funtions globally under correct names.
Some functions remain to be implemented, though.
And expose the correct funtions globally under correct names.
Implemented the `clamp`, `log`, `pow`, and `sqrt` functions.
src/functions/math.rs Outdated Show resolved Hide resolved
@kaj kaj marked this pull request as ready for review November 1, 2020 20:49
@kaj
Copy link
Owner Author

kaj commented Nov 1, 2020

I'm considering merging this without further improvements to the actual functions. That can always be done later.

Any thoughts on the "module system" itself? I know that it is rather sketchy and only handles functions, so I think a Module should be a struct and not just a type alias for a map. But that may also be an area for future improvements.

@glebm
Copy link
Contributor

glebm commented Nov 1, 2020

This is the first Sass implementation to begin implementing modules, so this is uncharted territory!

Doesn't have to be perfect before merging 👍

@kaj kaj mentioned this pull request Nov 2, 2020
The standard `to_upper_case` and `to_lower_case` sass:string functions
only changes ascii letters, everything else remains as-is.

Also added `to_upper_case_unicode` and `to_lower_case_unicode` for
proper unicode-aware case switching.
@kaj kaj merged commit ee06fff into master Nov 2, 2020
@kaj kaj deleted the use-builtin-modules branch November 2, 2020 10:19
kaj added a commit that referenced this pull request Nov 10, 2020
Progress: 2718 of 5840 tests passed in dart-sass compatiblilty mode.

### Breaking changes

* `SourceName` and `sass::Item::Import` was changed by #62.
* `Use` was added to the `sass::Item` enum by #80.
* Changes to `sass::Value` and `css::Vaue` by #81.

### Improvements

* PR #80: Implement `@use` for standard sass modules.  All standard
  modules are at least partially supported, only `sass:string` is
  fully supported.  See issue #60 for for module support status.
* PR 82: Implement hwb support in `sass:color`.
  Also, provide `From<Rgba>` for `css::Value` and deprecate color
  value constructors.
* Provide `From<bool>` for `css::Value` (and deprecate `Value::bool(v)`).
* PR #62: Improve `ParseError`, `SourcePos`, and `SourceName` by using
  located spans by [nom_locate](https://lib.rs/crates/nom_locate) in
  the parser.  A `sass::Item::Import` now handles where each file is
  imported from, to improve error reporting.
* PR #81: Improved number handlig.  Now `Value::Number` handles both
  machine-sized rationals, bignum rationals and floats internally and
  `Value::NumberBig` is removed.  Also, `Value` no longer implemnts
  `Ord` but only `PartialOrd`, to handle f64 NaN an infinite values
  correctly.
* Improve parsing of `@else` clauses.
* Update spec to 2020-10-29.

Tested with rustc 1.47.0 (18bf6b4f0 2020-10-07),
1.44.1 (c7087fe00 2020-06-17), 1.42.0 (b8cedc004 2020-03-09),
1.40.0 (73528e339 2019-12-16), 1.38.0 (625451e37 2019-09-23),
1.48.0-beta.8 (121901459 2020-11-08), and
1.49.0-nightly (25f6938da 2020-11-09),
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants