Skip to content

Commit

Permalink
Add dartdoc categories to Sass APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
nex3 committed Jul 30, 2021
1 parent 87e93a1 commit a28c656
Show file tree
Hide file tree
Showing 33 changed files with 104 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ pubspec.lock
package-lock.json
/benchmark/source
node_modules/
/doc/api
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## 1.36.1

### Dart API

* **Potentially breaking bug fix:** `SassException` has been marked as `@sealed`
to formally indicate that it's not intended to be extended outside of the
`sass` package.

## 1.36.0

### Dart API
Expand Down
8 changes: 8 additions & 0 deletions dartdoc_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
dartdoc:
categories:
Compile:
markdown: doc/compile.md
Importer:
markdown: doc/importer.md
Value:
markdown: doc/value.md
2 changes: 2 additions & 0 deletions doc/compile.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
APIs for compiling Sass source files to CSS, and providing options for that
compilation.
5 changes: 5 additions & 0 deletions doc/importer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Classes for defining custom logic for resolving `@use`, `@forward`, and
`@import` rules in Sass. See [`Importer`] for details on the importer API
contract.

[`Importer`]: ../sass/Importer-class.html
6 changes: 6 additions & 0 deletions doc/value.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Classes that represent Sass values. These are passed to and returned by
user-defined [`Callable`]s that are passed to functions like
[`compileToResult()`].

