Chromium Code Reviews| Index: pkg/docgen/lib/docgen.dart |
| diff --git a/pkg/docgen/lib/docgen.dart b/pkg/docgen/lib/docgen.dart |
| index 6ad260988ed81ff2477cc6d544e4242bf6a8e149..41bcf26615526076bf7bd0eed68ee4368727b47a 100644 |
| --- a/pkg/docgen/lib/docgen.dart |
| +++ b/pkg/docgen/lib/docgen.dart |
| @@ -67,7 +67,12 @@ Set<String> qualifiedNameIndex = new Set<String>(); |
| */ |
| Future<bool> docgen(List<String> files, {String packageRoot, |
| bool outputToYaml: true, bool includePrivate: false, bool includeSdk: false, |
| - bool parseSdk: false}) { |
| + bool parseSdk: false, bool append: false}) { |
| + if (!append) { |
| + var dir = new Directory('docs'); |
| + if (dir.existsSync()) dir.deleteSync(recursive: true); |
| + } |
| + |
| if (packageRoot == null && !parseSdk) { |
| // TODO(janicejl): At the moment, if a single file is passed it, it is |
| // assumed that it does not have a package root unless it is passed in by |
| @@ -90,7 +95,7 @@ Future<bool> docgen(List<String> files, {String packageRoot, |
| } |
| _documentLibraries(mirrorSystem.libraries.values, |
| includeSdk: includeSdk, includePrivate: includePrivate, |
| - outputToYaml: outputToYaml); |
| + outputToYaml: outputToYaml, append: append); |
| return true; |
| }); |
| @@ -196,8 +201,8 @@ Future<MirrorSystem> _analyzeLibraries(List<String> libraries, |
| * Creates documentation for filtered libraries. |
| */ |
| void _documentLibraries(List<LibraryMirror> libraries, |
| - {bool includeSdk:false, bool includePrivate:false, bool |
| - outputToYaml:true}) { |
| + {bool includeSdk:false, bool includePrivate:false, |
| + bool outputToYaml:true, bool append: false}) { |
|
Bob Nystrom
2013/07/30 16:23:29
Style nit: add spaces after other ":" in param lis
|
| libraries.forEach((lib) { |
| // Files belonging to the SDK have a uri that begins with 'dart:'. |
| if (includeSdk || !lib.uri.toString().startsWith('dart:')) { |
| @@ -209,10 +214,10 @@ void _documentLibraries(List<LibraryMirror> libraries, |
| // the libraries. This will help the viewer know what files are available |
| // to read in. |
| _writeToFile(listDir('docs').join('\n').replaceAll('docs/', ''), |
| - 'library_list.txt'); |
| + 'library_list.txt', append: append); |
| // Outputs all the qualified names documented. This will help generate search |
| // results. |
| - _writeToFile(qualifiedNameIndex.join('\n'), 'index.txt'); |
| + _writeToFile(qualifiedNameIndex.join('\n'), 'index.txt', append: append); |
| } |
| Library generateLibrary(dart2js.Dart2JsLibraryMirror library, |
| @@ -443,7 +448,7 @@ List<Type> _typeGenerics(TypeMirror mirror) { |
| /** |
| * Writes text to a file in the 'docs' directory. |
| */ |
| -void _writeToFile(String text, String filename) { |
| +void _writeToFile(String text, String filename, {bool append: false}) { |
| Directory dir = new Directory('docs'); |
| if (!dir.existsSync()) { |
| dir.createSync(); |
| @@ -452,8 +457,7 @@ void _writeToFile(String text, String filename) { |
| if (!file.existsSync()) { |
| file.createSync(); |
| } |
| - file.openSync(); |
| - file.writeAsString(text); |
| + file.writeAsString(text, mode: append ? FileMode.APPEND : FileMode.WRITE); |
| } |
| /** |