Chromium Code Reviews| 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..218bd61cd2634a57e751a2775deaf03efdea2065 | 
| --- /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'; | 
| + | 
| +/// A validator that validates that a package doesn't contain compiled Dartdoc | 
| 
 
Bob Nystrom
2013/01/31 18:54:54
"A validator that validates" -> "Validates".
 
nweiz
2013/01/31 20:31:54
Done.
 
 | 
| +/// 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("Remove compiled dartdoc documentation from " | 
| + "$relativePath.\n" | 
| 
 
Bob Nystrom
2013/01/31 18:54:54
How about:
Avoid putting generated documentation
 
nweiz
2013/01/31 20:31:54
The "that directory" text only makes sense if they
 
 | 
| + "Publishing compiled documentation causes package bloat without " | 
| + "providing value for users."); | 
| + } | 
| + }); | 
| + }); | 
| + } | 
| +} |