Index: pkg/polymer/lib/src/build/runner.dart |
diff --git a/pkg/polymer/lib/src/build/runner.dart b/pkg/polymer/lib/src/build/runner.dart |
index a65c9b070dc7cecf6ea3cf5cb64a84e3b985ed0d..bacb40dbf0675628d3faf29d1ab3734dba4511ef 100644 |
--- a/pkg/polymer/lib/src/build/runner.dart |
+++ b/pkg/polymer/lib/src/build/runner.dart |
@@ -2,10 +2,8 @@ |
// 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. |
-/** |
- * Definitions used to run the polymer linter and deploy tools without using |
- * pub serve or pub deploy. |
- */ |
+/// Definitions used to run the polymer linter and deploy tools without using |
+/// pub serve or pub deploy. |
library polymer.src.build.runner; |
import 'dart:async'; |
@@ -18,49 +16,39 @@ import 'package:stack_trace/stack_trace.dart'; |
import 'package:yaml/yaml.dart'; |
-/** Collects different parameters needed to configure and run barback. */ |
+/// Collects different parameters needed to configure and run barback. |
class BarbackOptions { |
- /** |
- * Phases of transformers to run for the current package. |
- * Use packagePhases to specify phases for other packages. |
- */ |
+ /// Phases of transformers to run for the current package. |
+ /// Use packagePhases to specify phases for other packages. |
final List<List<Transformer>> phases; |
- /** Package to treat as the current package in barback. */ |
+ /// Package to treat as the current package in barback. |
final String currentPackage; |
- /** Directory root for the current package. */ |
+ /// Directory root for the current package. |
final String packageHome; |
- /** |
- * Mapping between package names and the path in the file system where |
- * to find the sources of such package. |
- */ |
+ /// Mapping between package names and the path in the file system where |
+ /// to find the sources of such package. |
final Map<String, String> packageDirs; |
- /** Whether to run transformers on the test folder. */ |
+ /// Whether to run transformers on the test folder. |
final bool transformTests; |
- /** Directory where to generate code, if any. */ |
+ /// Directory where to generate code, if any. |
final String outDir; |
- /** |
- * Whether to print error messages using a json-format that tools, such as the |
- * Dart Editor, can process. |
- */ |
+ /// Whether to print error messages using a json-format that tools, such as |
+ /// the Dart Editor, can process. |
final bool machineFormat; |
- /** |
- * Whether to follow symlinks when listing directories. By default this is |
- * false because directories have symlinks for the packages directory created |
- * by pub, but it can be turned on for custom uses of this library. |
- */ |
+ /// Whether to follow symlinks when listing directories. By default this is |
+ /// false because directories have symlinks for the packages directory created |
+ /// by pub, but it can be turned on for custom uses of this library. |
final bool followLinks; |
- /** |
- * Phases of transformers to apply to packages other than the current |
- * package, keyed by the package name. |
- */ |
+ /// Phases of transformers to apply to packages other than the current |
+ /// package, keyed by the package name. |
final Map<String, List<List<Transformer>>> packagePhases; |
BarbackOptions(this.phases, this.outDir, {currentPackage, String packageHome, |
@@ -75,11 +63,9 @@ class BarbackOptions { |
} |
-/** |
- * Creates a barback system as specified by [options] and runs it. Returns a |
- * future that contains the list of assets generated after barback runs to |
- * completion. |
- */ |
+/// Creates a barback system as specified by [options] and runs it. Returns a |
+/// future that contains the list of assets generated after barback runs to |
+/// completion. |
Future<AssetSet> runBarback(BarbackOptions options) { |
var barback = new Barback(new _PackageProvider(options.packageDirs)); |
_initBarback(barback, options); |
@@ -88,7 +74,7 @@ Future<AssetSet> runBarback(BarbackOptions options) { |
return _emitAllFiles(barback, options); |
} |
-/** Extract the current package from the pubspec.yaml file. */ |
+/// Extract the current package from the pubspec.yaml file. |
String readCurrentPackageFromPubspec([String dir]) { |
var pubspec = new File( |
dir == null ? 'pubspec.yaml' : path.join(dir, 'pubspec.yaml')); |
@@ -100,12 +86,10 @@ String readCurrentPackageFromPubspec([String dir]) { |
return loadYaml(pubspec.readAsStringSync())['name']; |
} |
-/** |
- * Extract a mapping between package names and the path in the file system where |
- * to find the sources of such package. This map will contain an entry for the |
- * current package and everything it depends on (extracted via `pub |
- * list-package-dirs`). |
- */ |
+/// Extract a mapping between package names and the path in the file system |
+/// which has the source of the package. This map will contain an entry for the |
+/// current package and everything it depends on (extracted via `pub |
+/// list-package-dirs`). |
Map<String, String> readPackageDirsFromPub( |
[String packageHome, String currentPackage]) { |
var cachedDir = Directory.current; |
@@ -138,7 +122,7 @@ Map<String, String> readPackageDirsFromPub( |
return map; |
} |
-/** Return the relative path of each file under [subDir] in [package]. */ |
+/// Return the relative path of each file under [subDir] in [package]. |
Iterable<String> _listPackageDir(String package, String subDir, |
BarbackOptions options) { |
var packageDir = options.packageDirs[package]; |
@@ -150,7 +134,7 @@ Iterable<String> _listPackageDir(String package, String subDir, |
.map((f) => path.relative(f.path, from: packageDir)); |
} |
-/** A simple provider that reads files directly from the pub cache. */ |
+/// A simple provider that reads files directly from the pub cache. |
class _PackageProvider implements PackageProvider { |
Map<String, String> packageDirs; |
Iterable<String> get packages => packageDirs.keys; |
@@ -162,13 +146,13 @@ class _PackageProvider implements PackageProvider { |
_toSystemPath(id.path)))); |
} |
-/** Convert asset paths to system paths (Assets always use the posix style). */ |
+/// Convert asset paths to system paths (Assets always use the posix style). |
String _toSystemPath(String assetPath) { |
if (path.Style.platform != path.Style.windows) return assetPath; |
return path.joinAll(path.posix.split(assetPath)); |
} |
-/** Tell barback which transformers to use and which assets to process. */ |
+/// Tell barback which transformers to use and which assets to process. |
void _initBarback(Barback barback, BarbackOptions options) { |
var assets = []; |
void addAssets(String package, String subDir) { |
@@ -197,7 +181,7 @@ void _initBarback(Barback barback, BarbackOptions options) { |
barback.updateSources(assets); |
} |
-/** Attach error listeners on [barback] so we can report errors. */ |
+/// Attach error listeners on [barback] so we can report errors. |
void _attachListeners(Barback barback, BarbackOptions options) { |
// Listen for errors and results |
barback.errors.listen((e) { |
@@ -226,10 +210,8 @@ void _attachListeners(Barback barback, BarbackOptions options) { |
}); |
} |
-/** |
- * Emits all outputs of [barback] and copies files that we didn't process (like |
- * dependent package's libraries). |
- */ |
+/// Emits all outputs of [barback] and copies files that we didn't process (like |
+/// dependent package's libraries). |
Future _emitAllFiles(Barback barback, BarbackOptions options) { |
return barback.getAllAssets().then((assets) { |
// Delete existing output folder before we generate anything |
@@ -272,10 +254,8 @@ Future _emitTransformedFiles(AssetSet assets, BarbackOptions options) { |
}); |
} |
-/** |
- * Adds a package symlink from each directory under `out/web/foo/` to |
- * `out/packages`. |
- */ |
+/// Adds a package symlink from each directory under `out/web/foo/` to |
+/// `out/packages`. |
void _addPackagesSymlinks(AssetSet assets, BarbackOptions options) { |
var outPackages = path.join(options.outDir, 'packages'); |
var currentPackage = options.currentPackage; |
@@ -299,10 +279,8 @@ void _addPackagesSymlinks(AssetSet assets, BarbackOptions options) { |
} |
} |
-/** |
- * Emits a 'packages' directory directly under `out/packages` with the contents |
- * of every file that was not transformed by barback. |
- */ |
+/// Emits a 'packages' directory directly under `out/packages` with the contents |
+/// of every file that was not transformed by barback. |
Future _emitPackagesDir(BarbackOptions options) { |
var outPackages = path.join(options.outDir, 'packages'); |
_ensureDir(outPackages); |
@@ -319,28 +297,26 @@ Future _emitPackagesDir(BarbackOptions options) { |
}); |
} |
-/** Ensure [dirpath] exists. */ |
+/// Ensure [dirpath] exists. |
void _ensureDir(String dirpath) { |
new Directory(dirpath).createSync(recursive: true); |
} |
-/** |
- * Returns the first directory name on a url-style path, or null if there are no |
- * slashes. |
- */ |
+/// Returns the first directory name on a url-style path, or null if there are |
+/// no slashes. |
String _firstDir(String url) { |
var firstSlash = url.indexOf('/'); |
if (firstSlash == -1) return null; |
return url.substring(0, firstSlash); |
} |
-/** Copy a file from [inpath] to [outpath]. */ |
+/// Copy a file from [inpath] to [outpath]. |
Future _copyFile(String inpath, String outpath) { |
_ensureDir(path.dirname(outpath)); |
return new File(inpath).openRead().pipe(new File(outpath).openWrite()); |
} |
-/** Write contents of an [asset] into a file at [filepath]. */ |
+/// Write contents of an [asset] into a file at [filepath]. |
Future _writeAsset(String filepath, Asset asset) { |
_ensureDir(path.dirname(filepath)); |
return asset.read().pipe(new File(filepath).openWrite()); |
@@ -352,10 +328,8 @@ String _kindFromEntry(LogEntry entry) { |
: (level == LogLevel.WARNING ? 'warning' : 'info'); |
} |
-/** |
- * Formatter that generates messages using a format that can be parsed |
- * by tools, such as the Dart Editor, for reporting error messages. |
- */ |
+/// Formatter that generates messages using a format that can be parsed |
+/// by tools, such as the Dart Editor, for reporting error messages. |
String _jsonFormatter(LogEntry entry) { |
var kind = _kindFromEntry(entry); |
var span = entry.span; |
@@ -371,10 +345,8 @@ String _jsonFormatter(LogEntry entry) { |
}}]); |
} |
-/** |
- * Formatter that generates messages that are easy to read on the console (used |
- * by default). |
- */ |
+/// Formatter that generates messages that are easy to read on the console (used |
+/// by default). |
String _consoleFormatter(LogEntry entry) { |
var kind = _kindFromEntry(entry); |
var useColors = stdioType(stdout) == StdioType.TERMINAL; |