Skip to content

Commit 6f17b4a

Browse files
authored
Merge pull request #1412 from sass/dartdoc
Improve dartdoc and fix a couple API issues
2 parents 87e93a1 + e02d8b4 commit 6f17b4a

Some content is hidden

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

42 files changed

+159
-21
lines changed

.github/workflows/ci.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,23 @@ jobs:
127127
- name: Analyze dart
128128
run: dartanalyzer --fatal-warnings --fatal-infos lib tool test
129129

130+
dartdoc:
131+
name: Dartdoc
132+
runs-on: ubuntu-latest
133+
134+
steps:
135+
- uses: actions/checkout@v2
136+
- uses: dart-lang/setup-dart@v1
137+
- run: dart pub get
138+
- name: Run dartdoc
139+
run: dartdoc --quiet --no-generate-docs
140+
--errors ambiguous-doc-reference,broken-link,deprecated
141+
--errors unknown-directive,unknown-macro,unresolved-doc-reference
142+
130143
sanity_checks:
131144
name: Sanity checks
132145
runs-on: ubuntu-latest
133-
needs: [sass_spec, dart_tests, node_tests, static_analysis]
146+
needs: [sass_spec, dart_tests, node_tests, static_analysis, dartdoc]
134147
if: "startsWith(github.ref, 'refs/tags/') && github.repository == 'sass/dart-sass'"
135148

136149
steps:

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ pubspec.lock
1212
package-lock.json
1313
/benchmark/source
1414
node_modules/
15+
/doc/api

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
## 1.37.0
2+
3+
### Dart API
4+
5+
* **Potentially breaking bug fix:** `SassNumber.asSlash`,
6+
`SassNumber.withSlash()`, and `SassNumber.withoutSlash()` have been marked as
7+
`@internal`. They were never intended to be used outside the `sass` package.
8+
9+
* **Potentially breaking bug fix:** `SassException` has been marked as `@sealed`
10+
to formally indicate that it's not intended to be extended outside of the
11+
`sass` package.
12+
13+
* Add a `Value.withListContents()` method that returns a new Sass list with the
14+
same list separator and brackets as the current value, interpreted as a list.
15+
116
## 1.36.0
217

318
### Dart API

dartdoc_options.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
dartdoc:
2+
categories:
3+
Compile:
4+
markdown: doc/compile.md
5+
Importer:
6+
markdown: doc/importer.md
7+
Value:
8+
markdown: doc/value.md

doc/compile.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
APIs for compiling Sass source files to CSS, and providing options for that
2+
compilation.

doc/importer.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Classes for defining custom logic for resolving `@use`, `@forward`, and
2+
`@import` rules in Sass. See [`Importer`] for details on the importer API
3+
contract.
4+
5+
[`Importer`]: ../sass/Importer-class.html

doc/value.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Classes that represent Sass values. These are passed to and returned by
2+
user-defined [`Callable`]s that are passed to functions like
3+
[`compileToResult()`].
4+
5+
[`Callable`]: ../sass/Callable-class.html
6+
[`compileToResult()`]: ../sass/compileToResult.html

