Skip to content

Commit 4db7935

Browse files
authored
Merge pull request #1413 from sass/sass-api
Add a sass_api package that exposes more API details
2 parents 6f17b4a + 632a041 commit 4db7935

File tree

101 files changed

+1099
-222
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+1099
-222
lines changed

.github/workflows/ci.yml

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,9 @@ jobs:
121121
steps:
122122
- uses: actions/checkout@v2
123123
- uses: dart-lang/setup-dart@v1
124-
# TODO(nweiz): Use the latest Dart when dart-lang/sdk#45488
125-
with: {sdk: 2.12.4}
126124
- run: dart pub get
127-
- name: Analyze dart
128-
run: dartanalyzer --fatal-warnings --fatal-infos lib tool test
125+
- name: Analyze Dart
126+
run: dart analyze --fatal-warnings --fatal-infos .
129127

130128
dartdoc:
131129
name: Dartdoc
@@ -135,10 +133,14 @@ jobs:
135133
- uses: actions/checkout@v2
136134
- uses: dart-lang/setup-dart@v1
137135
- run: dart pub get
138-
- name: Run dartdoc
136+
- name: dartdoc sass
139137
run: dartdoc --quiet --no-generate-docs
140138
--errors ambiguous-doc-reference,broken-link,deprecated
141139
--errors unknown-directive,unknown-macro,unresolved-doc-reference
140+
- name: dartdoc sass_api
141+
run: cd pkg/sass_api && dartdoc --quiet --no-generate-docs
142+
--errors ambiguous-doc-reference,broken-link,deprecated
143+
--errors unknown-directive,unknown-macro,unresolved-doc-reference
142144

143145
sanity_checks:
144146
name: Sanity checks
@@ -252,6 +254,23 @@ jobs:
252254
run: dart pub run grinder pkg-pub-deploy
253255
env: {PUB_CREDENTIALS: "${{ secrets.PUB_CREDENTIALS }}"}
254256

