| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library compiled_dartdoc_validator; | 5 library compiled_dartdoc_validator; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import '../../../pkg/path/lib/path.dart' as path; | 9 import '../../../pkg/path/lib/path.dart' as path; |
| 10 | 10 |
| 11 import '../entrypoint.dart'; | 11 import '../entrypoint.dart'; |
| 12 import '../io.dart'; | 12 import '../io.dart'; |
| 13 import '../utils.dart'; | 13 import '../utils.dart'; |
| 14 import '../validator.dart'; | 14 import '../validator.dart'; |
| 15 | 15 |
| 16 /// Validates that a package doesn't contain compiled Dartdoc | 16 /// Validates that a package doesn't contain compiled Dartdoc |
| 17 /// output. | 17 /// output. |
| 18 class CompiledDartdocValidator extends Validator { | 18 class CompiledDartdocValidator extends Validator { |
| 19 CompiledDartdocValidator(Entrypoint entrypoint) | 19 CompiledDartdocValidator(Entrypoint entrypoint) |
| 20 : super(entrypoint); | 20 : super(entrypoint); |
| 21 | 21 |
| 22 Future validate() { | 22 Future validate() { |
| 23 return listDir(entrypoint.root.dir, recursive: true).then((entries) { | 23 return listDir(entrypoint.root.dir, recursive: true).then((entries) { |
| 24 return futureWhere(entries, (entry) { | 24 for (var entry in entries) { |
| 25 if (basename(entry) != "nav.json") return false; | 25 if (basename(entry) != "nav.json") return false; |
| 26 var dir = dirname(entry); | 26 var dir = dirname(entry); |
| 27 | 27 |
| 28 // Look for tell-tale Dartdoc output files all in the same directory. | 28 // Look for tell-tale Dartdoc output files all in the same directory. |
| 29 return Future.wait([ | 29 var files = [ |
| 30 fileExists(entry), | 30 entry, |
| 31 fileExists(join(dir, "index.html")), | 31 join(dir, "index.html"), |
| 32 fileExists(join(dir, "styles.css")), | 32 join(dir, "styles.css"), |
| 33 fileExists(join(dir, "dart-logo-small.png")), | 33 join(dir, "dart-logo-small.png"), |
| 34 fileExists(join(dir, "client-live-nav.js")) | 34 join(dir, "client-live-nav.js") |
| 35 ]).then((results) => results.every((val) => val)); | 35 ]; |
| 36 }).then((files) { | 36 |
| 37 for (var dartdocDir in files.mappedBy(dirname)) { | 37 if (files.every((val) => fileExists(val))) { |
| 38 var relativePath = path.relative(dartdocDir); | |
| 39 warnings.add("Avoid putting generated documentation in " | 38 warnings.add("Avoid putting generated documentation in " |
| 40 "$relativePath.\n" | 39 "${path.relative(dir)}.\n" |
| 41 "Generated documentation bloats the package with redundant " | 40 "Generated documentation bloats the package with redundant " |
| 42 "data."); | 41 "data."); |
| 43 } | 42 } |
| 44 }); | 43 } |
| 45 }); | 44 }); |
| 46 } | 45 } |
| 47 } | 46 } |
| OLD | NEW |