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

Side by Side Diff: sdk/lib/_internal/dartdoc/bin/dartdoc.dart

Issue 16364004: Add dartdoc to the generated utils snapshot. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 6 months 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « sdk/bin/dartdoc ('k') | sdk/lib/_internal/dartdoc/lib/dartdoc.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 11 matching lines...) Expand all
22 // TODO(rnystrom): Use "package:" URL (#4968). 22 // TODO(rnystrom): Use "package:" URL (#4968).
23 import '../lib/dartdoc.dart'; 23 import '../lib/dartdoc.dart';
24 import '../lib/src/dartdoc/utils.dart'; 24 import '../lib/src/dartdoc/utils.dart';
25 import 'package:args/args.dart'; 25 import 'package:args/args.dart';
26 import 'package:pathos/path.dart' as path; 26 import 'package:pathos/path.dart' as path;
27 27
28 /** 28 /**
29 * Run this from the `lib/_internal/dartdoc` directory. 29 * Run this from the `lib/_internal/dartdoc` directory.
30 */ 30 */
31 main() { 31 main() {
32 mainWithOptions(new Options());
33 }
34
35 /**
36 * We use this to include dartdoc in a single snapshot with dart2js.
37 * (They share 90% of the code)
38 */
39 mainWithOptions(Options options) {
32 // Need this because ArgParser.getUsage doesn't show command invocation. 40 // Need this because ArgParser.getUsage doesn't show command invocation.
33 final USAGE = 'Usage dartdoc [options] <entrypoint(s)>\n[options] include:'; 41 final USAGE = 'Usage dartdoc [options] <entrypoint(s)>\n[options] include:';
34 42
35 final args = new Options().arguments; 43 final args = options.arguments;
36 44
37 final dartdoc = new Dartdoc(); 45 final dartdoc = new Dartdoc();
38 46
39 final argParser = new ArgParser(); 47 final argParser = new ArgParser();
40 48
41 Path libPath = scriptDir.append('../../../../'); 49 Path libPath = scriptDir.append('../../../../');
42 50
43 String packageRoot; 51 String packageRoot;
44 52
45 argParser.addFlag('no-code', 53 argParser.addFlag('no-code',
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 if (packageRoot == null) packageRoot = _getPackageRoot(entrypoints); 241 if (packageRoot == null) packageRoot = _getPackageRoot(entrypoints);
234 242
235 cleanOutputDirectory(dartdoc.outputDir); 243 cleanOutputDirectory(dartdoc.outputDir);
236 244
237 // Start the analysis and documentation. 245 // Start the analysis and documentation.
238 dartdoc.documentLibraries(entrypoints, libPath, packageRoot) 246 dartdoc.documentLibraries(entrypoints, libPath, packageRoot)
239 // Prepare the dart2js script code and copy static resources. 247 // Prepare the dart2js script code and copy static resources.
240 // TODO(amouravski): move compileScript out and pre-generate the client 248 // TODO(amouravski): move compileScript out and pre-generate the client
241 // scripts. This takes a long time and the js hardly ever changes. 249 // scripts. This takes a long time and the js hardly ever changes.
242 .then((_) => compileScript(dartdoc.mode, dartdoc.outputDir, libPath)) 250 .then((_) => compileScript(dartdoc.mode, dartdoc.outputDir, libPath))
243 .then((_) => copyDirectory(scriptDir.append('../static'), 251 .then((_) => copyDirectory(libPath.append('lib/_internal/dartdoc/static'),
244 dartdoc.outputDir)) 252 dartdoc.outputDir))
245 .then((_) { 253 .then((_) {
246 print(dartdoc.status); 254 print(dartdoc.status);
247 if (dartdoc.totals == 0) { 255 if (dartdoc.totals == 0) {
248 exit(1); 256 exit(1);
249 } 257 }
250 }) 258 })
251 .catchError((e) { 259 .catchError((e) {
252 print('Error: generation failed: ${e}'); 260 print('Error: generation failed: ${e}');
253 var trace = getAttachedStackTrace(e); 261 var trace = getAttachedStackTrace(e);
254 if (trace != null) print("StackTrace: $trace"); 262 if (trace != null) print("StackTrace: $trace");
(...skipping 17 matching lines...) Expand all
272 // If there is not, then check if the entrypoint is somewhere in a `lib` 280 // If there is not, then check if the entrypoint is somewhere in a `lib`
273 // directory. 281 // directory.
274 var parts = path.split(path.dirname(script)); 282 var parts = path.split(path.dirname(script));
275 var libDir = parts.lastIndexOf('lib'); 283 var libDir = parts.lastIndexOf('lib');
276 if (libDir > 0) { 284 if (libDir > 0) {
277 return path.join(path.joinAll(parts.take(libDir)), 'packages'); 285 return path.join(path.joinAll(parts.take(libDir)), 'packages');
278 } else { 286 } else {
279 return null; 287 return null;
280 } 288 }
281 } 289 }
OLDNEW
« no previous file with comments | « sdk/bin/dartdoc ('k') | sdk/lib/_internal/dartdoc/lib/dartdoc.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698