Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(603)

Unified Diff: utils/pub/validator/compiled_dartdoc.dart

Issue 12089076: Add a pub validator for compiled dartdoc output. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Code review changes Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « utils/pub/validator.dart ('k') | utils/tests/pub/validator_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: utils/pub/validator/compiled_dartdoc.dart
diff --git a/utils/pub/validator/compiled_dartdoc.dart b/utils/pub/validator/compiled_dartdoc.dart
new file mode 100644
index 0000000000000000000000000000000000000000..c2c93f3a8708610624d1abdfce09a95813c4ce47
--- /dev/null
+++ b/utils/pub/validator/compiled_dartdoc.dart
@@ -0,0 +1,47 @@
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// 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 compiled_dartdoc_validator;
+
+import 'dart:async';
+
+import '../../../pkg/path/lib/path.dart' as path;
+
+import '../entrypoint.dart';
+import '../io.dart';
+import '../utils.dart';
+import '../validator.dart';
+
+/// Validates that a package doesn't contain compiled Dartdoc
+/// output.
+class CompiledDartdocValidator extends Validator {
+ CompiledDartdocValidator(Entrypoint entrypoint)
+ : super(entrypoint);
+
+ Future validate() {
+ return listDir(entrypoint.root.dir, recursive: true).then((entries) {
+ return futureWhere(entries, (entry) {
+ if (basename(entry) != "nav.json") return false;
+ var dir = dirname(entry);
+
+ // Look for tell-tale Dartdoc output files all in the same directory.
+ return Future.wait([
+ fileExists(entry),
+ fileExists(join(dir, "index.html")),
+ fileExists(join(dir, "styles.css")),
+ fileExists(join(dir, "dart-logo-small.png")),
+ fileExists(join(dir, "client-live-nav.js"))
+ ]).then((results) => results.every((val) => val));
+ }).then((files) {
+ for (var dartdocDir in files.mappedBy(dirname)) {
+ var relativePath = path.relative(dartdocDir);
+ warnings.add("Avoid putting generated documentation in "
+ "$relativePath.\n"
+ "Generated documentation bloats the package with redundant "
+ "data.");
+ }
+ });
+ });
+ }
+}
« no previous file with comments | « utils/pub/validator.dart ('k') | utils/tests/pub/validator_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698