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 /** | 5 /** |
6 * To generate docs for a library, run this script with the path to an | 6 * To generate docs for a library, run this script with the path to an |
7 * entrypoint .dart file, like: | 7 * entrypoint .dart file, like: |
8 * | 8 * |
9 * $ dart dartdoc.dart foo.dart | 9 * $ dart dartdoc.dart foo.dart |
10 * | 10 * |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 // The entrypoint of the library to generate docs for. | 105 // The entrypoint of the library to generate docs for. |
106 final entrypoint = args[args.length - 1]; | 106 final entrypoint = args[args.length - 1]; |
107 | 107 |
108 final files = new VMFileSystem(); | 108 final files = new VMFileSystem(); |
109 | 109 |
110 // TODO(rnystrom): Note that the following lines get munged by create-sdk to | 110 // TODO(rnystrom): Note that the following lines get munged by create-sdk to |
111 // work with the SDK's different file layout. If you change, be sure to test | 111 // work with the SDK's different file layout. If you change, be sure to test |
112 // that dartdoc still works when run from the built SDK directory. | 112 // that dartdoc still works when run from the built SDK directory. |
113 final frogPath = joinPaths(scriptDir, 'frog/'); | 113 final frogPath = joinPaths(scriptDir, 'frog/'); |
114 final libDir = joinPaths(scriptDir, '..'); | 114 final libDir = joinPaths(scriptDir, '..'); |
115 final compilerPath = 'dart2js'; | 115 final compilerPath |
| 116 = Platform.operatingSystem == 'windows' ? 'dart2js.bat' : 'dart2js'; |
116 | 117 |
117 parseOptions(frogPath, ['', '', '--libdir=$libDir'], files); | 118 parseOptions(frogPath, ['', '', '--libdir=$libDir'], files); |
118 initializeWorld(files); | 119 initializeWorld(files); |
119 | 120 |
120 final dartdoc = new Dartdoc(); | 121 final dartdoc = new Dartdoc(); |
121 | 122 |
122 if (includeSource != null) dartdoc.includeSource = includeSource; | 123 if (includeSource != null) dartdoc.includeSource = includeSource; |
123 if (mode != null) dartdoc.mode = mode; | 124 if (mode != null) dartdoc.mode = mode; |
124 if (outputDir != null) dartdoc.outputDir = outputDir; | 125 if (outputDir != null) dartdoc.outputDir = outputDir; |
125 if (generateAppCache != null) dartdoc.generateAppCache = generateAppCache; | 126 if (generateAppCache != null) dartdoc.generateAppCache = generateAppCache; |
126 if (omitGenerationTime != null) { | 127 if (omitGenerationTime != null) { |
127 dartdoc.omitGenerationTime = omitGenerationTime; | 128 dartdoc.omitGenerationTime = omitGenerationTime; |
128 } | 129 } |
129 | 130 |
130 cleanOutputDirectory(dartdoc.outputDir); | 131 cleanOutputDirectory(dartdoc.outputDir); |
131 | 132 |
132 // Compile the client-side code to JS. | 133 // Compile the client-side code to JS. |
133 final clientScript = (dartdoc.mode == MODE_STATIC) ? 'static' : 'live-nav'; | 134 final clientScript = (dartdoc.mode == MODE_STATIC) ? 'static' : 'live-nav'; |
134 final Future scriptCompiled = compileScript(compilerPath, | 135 final Future scriptCompiled = compileScript(compilerPath, |
135 '$scriptDir/client-$clientScript.dart', | 136 '$scriptDir/client-$clientScript.dart', |
136 '${dartdoc.outputDir}/client-$clientScript.js'); | 137 '${dartdoc.outputDir}/client-$clientScript.js'); |
137 | 138 |
138 final Future filesCopied = copyFiles('$scriptDir/static', dartdoc.outputDir); | 139 final Future filesCopied = copyFiles('$scriptDir/static', dartdoc.outputDir); |
139 | 140 |
140 Futures.wait([scriptCompiled, filesCopied]).then((_) { | 141 Futures.wait([scriptCompiled, filesCopied]).then((_) { |
141 dartdoc.document(entrypoint); | 142 dartdoc.document(entrypoint); |
| 143 |
| 144 print('Documented ${dartdoc._totalLibraries} libraries, ' |
| 145 '${dartdoc._totalTypes} types, and ' |
| 146 '${dartdoc._totalMembers} members.'); |
142 }); | 147 }); |
143 | |
144 print('Documented ${dartdoc._totalLibraries} libraries, ' | |
145 '${dartdoc._totalTypes} types, and ' | |
146 '${dartdoc._totalMembers} members.'); | |
147 } | 148 } |
148 | 149 |
149 /** | 150 /** |
150 * Gets the full path to the directory containing the entrypoint of the current | 151 * Gets the full path to the directory containing the entrypoint of the current |
151 * script. In other words, if you invoked dartdoc, directly, it will be the | 152 * script. In other words, if you invoked dartdoc, directly, it will be the |
152 * path to the directory containing `dartdoc.dart`. If you're running a script | 153 * path to the directory containing `dartdoc.dart`. If you're running a script |
153 * that imports dartdoc, it will be the path to that script. | 154 * that imports dartdoc, it will be the path to that script. |
154 */ | 155 */ |
155 String get scriptDir() { | 156 String get scriptDir() { |
156 return dirname(new File(new Options().script).fullPathSync()); | 157 return dirname(new File(new Options().script).fullPathSync()); |
(...skipping 1230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1387 if (filename.endsWith('appcache.manifest')) { | 1388 if (filename.endsWith('appcache.manifest')) { |
1388 return; | 1389 return; |
1389 } | 1390 } |
1390 var relativePath = filename.substring(pathPrefixLength + 1); | 1391 var relativePath = filename.substring(pathPrefixLength + 1); |
1391 write("$relativePath\n"); | 1392 write("$relativePath\n"); |
1392 }; | 1393 }; |
1393 toCache.onDone = (done) => endFile(); | 1394 toCache.onDone = (done) => endFile(); |
1394 toCache.list(recursive: true); | 1395 toCache.list(recursive: true); |
1395 } | 1396 } |
1396 } | 1397 } |
OLD | NEW |