257+
deploy_sub_packages:
258+
name: "Deploy Sub-Packages"
259+
runs-on: ubuntu-latest
260+
needs: [deploy_pub]
261+
if: "startsWith(github.ref, 'refs/tags/') && github.repository == 'sass/dart-sass'"
262+
263+
steps:
264+
- uses: actions/checkout@v2
265+
- uses: dart-lang/setup-dart@v1
266+
- run: dart pub get
267+
- name: Deploy
268+
run: dart pub run grinder deploy-sub-packages
269+
env:
270+
PUB_CREDENTIALS: "${{ secrets.PUB_CREDENTIALS }}"
271+
GH_TOKEN: "${{ secrets.GH_TOKEN }}"
272+
GH_USER: sassbot
273+
255274
deploy_homebrew:
256275
name: "Deploy Homebrew"
257276
runs-on: ubuntu-latest

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ package-lock.json
1313
/benchmark/source
1414
node_modules/
1515
/doc/api
16+
/pkg/*/doc/api

CONTRIBUTING.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Want to contribute? Great! First, read this page.
88
* [Changing the Node API](#changing-the-node-api)
99
* [Synchronizing](#synchronizing)
1010
* [File Headers](#file-headers)
11+
* [Release Process](#release-process)
1112

1213
## Before You Contribute
1314

@@ -208,3 +209,27 @@ All files in the project must start with the following header.
208209
// MIT-style license that can be found in the LICENSE file or at
209210
// https://opensource.org/licenses/MIT.
210211
```
212+
213+
## Release Process
214+
215+
Most of the release process is fully automated on GitHub actions, triggered by
216+
pushing a tag matching the current `pubspec.yaml` version. However, there are a
217+
few things to do before pushing that tag:
218+
219+
* Make sure the `pubspec.yaml` version doesn't end in `-dev`. (This is a Dart
220+
convention to distinguish commits that aren't meant for release from commits
221+
that are.)
222+
223+
* Make sure that `CHANGELOG.md` has an entry for the current version.
224+
225+
* Make sure that any packages in `pkg` depend on the current version of `sass`.
226+
227+
* Increment the versions of all packages in `pkg`. These should be incremented
228+
at least as much as the `sass` version, and more if you add a new API that's
229+
exposed by one of those packages.
230+
231+
* Make sure that every package in `pkg`'s `CHANGELOG.md` has an entry for its
232+
current version.
233+
234+
You *don't* need to create tags for packages in `pkg`; that will be handled
235+
automatically by GitHub actions.

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ A [Dart][dart] implementation of [Sass][sass]. **Sass makes CSS fun again**.
3232
* [Standalone](#standalone)
3333
* [From npm](#from-npm)
3434
* [From Pub](#from-pub)
35+
* [`sass_api` Package](#sass_api-package)
3536
* [From Source](#from-source)
3637
* [JavaScript API](#javascript-api)
3738
* [Why Dart?](#why-dart)
@@ -129,6 +130,15 @@ See [the Dart API docs][api] for details.
129130

130131
[api]: https://www.dartdocs.org/documentation/sass/latest/sass/sass-library.html
131132

133+
#### `sass_api` Package
134+
135+
Dart users also have access to more in-depth APIs via the [`sass_api` package].
136+
This provides access to the Sass AST and APIs for resolving Sass loads without
137+
running a full compilation. It's separated out into its own package so that it
138+
can increase its version number independently of the main `sass` package.
139+
140+
[`sass_api` package]: https://pub.dev/package/sass_api
141+
132142
### From Source
133143

134144
Assuming you've already checked out this repository:

lib/src/ast/node.dart

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,18 @@
22
// MIT-style license that can be found in the LICENSE file or at
33
// https://opensource.org/licenses/MIT.
44

5+
import 'package:meta/meta.dart';
56
import 'package:source_span/source_span.dart';
67

78
/// A node in an abstract syntax tree.
9+
///
10+
/// Note: although all nodes have `toString()` methods that generally reflect
11+
/// their source text, these methods should only be used for debugging and not
12+
/// for creating Sass source code. They aren't tested and are not guaranteed to
13+
/// remain stable over time.
14+
///
15+
/// {@category AST}
16+
@sealed
817
abstract class AstNode {
918
/// The source span associated with the node.
1019
///
@@ -18,6 +27,9 @@ abstract class AstNode {
1827
/// A number of APIs take [AstNode]s instead of spans because computing spans
1928
/// eagerly can be expensive. This allows arbitrary spans to be passed to
2029
/// those callbacks while still being lazily computed.
30+
///
31+
/// @nodoc
32+
@internal
2133
factory AstNode.fake(FileSpan Function() callback) = _FakeAstNode;
2234

2335
AstNode();

lib/src/ast/sass/argument.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,17 @@
22
// MIT-style license that can be found in the LICENSE file or at
33
// https://opensource.org/licenses/MIT.
44

5+
import 'package:meta/meta.dart';
56
import 'package:source_span/source_span.dart';
67

78
import '../../utils.dart';
89
import 'expression.dart';
910
import 'node.dart';
1011

1112
/// An argument declared as part of an [ArgumentDeclaration].
13+
///
14+
/// {@category AST}
15+
@sealed
1216
class Argument implements SassNode {
1317
/// The argument name.
1418
final String name;

lib/src/ast/sass/argument_declaration.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// MIT-style license that can be found in the LICENSE file or at
33
// https://opensource.org/licenses/MIT.
44

5+
import 'package:meta/meta.dart';
56
import 'package:source_span/source_span.dart';
67

78
import '../../exception.dart';
@@ -13,6 +14,10 @@ import 'argument.dart';
1314
import 'node.dart';
1415

1516
/// An argument declaration, as for a function or mixin definition.
17+
///
18+
/// {@category AST}
19+
/// {@category Parsing}
20+
@sealed
1621
class ArgumentDeclaration implements SassNode {
1722
/// The arguments that are taken.
1823
final List<Argument> arguments;

lib/src/ast/sass/argument_invocation.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,16 @@
22
// MIT-style license that can be found in the LICENSE file or at
33
// https://opensource.org/licenses/MIT.
44

5+
import 'package:meta/meta.dart';
56
import 'package:source_span/source_span.dart';
67

78
import 'expression.dart';
89
import 'node.dart';
910

1011
/// A set of arguments passed in to a function or mixin.
12+
///
13+
/// {@category AST}
14+
@sealed
1115
class ArgumentInvocation implements SassNode {
1216
/// The arguments passed by position.
1317
final List<Expression> positional;

lib/src/ast/sass/at_root_query.dart

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// MIT-style license that can be found in the LICENSE file or at
33
// https://opensource.org/licenses/MIT.
44

5+
import 'package:meta/meta.dart';
56
import 'package:collection/collection.dart';
67

78
import '../../exception.dart';
@@ -10,6 +11,9 @@ import '../../parse/at_root_query.dart';
1011
import '../css.dart';
1112

1213
/// A query for the `@at-root` rule.
14+
///
15+
/// @nodoc
16+
@internal
1317
class AtRootQuery {
1418
/// The default at-root query, which excludes only style rules.
1519
static const defaultQuery = AtRootQuery._default();
@@ -34,7 +38,7 @@ class AtRootQuery {
3438
/// Note that this takes [include] into account.
3539
bool get excludesStyleRules => (_all || _rule) != include;
3640

37-
AtRootQuery(this.include, Set<String> names)
41+
AtRootQuery(Set<String> names, {required this.include})
3842
: names = names,
3943
_all = names.contains("all"),
4044
_rule = names.contains("rule");
@@ -55,6 +59,9 @@ class AtRootQuery {
5559
AtRootQueryParser(contents, url: url, logger: logger).parse();
5660

5761
/// Returns whether [this] excludes [node].
62+
///
63+
/// @nodoc
64+
@internal
5865
bool excludes(CssParentNode node) {
5966
if (_all) return !include;
6067
if (node is CssStyleRule) return excludesStyleRules;

lib/src/ast/sass/callable_invocation.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,15 @@
22
// MIT-style license that can be found in the LICENSE file or at
33
// https://opensource.org/licenses/MIT.
44

5+
import 'package:meta/meta.dart';
6+
57
import 'argument_invocation.dart';
68
import 'node.dart';
79

810
/// An abstract class for invoking a callable (a function or mixin).
11+
///
12+
/// {@category AST}
13+
@sealed
914
abstract class CallableInvocation implements SassNode {
1015
/// The arguments passed to the callable.
1116
ArgumentInvocation get arguments;

lib/src/ast/sass/configured_variable.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,16 @@
22
// MIT-style license that can be found in the LICENSE file or at
33
// https://opensource.org/licenses/MIT.
44

5+
import 'package:meta/meta.dart';
56
import 'package:source_span/source_span.dart';
67

78
import 'expression.dart';
89
import 'node.dart';
910

1011
/// A variable configured by a `with` clause in a `@use` or `@forward` rule.
12+
///
13+
/// {@category AST}
14+
@sealed
1115
class ConfiguredVariable implements SassNode {
1216
/// The name of the variable being configured.
1317
final String name;

lib/src/ast/sass/expression.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,19 @@
22
// MIT-style license that can be found in the LICENSE file or at
33
// https://opensource.org/licenses/MIT.
44

5+
import 'package:meta/meta.dart';
6+
57
import '../../exception.dart';
68
import '../../logger.dart';
79
import '../../parse/scss.dart';
810
import '../../visitor/interface/expression.dart';
911
import 'node.dart';
1012

1113
/// A SassScript expression in a Sass syntax tree.
14+
///
15+
/// {@category AST}
16+
/// {@category Parsing}
17+
@sealed
1218
abstract class Expression implements SassNode {
1319
/// Calls the appropriate visit method on [visitor].
1420
T accept<T>(ExpressionVisitor<T> visitor);

lib/src/ast/sass/expression/binary_operation.dart

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,17 @@
22
// MIT-style license that can be found in the LICENSE file or at
33
// https://opensource.org/licenses/MIT.
44

5-
import 'package:source_span/source_span.dart';
65
import 'package:charcode/charcode.dart';
6+
import 'package:meta/meta.dart';
7+
import 'package:source_span/source_span.dart';
78

89
import '../../../visitor/interface/expression.dart';
910
import '../expression.dart';
1011

1112
/// A binary operator, as in `1 + 2` or `$this and $other`.
13+
///
14+
/// {@category AST}
15+
@sealed
1216
class BinaryOperationExpression implements Expression {
1317
/// The operator being invoked.
1418
final BinaryOperator operator;
@@ -21,6 +25,9 @@ class BinaryOperationExpression implements Expression {
2125

2226
/// Whether this is a [BinaryOperator.dividedBy] operation that may be
2327
/// interpreted as slash-separated numbers.
28+
///
29+
/// @nodoc
30+
@internal
2431
final bool allowsSlash;
2532

2633
FileSpan get span {
@@ -43,6 +50,9 @@ class BinaryOperationExpression implements Expression {
4350

4451
/// Creates a [BinaryOperator.dividedBy] operation that may be interpreted as
4552
/// slash-separated numbers.
53+
///
54+
/// @nodoc
55+
@internal
4656
BinaryOperationExpression.slash(this.left, this.right)
4757
: operator = BinaryOperator.dividedBy,
4858
allowsSlash = true;
@@ -76,6 +86,9 @@ class BinaryOperationExpression implements Expression {
7686
}
7787

7888
/// A binary operator constant.
89+
///
90+
/// {@category AST}
91+
@sealed
7992
class BinaryOperator {
8093
/// The Microsoft equals operator, `=`.
8194
static const singleEquals = BinaryOperator._("single equals", "=", 0);

lib/src/ast/sass/expression/boolean.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,16 @@
22
// MIT-style license that can be found in the LICENSE file or at
33
// https://opensource.org/licenses/MIT.
44

5+
import 'package:meta/meta.dart';
56
import 'package:source_span/source_span.dart';
67

78
import '../../../visitor/interface/expression.dart';
89
import '../expression.dart';
910

1011
/// A boolean literal, `true` or `false`.
12+
///
13+
/// {@category AST}
14+
@sealed
1115
class BooleanExpression implements Expression {
1216
/// The value of this expression.
1317
final bool value;

lib/src/ast/sass/expression/color.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,17 @@
22
// MIT-style license that can be found in the LICENSE file or at
33
// https://opensource.org/licenses/MIT.
44

5+
import 'package:meta/meta.dart';
56
import 'package:source_span/source_span.dart';
67

78
import '../../../value.dart';
89
import '../../../visitor/interface/expression.dart';
910
import '../expression.dart';
1011

1112
/// A color literal.
13+
///
14+
/// {@category AST}
15+
@sealed
1216
class ColorExpression implements Expression {
1317
/// The value of this color.
1418
final SassColor value;

lib/src/ast/sass/expression/function.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// MIT-style license that can be found in the LICENSE file or at
33
// https://opensource.org/licenses/MIT.
44

5+
import 'package:meta/meta.dart';
56
import 'package:source_span/source_span.dart';
67

78
import '../../../visitor/interface/expression.dart';
@@ -13,6 +14,9 @@ import '../interpolation.dart';
1314
/// A function invocation.
1415
///
1516
/// This may be a plain CSS function or a Sass function.
17+
///
18+
/// {@category AST}
19+
@sealed
1620
class FunctionExpression implements Expression, CallableInvocation {
1721
/// The namespace of the function being invoked, or `null` if it's invoked
1822
/// without a namespace.

0 commit comments

Comments
 (0)