[`Callable`]: ../sass/Callable-class.html
[`compileToResult()`]: ../sass/compileToResult.html
14 changes: 14 additions & 0 deletions lib/sass.dart
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ export 'src/warn.dart' show warn;
/// [byte-order mark]: https://en.wikipedia.org/wiki/Byte_order_mark#UTF-8
///
/// Throws a [SassException] if conversion fails.
///
/// {@category Compile}
CompileResult compileToResult(String path,
{bool color = false,
Logger? logger,
Expand Down Expand Up @@ -179,6 +181,8 @@ CompileResult compileToResult(String path,
/// [byte-order mark]: https://en.wikipedia.org/wiki/Byte_order_mark#UTF-8
///
/// Throws a [SassException] if conversion fails.
///
/// {@category Compile}
CompileResult compileStringToResult(String source,
{Syntax? syntax,
bool color = false,
Expand Down Expand Up @@ -245,6 +249,8 @@ Future<CompileResult> compileToResultAsync(String path,
/// Running asynchronously allows this to take [AsyncImporter]s rather than
/// synchronous [Importer]s. However, running asynchronously is also somewhat
/// slower, so [compileStringToResult] should be preferred if possible.
///
/// {@category Compile}
Future<CompileResult> compileStringToResultAsync(String source,
{Syntax? syntax,
bool color = false,
Expand Down Expand Up @@ -296,6 +302,8 @@ Future<CompileResult> compileStringToResultAsync(String source,
/// SingleMapping sourceMap;
/// var css = compile(sassPath, sourceMap: (map) => sourceMap = map);
/// ```
///
/// {@category Compile}
@Deprecated("Use compileToResult() instead.")
String compile(
String path,
Expand Down Expand Up @@ -345,6 +353,8 @@ String compile(
/// SingleMapping sourceMap;
/// var css = compileString(sass, sourceMap: (map) => sourceMap = map);
/// ```
///
/// {@category Compile}
@Deprecated("Use compileStringToResult() instead.")
String compileString(
String source,
Expand Down Expand Up @@ -388,6 +398,8 @@ String compileString(
/// Running asynchronously allows this to take [AsyncImporter]s rather than
/// synchronous [Importer]s. However, running asynchronously is also somewhat
/// slower, so [compile] should be preferred if possible.
///
/// {@category Compile}
@Deprecated("Use compileToResultAsync() instead.")
Future<String> compileAsync(
String path,
Expand Down Expand Up @@ -421,6 +433,8 @@ Future<String> compileAsync(
/// Running asynchronously allows this to take [AsyncImporter]s rather than
/// synchronous [Importer]s. However, running asynchronously is also somewhat
/// slower, so [compileString] should be preferred if possible.
///
/// {@category Compile}
@Deprecated("Use compileStringToResultAsync() instead.")
Future<String> compileStringAsync(
String source,
Expand Down
2 changes: 2 additions & 0 deletions lib/src/callable.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ export 'callable/user_defined.dart';
/// [SassString.sassIndexToRuneIndex] methods can be used to do this
/// automatically, and the [SassString.sassLength] getter can be used to
/// access a string's length in code points.
///
/// {@category Compile}
@sealed
abstract class Callable extends AsyncCallable {
@Deprecated('Use `Callable.function` instead.')
Expand Down
2 changes: 2 additions & 0 deletions lib/src/callable/async.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import 'async_built_in.dart';
/// work synchronously, it should be a [Callable] instead.
///
/// See [Callable] for more details.
///
/// {@category Compile}
@sealed
abstract class AsyncCallable {
/// The callable's name.
Expand Down
2 changes: 2 additions & 0 deletions lib/src/compile_result.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import 'visitor/serialize.dart';

/// The result of compiling a Sass document to CSS, along with metadata about
/// the compilation process.
///
/// {@category Compile}
@sealed
class CompileResult {
/// The result of evaluating the source file.
Expand Down
4 changes: 4 additions & 0 deletions lib/src/exception.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// https://opensource.org/licenses/MIT.

import 'package:charcode/charcode.dart';
import 'package:meta/meta.dart';
import 'package:source_span/source_span.dart';
import 'package:stack_trace/stack_trace.dart';
import 'package:term_glyph/term_glyph.dart' as term_glyph;
Expand All @@ -12,6 +13,9 @@ import 'utils.dart';
import 'value.dart';

/// An exception thrown by Sass.
///
/// {@category Compile}
@sealed
class SassException extends SourceSpanException {
/// The Sass stack trace at the point this exception was thrown.
///
Expand Down
2 changes: 2 additions & 0 deletions lib/src/importer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ export 'importer/result.dart';
/// [AsyncImporter] if possible.
///
/// Subclasses should extend [Importer], not implement it.
///
/// {@category Importer}
abstract class Importer extends AsyncImporter {
/// An importer that never imports any stylesheets.
///
Expand Down
2 changes: 2 additions & 0 deletions lib/src/importer/async.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import 'utils.dart' as utils;
/// instead.
///
/// Subclasses should extend [AsyncImporter], not implement it.
///
/// {@category Importer}
abstract class AsyncImporter {
/// Whether the current [canonicalize] invocation comes from an `@import`
/// rule.
Expand Down
2 changes: 2 additions & 0 deletions lib/src/importer/filesystem.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import '../util/nullable.dart';
import 'utils.dart';

/// An importer that loads files from a load path on the filesystem.
///
/// {@category Importer}
@sealed
class FilesystemImporter extends Importer {
/// The path relative to which this importer looks for files.
Expand Down
2 changes: 2 additions & 0 deletions lib/src/importer/package.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import '../importer.dart';
final _filesystemImporter = FilesystemImporter('.');

/// An importer that loads stylesheets from `package:` imports.
///
/// {@category Importer}
@sealed
class PackageImporter extends Importer {
/// The resolver that converts `package:` imports to `file:`.
Expand Down
2 changes: 2 additions & 0 deletions lib/src/importer/result.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import '../importer.dart';
import '../syntax.dart';

/// The result of importing a Sass stylesheet, as returned by [Importer.load].
///
/// {@category Importer}
@sealed
class ImporterResult {
/// The contents of the stylesheet.
Expand Down
2 changes: 2 additions & 0 deletions lib/src/logger.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import 'logger/stderr.dart';
/// An interface for loggers that print messages produced by Sass stylesheets.
///
/// This may be implemented by user code.
///
/// {@category Compile}
abstract class Logger {
/// A logger that silently ignores all messages.
static final Logger quiet = _QuietLogger();
Expand Down
2 changes: 2 additions & 0 deletions lib/src/syntax.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import 'package:meta/meta.dart';
import 'package:path/path.dart' as p;

/// An enum of syntaxes that Sass can parse.
///
/// {@category Compile}
@sealed
class Syntax {
/// The CSS-superset SCSS syntax.
Expand Down
2 changes: 2 additions & 0 deletions lib/src/value.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ export 'value/string.dart';
/// subclass constructors like [new SassString]. Untyped values can be cast to
/// particular types using `assert*()` functions like [assertString], which
/// throw user-friendly error messages if they fail.
///
/// {@category Value}
@sealed
abstract class Value {
/// Whether the value counts as `true` in an `@if` statement and other
Expand Down
2 changes: 2 additions & 0 deletions lib/src/value/argument_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import '../value.dart';
/// An argument list comes from a rest argument. It's distinct from a normal
/// [SassList] in that it may contain a keyword map as well as the positional
/// arguments.
///
/// {@category Value}
@sealed
class SassArgumentList extends SassList {
/// The keyword arguments attached to this argument list.
Expand Down
6 changes: 6 additions & 0 deletions lib/src/value/boolean.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,18 @@ import '../visitor/interface/value.dart';
import '../value.dart';

/// The SassScript `true` value.
///
/// {@category Value}
const sassTrue = SassBoolean._(true);

/// The SassScript `false` value.
///
/// {@category Value}
const sassFalse = SassBoolean._(false);

/// A SassScript boolean value.
///
/// {@category Value}
@sealed
class SassBoolean extends Value {
/// Whether this value is `true` or `false`.
Expand Down
2 changes: 2 additions & 0 deletions lib/src/value/color.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import '../value.dart';
import '../visitor/interface/value.dart';

/// A SassScript color.
///
/// {@category Value}
@sealed
class SassColor extends Value {
/// This color's red channel, between `0` and `255`.
Expand Down
2 changes: 2 additions & 0 deletions lib/src/value/function.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import '../value.dart';
///
/// A function reference captures a function from the local environment so that
/// it may be passed between modules.
///
/// {@category Value}
@sealed
class SassFunction extends Value {
/// The callable that this function invokes.
Expand Down
4 changes: 4 additions & 0 deletions lib/src/value/list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import '../visitor/interface/value.dart';
import '../value.dart';

/// A SassScript list.
///
/// {@category Value}
@sealed
class SassList extends Value {
// TODO(nweiz): Use persistent data structures rather than copying here. An
Expand Down Expand Up @@ -70,6 +72,8 @@ class SassList extends Value {
}

/// An enum of list separator types.
///
/// {@category Value}
@sealed
class ListSeparator {
/// A space-separated list.
Expand Down
2 changes: 2 additions & 0 deletions lib/src/value/map.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import '../value.dart';
import '../utils.dart';

/// A SassScript map.
///
/// {@category Value}
@sealed
class SassMap extends Value {
// TODO(nweiz): Use persistent data structures rather than copying here. We
Expand Down
2 changes: 2 additions & 0 deletions lib/src/value/null.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import '../visitor/interface/value.dart';
import '../value.dart';

/// The SassScript `null` value.
///
/// {@category Value}
const Value sassNull = _SassNull();

/// A SassScript null value.
Expand Down
2 changes: 2 additions & 0 deletions lib/src/value/number.dart
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@ final _typesByUnit = {
/// support scientific-style numerator and denominator units (for example,
/// `miles/hour`). These are expected to be resolved before being emitted to
/// CSS.
///
/// {@category Value}
@sealed
abstract class SassNumber extends Value {
/// The number of distinct digits that are emitted when converting a number to
Expand Down
2 changes: 2 additions & 0 deletions lib/src/value/number/complex.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import '../number.dart';

/// A specialized subclass of [SassNumber] for numbers that are not
/// [UnitlessSassNumber]s or [SingleUnitSassNumber]s.
///
/// {@category Value}
@sealed
class ComplexSassNumber extends SassNumber {
final List<String> numeratorUnits;
Expand Down
2 changes: 2 additions & 0 deletions lib/src/value/number/single_unit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import '../number.dart';

/// A specialized subclass of [SassNumber] for numbers that have exactly one
/// numerator unit.
///
/// {@category Value}
@sealed
class SingleUnitSassNumber extends SassNumber {
final String _unit;
Expand Down
2 changes: 2 additions & 0 deletions lib/src/value/number/unitless.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import '../../value.dart';
import '../number.dart';

/// A specialized subclass of [SassNumber] for numbers that have no units.
///
/// {@category Value}
@sealed
class UnitlessSassNumber extends SassNumber {
List<String> get numeratorUnits => const [];
Expand Down
2 changes: 2 additions & 0 deletions lib/src/value/string.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ final _emptyUnquoted = SassString("", quotes: false);
///
/// Strings can either be quoted or unquoted. Unquoted strings are usually CSS
/// identifiers, but they may contain any text.
///
/// {@category Value}
@sealed
class SassString extends Value {
/// The contents of the string.
Expand Down
2 changes: 2 additions & 0 deletions lib/src/visitor/serialize.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1254,6 +1254,8 @@ class _SerializeVisitor
}

/// An enum of generated CSS styles.
///
/// {@category Compile}
@sealed
class OutputStyle {
/// The standard CSS style, with each declaration on its own line.
Expand Down
2 changes: 2 additions & 0 deletions lib/src/warn.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import 'dart:async';
/// If [deprecation] is `true`, the warning is emitted as a deprecation warning.
///
/// This may only be called within a custom function or importer callback.
///
/// {@category Compile}
void warn(String message, {bool deprecation = false}) {
var warnDefinition = Zone.current[#_warn];

Expand Down

0 comments on commit a28c656

Please sign in to comment.