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

Side by Side Diff: pkg/docgen/bin/docgen.dart

Issue 18438003: Removed ArgResult in lib/docgen.dart and removed top level variables. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 5 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 | « no previous file | pkg/docgen/lib/docgen.dart » ('j') | pkg/docgen/lib/docgen.dart » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 import 'dart:io'; 5 import 'dart:io';
6 6
7 import 'package:args/args.dart'; 7 import 'package:args/args.dart';
8 import 'package:logging/logging.dart'; 8 import 'package:logging/logging.dart';
9 9
10 import '../lib/docgen.dart'; 10 import '../lib/docgen.dart';
11 11
12 /** 12 /**
13 * Analyzes Dart files and generates a representation of included libraries, 13 * Analyzes Dart files and generates a representation of included libraries,
14 * classes, and members. 14 * classes, and members.
15 */ 15 */
16 void main() { 16 void main() {
17 logger.onRecord.listen((record) => print(record.message)); 17 logger.onRecord.listen((record) => print(record.message));
18 var results = initArgParser().parse(new Options().arguments); 18 var results = initArgParser().parse(new Options().arguments);
19 if (results['help']) return; 19 docgen(results.rest, packageDir: results['package-root'],
Andrei Mouravski 2013/07/02 00:58:29 Move packageDir: ... to the next line.
Andrei Mouravski 2013/07/02 00:58:29 Also, I think packageDir should be changed to pack
janicejl 2013/07/02 01:21:31 Done.
20 docgen(results); 20 outputToYaml: results['yaml'] || results['output-format'] == 'yaml',
Andrei Mouravski 2013/07/02 00:58:29 Create a var above this to hold this info.
janicejl 2013/07/02 01:21:31 Done.
21 outputToJson: results['json'] || results['output-format'] == 'json',
Andrei Mouravski 2013/07/02 00:58:29 Get rid of outputToJson, since it's a negation.
janicejl 2013/07/02 01:21:31 Done.
22 includePrivate: results['include-private'],
23 includeSdk: results['parse-sdk'] || results['include-sdk'],
24 parseSdk: results['parse-sdk']);
21 } 25 }
22 26
23 /** 27 /**
24 * Creates parser for docgen command line arguments. 28 * Creates parser for docgen command line arguments.
25 */ 29 */
26 ArgParser initArgParser() { 30 ArgParser initArgParser() {
Andrei Mouravski 2013/07/02 02:21:44 Probably should be private.
janicejl 2013/07/02 17:18:51 Done.
27 var parser = new ArgParser(); 31 var parser = new ArgParser();
28 parser.addFlag('help', abbr: 'h', 32 parser.addFlag('help', abbr: 'h',
29 help: 'Prints help and usage information.', 33 help: 'Prints help and usage information.',
30 negatable: false, 34 negatable: false,
31 callback: (help) { 35 callback: (help) {
32 if (help) { 36 if (help) {
33 logger.info(parser.getUsage()); 37 logger.info(parser.getUsage());
34 logger.info(USAGE); 38 logger.info(USAGE);
39 exit(0);
Andrei Mouravski 2013/07/02 00:58:29 Throw an exception instead.
janicejl 2013/07/02 01:21:31 If I throw an exception, wouldn't it cause a stack
Andrei Mouravski 2013/07/02 02:21:44 Yeah, but I'd also move the help logging stuff to
janicejl 2013/07/02 17:18:51 I decided to keep it in the callback so that all t
35 } 40 }
36 }); 41 });
37 parser.addFlag('verbose', abbr: 'v', 42 parser.addFlag('verbose', abbr: 'v',
38 help: 'Output more logging information.', negatable: false, 43 help: 'Output more logging information.', negatable: false,
39 callback: (verbose) { 44 callback: (verbose) {
40 if (verbose) Logger.root.level = Level.FINEST; 45 if (verbose) Logger.root.level = Level.FINEST;
41 }); 46 });
42 parser.addOption('output-format', abbr: 'o', 47 parser.addOption('output-format', abbr: 'o',
43 help: 'Sets the output format.', 48 help: 'Sets the output format.',
44 allowed: ['yaml', 'json'], 49 allowed: ['yaml', 'json'],
45 allowedHelp: {'yaml' : 'Outputs to YAML. (Default)', 50 allowedHelp: {'yaml' : 'Outputs to YAML. (Default)',
46 'json' : 'Outputs to JSON.'}); 51 'json' : 'Outputs to JSON.'});
47 parser.addFlag('yaml', abbr: 'y', 52 parser.addFlag('yaml', abbr: 'y',
48 help: 'Same as output-format=yaml.', negatable: false); 53 help: 'Same as output-format=yaml.', negatable: false);
49 parser.addFlag('json', abbr: 'j', 54 parser.addFlag('json', abbr: 'j',
50 help: 'Same as output-format=json.', negatable: false); 55 help: 'Same as output-format=json.', negatable: false);
51 parser.addFlag('include-private', 56 parser.addFlag('include-private',
52 help: 'Flag to include private declarations.', negatable: false); 57 help: 'Flag to include private declarations.', negatable: false);
53 parser.addFlag('include-sdk', 58 parser.addFlag('include-sdk',
54 help: 'Flag to parse SDK Library files.', negatable: false); 59 help: 'Flag to parse SDK Library files.', negatable: false);
55 parser.addFlag('parse-sdk', 60 parser.addFlag('parse-sdk',
56 help: 'Parses the SDK libraries only.', 61 help: 'Parses the SDK libraries only.',
57 defaultsTo: false, negatable: false); 62 defaultsTo: false, negatable: false);
58 parser.addOption('package-root', 63 parser.addOption('package-root',
59 help: "Sets the package root of the library being analyzed."); 64 help: "Sets the package root of the library being analyzed.");
60 65
61 return parser; 66 return parser;
62 } 67 }
OLDNEW
« no previous file with comments | « no previous file | pkg/docgen/lib/docgen.dart » ('j') | pkg/docgen/lib/docgen.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698