Chromium Code Reviews| Index: pkg/barback/lib/transformer.dart |
| diff --git a/pkg/barback/lib/transformer.dart b/pkg/barback/lib/transformer.dart |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..b5a4eac22a3ff26ff4e1bae030483728c56175a6 |
| --- /dev/null |
| +++ b/pkg/barback/lib/transformer.dart |
| @@ -0,0 +1,56 @@ |
| +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
|
nweiz
2013/06/14 00:57:57
I don't understand why the classes in this file ar
Bob Nystrom
2013/06/17 23:35:05
I thought it might be nice to separate out the pub
nweiz
2013/06/18 23:14:45
As I mentioned elsewhere, this sort of thing shoul
Bob Nystrom
2013/06/20 00:23:59
OK. Done.
|
| +// for details. All rights reserved. Use of this source code is governed by a |
| +// BSD-style license that can be found in the LICENSE file. |
| + |
| +library barback.generator; |
| + |
| +import 'dart:async'; |
| +import 'dart:io'; |
| + |
| +import 'package:pathos/path.dart' as pathos; |
| + |
| +import 'barback.dart'; |
| + |
| +/// A [Transformer] represents a processing step that can take in one or more |
|
nweiz
2013/06/14 00:57:57
"processing step" here is confusing; it sounds lik
Bob Nystrom
2013/06/17 23:35:05
Done.
|
| +/// input assets and use them to generate one or more output assets. |
| +/// |
| +/// Dart2js, a SASS->CSS processor, a CSS spriter, and a tool to concatenate JS |
| +/// files are all examples of transformers. To define your own transformation |
|
nweiz
2013/06/14 00:57:57
"a tool to concatenate JS files" is a weird exampl
Bob Nystrom
2013/06/17 23:35:05
Done.
|
| +/// step, you extend (or implement) this class. |
|
nweiz
2013/06/14 00:57:57
"you" -> ""
Bob Nystrom
2013/06/17 23:35:05
Done.
|
| +abstract class Transformer { |
| + /// Returns `true` if [input] can be a primary input for this transformer. |
| + /// This is used to tell which files this transformer applies to. |
|
nweiz
2013/06/14 00:57:57
Explain what a primary input is.
Bob Nystrom
2013/06/17 23:35:05
Done.
|
| + Future<bool> isPrimary(AssetId input); |
| + |
| + /// Process this transformer on [transform], which describes the actual |
|
nweiz
2013/06/14 00:57:57
"Process this transformer on [transform]" is very
Bob Nystrom
2013/06/17 23:35:05
Done.
|
| + /// assets being transformed. |
|
nweiz
2013/06/14 00:57:57
I don't think it's accurate to say that a Transfor
Bob Nystrom
2013/06/17 23:35:05
Done.
|
| + Future apply(Transform transform); |
| + |
| + String toString() => runtimeType.toString().replaceAll("Transformer", ""); |
| +} |
| + |
| +/// While a [Transformer] represents a *kind* of transformation, this defines |
| +/// one specific usage of it on a set of files. It is used in [apply()] to |
|
nweiz
2013/06/14 00:57:57
"usage" -> "instance"
"It is used" -> "Transforme
Bob Nystrom
2013/06/17 23:35:05
Reworded.
|
| +/// access the inputs for the transformation and to provide the outputs. |
| +abstract class Transform { |
| + /// Gets the ID of the primary input for this transformation. While a |
| + /// transformation can use multiple input assets, one must be a special |
| + /// "primary" asset. This will be the "entrypoint" or "main" input file for |
| + /// a transformation. |
| + /// |
| + /// For example, with a dart2js transform, the primary input would be the |
| + /// entrypoint Dart file. All of the other Dart files that that imports |
| + /// would be other, secondary inputs. |
|
nweiz
2013/06/14 00:57:57
"other," -> ""
Bob Nystrom
2013/06/17 23:35:05
Done.
|
| + AssetId get primaryId; |
| + |
| + /// Gets the asset for the primary input. |
| + Future<Asset> get primaryInput => getInput(primaryId); |
| + |
| + /// Gets the asset for for an input [id]. If an input with that ID cannot be |
| + /// found, throws an [AssetNotFoundException]. |
| + Future<Asset> getInput(AssetId id); |
| + |
| + /// Stores [output] as the output created by this transformation for asset |
| + /// [id]. A transformation can output as many assets as it wants. |
| + void addOutput(AssetId id, Asset output); |
| +} |