lib/sass.dart

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ export 'src/warn.dart' show warn;
7676
/// correspond to which in the resulting CSS. [SingleMapping.targetUrl] will be
7777
/// `null`. It's up to the caller to save this mapping to disk and add a source
7878
/// map comment to [CompileResult.css] pointing to it. Users using the
79-
/// [SourceMap] API should be sure to add the [`source_maps`][] package to their
80-
/// pubspec.
79+
/// [SingleMapping] API should be sure to add the [`source_maps`][] package to
80+
/// their pubspec.
8181
///
8282
/// [`source_maps`]: https://pub.dartlang.org/packages/source_maps
8383
///
@@ -89,6 +89,8 @@ export 'src/warn.dart' show warn;
8989
/// [byte-order mark]: https://en.wikipedia.org/wiki/Byte_order_mark#UTF-8
9090
///
9191
/// Throws a [SassException] if conversion fails.
92+
///
93+
/// {@category Compile}
9294
CompileResult compileToResult(String path,
9395
{bool color = false,
9496
Logger? logger,
@@ -166,8 +168,8 @@ CompileResult compileToResult(String path,
166168
/// correspond to which in the resulting CSS. [SingleMapping.targetUrl] will be
167169
/// `null`. It's up to the caller to save this mapping to disk and add a source
168170
/// map comment to [CompileResult.css] pointing to it. Users using the
169-
/// [SourceMap] API should be sure to add the [`source_maps`][] package to their
170-
/// pubspec.
171+
/// [SingleMapping] API should be sure to add the [`source_maps`][] package to
172+
/// their pubspec.
171173
///
172174
/// [`source_maps`]: https://pub.dartlang.org/packages/source_maps
173175
///
@@ -179,6 +181,8 @@ CompileResult compileToResult(String path,
179181
/// [byte-order mark]: https://en.wikipedia.org/wiki/Byte_order_mark#UTF-8
180182
///
181183
/// Throws a [SassException] if conversion fails.
184+
///
185+
/// {@category Compile}
182186
CompileResult compileStringToResult(String source,
183187
{Syntax? syntax,
184188
bool color = false,
@@ -245,6 +249,8 @@ Future<CompileResult> compileToResultAsync(String path,
245249
/// Running asynchronously allows this to take [AsyncImporter]s rather than
246250
/// synchronous [Importer]s. However, running asynchronously is also somewhat
247251
/// slower, so [compileStringToResult] should be preferred if possible.
252+
///
253+
/// {@category Compile}
248254
Future<CompileResult> compileStringToResultAsync(String source,
249255
{Syntax? syntax,
250256
bool color = false,
@@ -284,7 +290,7 @@ Future<CompileResult> compileStringToResultAsync(String source,
284290
/// sections of the source file(s) correspond to which in the resulting CSS.
285291
/// It's called immediately before this method returns, and only if compilation
286292
/// succeeds. Note that [SingleMapping.targetUrl] will always be `null`. Users
287-
/// using the [SourceMap] API should be sure to add the [`source_maps`][]
293+
/// using the [SingleMapping] API should be sure to add the [`source_maps`][]
288294
/// package to their pubspec.
289295
///
290296
/// [`source_maps`]: https://pub.dartlang.org/packages/source_maps
@@ -296,6 +302,8 @@ Future<CompileResult> compileStringToResultAsync(String source,
296302
/// SingleMapping sourceMap;
297303
/// var css = compile(sassPath, sourceMap: (map) => sourceMap = map);
298304
/// ```
305+
///
306+
/// {@category Compile}
299307
@Deprecated("Use compileToResult() instead.")
300308
String compile(
301309
String path,
@@ -333,7 +341,7 @@ String compile(
333341
/// sections of the source file(s) correspond to which in the resulting CSS.
334342
/// It's called immediately before this method returns, and only if compilation
335343
/// succeeds. Note that [SingleMapping.targetUrl] will always be `null`. Users
336-
/// using the [SourceMap] API should be sure to add the [`source_maps`][]
344+
/// using the [SingleMapping] API should be sure to add the [`source_maps`][]
337345
/// package to their pubspec.
338346
///
339347
/// [`source_maps`]: https://pub.dartlang.org/packages/source_maps
@@ -345,6 +353,8 @@ String compile(
345353
/// SingleMapping sourceMap;
346354
/// var css = compileString(sass, sourceMap: (map) => sourceMap = map);
347355
/// ```
356+
///
357+
/// {@category Compile}
348358
@Deprecated("Use compileStringToResult() instead.")
349359
String compileString(
350360
String source,
@@ -388,6 +398,8 @@ String compileString(
388398
/// Running asynchronously allows this to take [AsyncImporter]s rather than
389399
/// synchronous [Importer]s. However, running asynchronously is also somewhat
390400
/// slower, so [compile] should be preferred if possible.
401+
///
402+
/// {@category Compile}
391403
@Deprecated("Use compileToResultAsync() instead.")
392404
Future<String> compileAsync(
393405
String path,
@@ -421,6 +433,8 @@ Future<String> compileAsync(
421433
/// Running asynchronously allows this to take [AsyncImporter]s rather than
422434
/// synchronous [Importer]s. However, running asynchronously is also somewhat
423435
/// slower, so [compileString] should be preferred if possible.
436+
///
437+
/// {@category Compile}
424438
@Deprecated("Use compileStringToResultAsync() instead.")
425439
Future<String> compileStringAsync(
426440
String source,

lib/src/ast/sass/at_root_query.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import 'package:collection/collection.dart';
66

7+
import '../../exception.dart';
78
import '../../logger.dart';
89
import '../../parse/at_root_query.dart';
910
import '../css.dart';

lib/src/ast/sass/expression.dart

Lines changed: 1 addition & 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 '../../exception.dart';
56
import '../../logger.dart';
67
import '../../parse/scss.dart';
78
import '../../visitor/interface/expression.dart';

lib/src/ast/sass/statement/stylesheet.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,17 @@ import 'dart:collection';
66

77
import 'package:source_span/source_span.dart';
88

9-
import '../../../visitor/interface/statement.dart';
9+
import '../../../exception.dart';
1010
import '../../../logger.dart';
1111
import '../../../parse/css.dart';
1212
import '../../../parse/sass.dart';
1313
import '../../../parse/scss.dart';
1414
import '../../../syntax.dart';
15+
import '../../../visitor/interface/statement.dart';
1516
import '../statement.dart';
16-
import 'parent.dart';
1717
import 'forward_rule.dart';
1818
import 'loud_comment.dart';
19+
import 'parent.dart';
1920
import 'silent_comment.dart';
2021
import 'use_rule.dart';
2122
import 'variable_declaration.dart';

lib/src/ast/sass/statement/use_rule.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import 'package:source_span/source_span.dart';
66

7+
import '../../../exception.dart';
78
import '../../../logger.dart';
89
import '../../../parse/scss.dart';
910
import '../../../visitor/interface/statement.dart';

lib/src/ast/sass/statement/variable_declaration.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import 'package:source_span/source_span.dart';
66

7+
import '../../../exception.dart';
78
import '../../../logger.dart';
89
import '../../../parse/scss.dart';
910
import '../../../utils.dart';

lib/src/callable.dart

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import 'package:meta/meta.dart';
66

77
import 'callable/async.dart';
88
import 'callable/built_in.dart';
9+
import 'exception.dart';
910
import 'value.dart';
1011

1112
export 'callable/async.dart';
@@ -41,8 +42,8 @@ export 'callable/user_defined.dart';
4142
/// * When manipulating values like lists, strings, and numbers that have
4243
/// metadata (comma versus space separated, bracketed versus unbracketed,
4344
/// quoted versus unquoted, units), the output metadata should match the input
44-
/// metadata. For lists, the [Value.changeList] method can be used to do this
45-
/// automatically.
45+
/// metadata. For lists, the [Value.withListContents] method can be used to do
46+
/// this automatically.
4647
///
4748
/// * When in doubt, lists should default to comma-separated, strings should
4849
/// default to quoted, and number should default to unitless.
@@ -62,6 +63,8 @@ export 'callable/user_defined.dart';
6263
/// [SassString.sassIndexToRuneIndex] methods can be used to do this
6364
/// automatically, and the [SassString.sassLength] getter can be used to
6465
/// access a string's length in code points.
66+
///
67+
/// {@category Compile}
6568
@sealed
6669
abstract class Callable extends AsyncCallable {
6770
@Deprecated('Use `Callable.function` instead.')

lib/src/callable/async.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import 'dart:async';
66

77
import 'package:meta/meta.dart';
88

9+
import '../exception.dart';
910
import '../value.dart';
1011
import 'async_built_in.dart';
1112

@@ -17,6 +18,8 @@ import 'async_built_in.dart';
1718
/// work synchronously, it should be a [Callable] instead.
1819
///
1920
/// See [Callable] for more details.
21+
///
22+
/// {@category Compile}
2023
@sealed
2124
abstract class AsyncCallable {
2225
/// The callable's name.

lib/src/compile_result.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import 'visitor/serialize.dart';
1010

1111
/// The result of compiling a Sass document to CSS, along with metadata about
1212
/// the compilation process.
13+
///
14+
/// {@category Compile}
1315
@sealed
1416
class CompileResult {
1517
/// The result of evaluating the source file.

lib/src/exception.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// https://opensource.org/licenses/MIT.
44

55
import 'package:charcode/charcode.dart';
6+
import 'package:meta/meta.dart';
67
import 'package:source_span/source_span.dart';
78
import 'package:stack_trace/stack_trace.dart';
89
import 'package:term_glyph/term_glyph.dart' as term_glyph;
@@ -12,6 +13,9 @@ import 'utils.dart';
1213
import 'value.dart';
1314

1415
/// An exception thrown by Sass.
16+
///
17+
/// {@category Compile}
18+
@sealed
1519
class SassException extends SourceSpanException {
1620
/// The Sass stack trace at the point this exception was thrown.
1721
///

lib/src/functions/list.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ final _setNth = _function("set-nth", r"$list, $n, $value", (arguments) {
3838
var value = arguments[2];
3939
var newList = list.asList.toList();
4040
newList[list.sassIndexToListIndex(index, "n")] = value;
41-
return arguments[0].changeListContents(newList);
41+
return arguments[0].withListContents(newList);
4242
});
4343

4444
final _join = _function(
@@ -99,7 +99,7 @@ final _append =
9999
}
100100

101101
var newList = [...list.asList, value];
102-
return list.changeListContents(newList, separator: separator);
102+
return list.withListContents(newList, separator: separator);
103103
});
104104

105105
final _zip = _function("zip", r"$lists...", (arguments) {

lib/src/importer.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ export 'importer/result.dart';
2424
/// [AsyncImporter] if possible.
2525
///
2626
/// Subclasses should extend [Importer], not implement it.
27+
///
28+
/// {@category Importer}
2729
abstract class Importer extends AsyncImporter {
2830
/// An importer that never imports any stylesheets.
2931
///

lib/src/importer/async.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ import 'utils.dart' as utils;
2222
/// instead.
2323
///
2424
/// Subclasses should extend [AsyncImporter], not implement it.
25+
///
26+
/// {@category Importer}
2527
abstract class AsyncImporter {
2628
/// Whether the current [canonicalize] invocation comes from an `@import`
2729
/// rule.

lib/src/importer/filesystem.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import '../util/nullable.dart';
1212
import 'utils.dart';
1313

1414
/// An importer that loads files from a load path on the filesystem.
15+
///
16+
/// {@category Importer}
1517
@sealed
1618
class FilesystemImporter extends Importer {
1719
/// The path relative to which this importer looks for files.

lib/src/importer/package.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import '../importer.dart';
1414
final _filesystemImporter = FilesystemImporter('.');
1515

1616
/// An importer that loads stylesheets from `package:` imports.
17+
///
18+
/// {@category Importer}
1719
@sealed
1820
class PackageImporter extends Importer {
1921
/// The resolver that converts `package:` imports to `file:`.
@@ -24,7 +26,8 @@ class PackageImporter extends Importer {
2426
/// package.
2527
///
2628
/// [`PackageConfig`]: https://pub.dev/documentation/package_config/latest/package_config.package_config/PackageConfig-class.html
27-
PackageImporter(this._packageConfig);
29+
PackageImporter(PackageConfig packageConfig)
30+
: _packageConfig = packageConfig;
2831

2932
Uri? canonicalize(Uri url) {
3033
if (url.scheme == 'file') return _filesystemImporter.canonicalize(url);

lib/src/importer/result.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import '../importer.dart';
1010
import '../syntax.dart';
1111

1212
/// The result of importing a Sass stylesheet, as returned by [Importer.load].
13+
///
14+
/// {@category Importer}
1315
@sealed
1416
class ImporterResult {
1517
/// The contents of the stylesheet.

lib/src/logger.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import 'logger/stderr.dart';
1010
/// An interface for loggers that print messages produced by Sass stylesheets.
1111
///
1212
/// This may be implemented by user code.
13+
///
14+
/// {@category Compile}
1315
abstract class Logger {
1416
/// A logger that silently ignores all messages.
1517
static final Logger quiet = _QuietLogger();

lib/src/node/value/list.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ final Function listConstructor = createClass('SassList',
3434
'setValue': (_NodeSassList thisArg, int index, Object value) {
3535
var mutable = thisArg.dartValue.asList.toList();
3636
mutable[index] = unwrapValue(value);
37-
thisArg.dartValue = thisArg.dartValue.changeListContents(mutable);
37+
thisArg.dartValue = thisArg.dartValue.withListContents(mutable);
3838
},
3939
'getSeparator': (_NodeSassList thisArg) =>
4040
thisArg.dartValue.separator == ListSeparator.comma,

0 commit comments

Comments
 (0)