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

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

Issue 14135007: Add dartdoc to the generated utils snapshot (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 8 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
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 22
23 // TODO(rnystrom): Use "package:" URL (#4968). 23 // TODO(rnystrom): Use "package:" URL (#4968).
24 import '../lib/dartdoc.dart'; 24 import '../lib/dartdoc.dart';
25 import '../lib/src/dartdoc/utils.dart'; 25 import '../lib/src/dartdoc/utils.dart';
26 import 'package:args/args.dart'; 26 import 'package:args/args.dart';
27 import 'package:pathos/path.dart' as path; 27 import 'package:pathos/path.dart' as path;
28 28
29 /** 29 /**
30 * Run this from the `lib/_internal/dartdoc` directory. 30 * Run this from the `lib/_internal/dartdoc` directory.
31 */ 31 */
32 main() { 32 mainWithOptions(Options options) {
33 // Need this because ArgParser.getUsage doesn't show command invocation. 33 // Need this because ArgParser.getUsage doesn't show command invocation.
34 final USAGE = 'Usage dartdoc [options] <entrypoint(s)>\n[options] include:'; 34 final USAGE = 'Usage dartdoc [options] <entrypoint(s)>\n[options] include:';
35 35
36 final args = new Options().arguments; 36 final args = options.arguments;
37 37
38 final dartdoc = new Dartdoc(); 38 final dartdoc = new Dartdoc();
39 39
40 final argParser = new ArgParser(); 40 final argParser = new ArgParser();
41 41
42 final Path libPath = scriptDir.append('../../../../'); 42 final Path libPath = scriptDir.append('../../../../');
43 43
44 String packageRoot; 44 String packageRoot;
45 45
46 argParser.addFlag('no-code', 46 argParser.addFlag('no-code',
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 } 242 }
243 }) 243 })
244 .catchError((e) { 244 .catchError((e) {
245 print('Error: generation failed: ${e}'); 245 print('Error: generation failed: ${e}');
246 dartdoc.cleanup(); 246 dartdoc.cleanup();
247 exit(1); 247 exit(1);
248 }) 248 })
249 .whenComplete(() => dartdoc.cleanup()); 249 .whenComplete(() => dartdoc.cleanup());
250 } 250 }
251 251
252 main() {
253 mainWithOptions(new Options());
254 }
255
252 String _getPackageRoot(List<Uri> entrypoints) { 256 String _getPackageRoot(List<Uri> entrypoints) {
253 // Check if there's a `packages` directory in the entry point directory. 257 // Check if there's a `packages` directory in the entry point directory.
254 var fileEntrypoint = entrypoints.firstWhere( 258 var fileEntrypoint = entrypoints.firstWhere(
255 (entrypoint) => entrypoint.scheme == 'file', 259 (entrypoint) => entrypoint.scheme == 'file',
256 orElse: () => null); 260 orElse: () => null);
257 if (fileEntrypoint == null) return; 261 if (fileEntrypoint == null) return;
258 262
259 var script = path.normalize(path.absolute(fileUriToPath(fileEntrypoint))); 263 var script = path.normalize(path.absolute(fileUriToPath(fileEntrypoint)));
260 var dir = path.join(path.dirname(script), 'packages/'); 264 var dir = path.join(path.dirname(script), 'packages/');
261 if (new Directory(dir).existsSync()) return dir; 265 if (new Directory(dir).existsSync()) return dir;
262 266
263 // If there is not, then check if the entrypoint is somewhere in a `lib` 267 // If there is not, then check if the entrypoint is somewhere in a `lib`
264 // directory. 268 // directory.
265 var parts = path.split(path.dirname(script)); 269 var parts = path.split(path.dirname(script));
266 var libDir = parts.lastIndexOf('lib'); 270 var libDir = parts.lastIndexOf('lib');
267 if (libDir > 0) { 271 if (libDir > 0) {
268 return path.join(path.joinAll(parts.take(libDir)), 'packages'); 272 return path.join(path.joinAll(parts.take(libDir)), 'packages');
269 } else { 273 } else {
270 return null; 274 return null;
271 } 275 }
272 } 276 }
OLDNEW
« sdk/bin/dartdoc ('K') | « sdk/bin/dartdoc ('k') | utils/compiler/compiler.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698