| 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 | 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 | 19 |
| 20 docgen(results.rest, | 20 docgen(results.rest, |
| 21 packageRoot: results['package-root'], | 21 packageRoot: results['package-root'], |
| 22 outputToYaml: !results['json'], | 22 outputToYaml: !results['json'], |
| 23 includePrivate: results['include-private'], | 23 includePrivate: results['include-private'], |
| 24 includeSdk: results['parse-sdk'] || results['include-sdk'], | 24 includeSdk: results['parse-sdk'] || results['include-sdk'], |
| 25 parseSdk: results['parse-sdk'], | 25 parseSdk: results['parse-sdk'], |
| 26 append: results['append'] && new Directory('docs').existsSync()); | 26 append: results['append'] && new Directory('docs').existsSync(), |
| 27 introduction: results['parse-sdk'] ? |
| 28 'sdk-introduction.md' : results['introduction']); |
| 27 } | 29 } |
| 28 | 30 |
| 29 /** | 31 /** |
| 30 * Creates parser for docgen command line arguments. | 32 * Creates parser for docgen command line arguments. |
| 31 */ | 33 */ |
| 32 ArgParser _initArgParser() { | 34 ArgParser _initArgParser() { |
| 33 var parser = new ArgParser(); | 35 var parser = new ArgParser(); |
| 34 parser.addFlag('help', abbr: 'h', | 36 parser.addFlag('help', abbr: 'h', |
| 35 help: 'Prints help and usage information.', | 37 help: 'Prints help and usage information.', |
| 36 negatable: false, | 38 negatable: false, |
| (...skipping 13 matching lines...) Expand all Loading... |
| 50 help: 'Outputs to JSON. Files are outputted to YAML by default.', | 52 help: 'Outputs to JSON. Files are outputted to YAML by default.', |
| 51 negatable: true); | 53 negatable: true); |
| 52 parser.addFlag('include-private', | 54 parser.addFlag('include-private', |
| 53 help: 'Flag to include private declarations.', negatable: false); | 55 help: 'Flag to include private declarations.', negatable: false); |
| 54 parser.addFlag('include-sdk', | 56 parser.addFlag('include-sdk', |
| 55 help: 'Flag to parse SDK Library files.', negatable: false); | 57 help: 'Flag to parse SDK Library files.', negatable: false); |
| 56 parser.addFlag('parse-sdk', | 58 parser.addFlag('parse-sdk', |
| 57 help: 'Parses the SDK libraries only.', | 59 help: 'Parses the SDK libraries only.', |
| 58 defaultsTo: false, negatable: false); | 60 defaultsTo: false, negatable: false); |
| 59 parser.addOption('package-root', | 61 parser.addOption('package-root', |
| 60 help: "Sets the package root of the library being analyzed."); | 62 help: 'Sets the package root of the library being analyzed.'); |
| 61 parser.addFlag('append', | 63 parser.addFlag('append', |
| 62 help: 'Append to the docs folder, library_list.txt and index.txt', | 64 help: 'Append to the docs folder, library_list.txt and index.txt', |
| 63 defaultsTo: false, negatable: false); | 65 defaultsTo: false, negatable: false); |
| 66 parser.addOption('introduction', |
| 67 help: 'Adds the provided markdown text file as the introduction' |
| 68 'for the outputted documentation.', defaultsTo: ''); |
| 64 | 69 |
| 65 return parser; | 70 return parser; |
| 66 } | 71 } |
| OLD | NEW |