| OLD | NEW |
| 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 import 'package:path/path.dart' as path; | 11 import 'package:path/path.dart' as path; |
| 12 | 12 |
| 13 List<String> excludedLibraries = []; | 13 List<String> excludedLibraries = []; |
| 14 | 14 |
| 15 /** | 15 /** |
| 16 * Analyzes Dart files and generates a representation of included libraries, | 16 * Analyzes Dart files and generates a representation of included libraries, |
| 17 * classes, and members. | 17 * classes, and members. |
| 18 */ | 18 */ |
| 19 void main(List<String> arguments) { | 19 void main(List<String> arguments) { |
| 20 logger.onRecord.listen((record) => print(record.message)); | |
| 21 var results = _initArgParser().parse(arguments); | 20 var results = _initArgParser().parse(arguments); |
| 22 | 21 |
| 23 var includeSdk = results['parse-sdk'] || results['include-sdk']; | 22 var includeSdk = results['parse-sdk'] || results['include-sdk']; |
| 24 var scriptDir = path.dirname(Platform.script.toFilePath()); | 23 var scriptDir = path.dirname(Platform.script.toFilePath()); |
| 25 var introFile = | 24 var introFile = |
| 26 path.join(path.dirname(scriptDir), 'doc', 'sdk-introduction.md'); | 25 path.join(path.dirname(scriptDir), 'doc', 'sdk-introduction.md'); |
| 27 var introduction = includeSdk ? introFile : results['introduction']; | 26 var introduction = includeSdk ? introFile : results['introduction']; |
| 28 docgen(results.rest.map(path.normalize).toList(), | 27 docgen(results.rest.map(path.normalize).toList(), |
| 29 packageRoot: results['package-root'], | 28 packageRoot: results['package-root'], |
| 30 outputToYaml: !results['json'], | 29 outputToYaml: !results['json'], |
| (...skipping 10 matching lines...) Expand all Loading... |
| 41 /** | 40 /** |
| 42 * Creates parser for docgen command line arguments. | 41 * Creates parser for docgen command line arguments. |
| 43 */ | 42 */ |
| 44 ArgParser _initArgParser() { | 43 ArgParser _initArgParser() { |
| 45 var parser = new ArgParser(); | 44 var parser = new ArgParser(); |
| 46 parser.addFlag('help', abbr: 'h', | 45 parser.addFlag('help', abbr: 'h', |
| 47 help: 'Prints help and usage information.', | 46 help: 'Prints help and usage information.', |
| 48 negatable: false, | 47 negatable: false, |
| 49 callback: (help) { | 48 callback: (help) { |
| 50 if (help) { | 49 if (help) { |
| 51 logger.info(parser.getUsage()); | 50 print(parser.getUsage()); |
| 52 logger.info(USAGE); | 51 print('Usage: dart docgen.dart [OPTIONS] fooDir/barFile'); |
| 53 exit(0); | 52 exit(0); |
| 54 } | 53 } |
| 55 }); | 54 }); |
| 56 parser.addFlag('verbose', abbr: 'v', | 55 parser.addFlag('verbose', abbr: 'v', |
| 57 help: 'Output more logging information.', negatable: false, | 56 help: 'Output more logging information.', negatable: false, |
| 58 callback: (verbose) { | 57 callback: (verbose) { |
| 59 if (verbose) Logger.root.level = Level.FINEST; | 58 if (verbose) Logger.root.level = Level.FINEST; |
| 60 }); | 59 }); |
| 61 parser.addFlag('json', abbr: 'j', | 60 parser.addFlag('json', abbr: 'j', |
| 62 help: 'Outputs to JSON. Files are outputted to YAML by default. ' | 61 help: 'Outputs to JSON. Files are outputted to YAML by default. ' |
| (...skipping 22 matching lines...) Expand all Loading... |
| 85 help: 'Exclude the library by this name from the documentation', | 84 help: 'Exclude the library by this name from the documentation', |
| 86 allowMultiple: true, | 85 allowMultiple: true, |
| 87 callback: (libs) => excludedLibraries.addAll(libs)); | 86 callback: (libs) => excludedLibraries.addAll(libs)); |
| 88 parser.addFlag('include-dependent-packages', | 87 parser.addFlag('include-dependent-packages', |
| 89 help: 'Assumes we are documenting a single package and are running ' | 88 help: 'Assumes we are documenting a single package and are running ' |
| 90 'in the directory with its pubspec. Includes documentation for all ' | 89 'in the directory with its pubspec. Includes documentation for all ' |
| 91 'of its dependent packages.', | 90 'of its dependent packages.', |
| 92 defaultsTo: false, negatable: false); | 91 defaultsTo: false, negatable: false); |
| 93 return parser; | 92 return parser; |
| 94 } | 93 } |
| OLD | NEW |