| 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 var results = _initArgParser().parse(arguments); | 20 var results = _initArgParser().parse(arguments); |
| 21 | 21 |
| 22 var includeSdk = results['parse-sdk'] || results['include-sdk']; | 22 var includeSdk = results['parse-sdk'] || results['include-sdk']; |
| 23 var scriptDir = path.dirname(Platform.script.toFilePath()); | 23 var scriptDir = path.dirname(Platform.script.toFilePath()); |
| 24 var introFile = | 24 var introduction = includeSdk ? '' : results['introduction']; |
| 25 path.join(path.dirname(scriptDir), 'doc', 'sdk-introduction.md'); | |
| 26 var introduction = includeSdk ? introFile : results['introduction']; | |
| 27 docgen(results.rest.map(path.normalize).toList(), | 25 docgen(results.rest.map(path.normalize).toList(), |
| 28 packageRoot: results['package-root'], | 26 packageRoot: results['package-root'], |
| 29 outputToYaml: !results['json'], | 27 outputToYaml: !results['json'], |
| 30 includePrivate: results['include-private'], | 28 includePrivate: results['include-private'], |
| 31 includeSdk: includeSdk, | 29 includeSdk: includeSdk, |
| 32 parseSdk: results['parse-sdk'], | 30 parseSdk: results['parse-sdk'], |
| 33 append: results['append'] && new Directory(results['out']).existsSync(), | 31 append: results['append'] && new Directory(results['out']).existsSync(), |
| 34 introduction: introduction, | 32 introFileName: introduction, |
| 35 out: results['out'], | 33 out: results['out'], |
| 36 excludeLibraries: excludedLibraries, | 34 excludeLibraries: excludedLibraries, |
| 37 includeDependentPackages: results['include-dependent-packages']); | 35 includeDependentPackages: results['include-dependent-packages']); |
| 38 } | 36 } |
| 39 | 37 |
| 40 /** | 38 /** |
| 41 * Creates parser for docgen command line arguments. | 39 * Creates parser for docgen command line arguments. |
| 42 */ | 40 */ |
| 43 ArgParser _initArgParser() { | 41 ArgParser _initArgParser() { |
| 44 var parser = new ArgParser(); | 42 var parser = new ArgParser(); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 69 parser.addFlag('parse-sdk', | 67 parser.addFlag('parse-sdk', |
| 70 help: 'Parses the SDK libraries only.', | 68 help: 'Parses the SDK libraries only.', |
| 71 defaultsTo: false, negatable: false); | 69 defaultsTo: false, negatable: false); |
| 72 parser.addOption('package-root', | 70 parser.addOption('package-root', |
| 73 help: 'Sets the package root of the library being analyzed.'); | 71 help: 'Sets the package root of the library being analyzed.'); |
| 74 parser.addFlag('append', | 72 parser.addFlag('append', |
| 75 help: 'Append to the docs folder, library_list.json and index.txt', | 73 help: 'Append to the docs folder, library_list.json and index.txt', |
| 76 defaultsTo: false, negatable: false); | 74 defaultsTo: false, negatable: false); |
| 77 parser.addOption('introduction', | 75 parser.addOption('introduction', |
| 78 help: 'Adds the provided markdown text file as the introduction' | 76 help: 'Adds the provided markdown text file as the introduction' |
| 79 ' for the outputted documentation.', defaultsTo: ''); | 77 ' for the generated documentation.', defaultsTo: ''); |
| 80 parser.addOption('out', | 78 parser.addOption('out', |
| 81 help: 'The name of the output directory.', | 79 help: 'The name of the output directory.', |
| 82 defaultsTo: 'docs'); | 80 defaultsTo: 'docs'); |
| 83 parser.addOption('exclude-lib', | 81 parser.addOption('exclude-lib', |
| 84 help: 'Exclude the library by this name from the documentation', | 82 help: 'Exclude the library by this name from the documentation', |
| 85 allowMultiple: true, | 83 allowMultiple: true, |
| 86 callback: (libs) => excludedLibraries.addAll(libs)); | 84 callback: (libs) => excludedLibraries.addAll(libs)); |
| 87 parser.addFlag('include-dependent-packages', | 85 parser.addFlag('include-dependent-packages', |
| 88 help: 'Assumes we are documenting a single package and are running ' | 86 help: 'Assumes we are documenting a single package and are running ' |
| 89 'in the directory with its pubspec. Includes documentation for all ' | 87 'in the directory with its pubspec. Includes documentation for all ' |
| 90 'of its dependent packages.', | 88 'of its dependent packages.', |
| 91 defaultsTo: false, negatable: false); | 89 defaultsTo: false, negatable: false); |
| 92 return parser; | 90 return parser; |
| 93 } | 91 } |
| OLD | NEW |