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

Unified Diff: utils/dartdoc/dartdoc.dart

Issue 8572044: Clean and create output directory when generating docs. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Git rid of need for grid-22.png. Created 9 years, 1 month 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
Index: utils/dartdoc/dartdoc.dart
diff --git a/utils/dartdoc/dartdoc.dart b/utils/dartdoc/dartdoc.dart
index 2ca8cff4932ec32a08d38332a14b3ceb66b6f087..921bb694b434443e50077f6ff9dacf3993d34a22 100644
--- a/utils/dartdoc/dartdoc.dart
+++ b/utils/dartdoc/dartdoc.dart
@@ -6,6 +6,7 @@
#library('dartdoc');
#import('../../frog/lang.dart');
+#import('../../frog/file_system.dart');
#import('../../frog/file_system_node.dart');
#source('classify.dart');
@@ -35,6 +36,8 @@ int _totalLibraries = 0;
int _totalTypes = 0;
int _totalMembers = 0;
+FileSystem files;
+
/**
* Run this from the frog/samples directory. Before running, you need
* to create a docs dir with 'mkdir docs' - since Dart currently doesn't
@@ -44,18 +47,29 @@ void main() {
// The entrypoint of the library to generate docs for.
final libPath = process.argv[2];
- // TODO(rnystrom): Get options and homedir like frog.dart does.
- final files = new NodeFileSystem();
+ files = new NodeFileSystem();
parseOptions('../../frog', [] /* args */, files);
final elapsed = time(() {
+ _comments = <String, Map<int, String>>{};
+
initializeWorld(files);
world.processScript(libPath);
world.resolveAll();
- _comments = <String, Map<int, String>>{};
+ // Clean the output directory.
+ if (files.fileExists(outdir)) {
+ files.removeDirectory(outdir, recursive: true);
+ }
+ files.createDirectory(outdir, recursive: true);
+ // Copy over the static files.
+ for (final file in ['interact.js', 'styles.css']) {
+ copyStatic(file);
+ }
+
+ // Generate the docs.
for (var library in world.libraries.getValues()) {
docLibrary(library);
}
@@ -67,6 +81,12 @@ void main() {
'$_totalMembers members in ${elapsed}msec.');
}
+/** Copies the static file at 'static/file' to the output directory. */
+copyStatic(String file) {
+ var contents = files.readAll(joinPaths('static', file));
Jacob 2011/11/16 19:59:30 why not use final for this and other local vars th
jimhug 2011/11/17 16:59:44 This is a good topic. I've found myself not doing
Bob Nystrom 2011/11/17 20:44:21 I do the same thing. Lately, my habit has been to
Jacob 2011/11/17 20:54:08 using final for everything at first has worked wel
+ files.writeString(joinPaths(outdir, file), contents);
+}
+
num time(callback()) {
// Unlike world.withTiming, returns the elapsed time.
final watch = new Stopwatch();

Powered by Google App Engine
This is Rietveld 408576698