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 = []; | |
14 | |
13 /** | 15 /** |
14 * Analyzes Dart files and generates a representation of included libraries, | 16 * Analyzes Dart files and generates a representation of included libraries, |
15 * classes, and members. | 17 * classes, and members. |
16 */ | 18 */ |
17 void main(List<String> arguments) { | 19 void main(List<String> arguments) { |
18 logger.onRecord.listen((record) => print(record.message)); | 20 logger.onRecord.listen((record) => print(record.message)); |
19 var results = _initArgParser().parse(arguments); | 21 var results = _initArgParser().parse(arguments); |
20 | 22 |
23 var includeSdk = results['parse-sdk'] || results['include-sdk']; | |
24 var introFile = path.join(path.dirname(Platform.script.toFilePath()), | |
25 'sdk-introduction.md'); | |
kustermann
2013/11/18 09:57:08
Why is this markup file in the docgen/bin director
Alan Knight
2013/11/18 20:34:50
I suspect so it was easy to find for bin/docgen.da
| |
26 var introduction = includeSdk ? introFile : results['introduction']; | |
21 docgen(results.rest.map(path.normalize).toList(), | 27 docgen(results.rest.map(path.normalize).toList(), |
22 packageRoot: results['package-root'], | 28 packageRoot: results['package-root'], |
23 outputToYaml: !results['json'], | 29 outputToYaml: !results['json'], |
24 includePrivate: results['include-private'], | 30 includePrivate: results['include-private'], |
25 includeSdk: results['parse-sdk'] || results['include-sdk'], | 31 includeSdk: includeSdk, |
26 parseSdk: results['parse-sdk'], | 32 parseSdk: results['parse-sdk'], |
27 append: results['append'] && new Directory('docs').existsSync(), | 33 append: results['append'] && new Directory(results['out']).existsSync(), |
28 introduction: (results['parse-sdk'] || results['include-sdk']) ? | 34 introduction: introduction, |
29 'sdk-introduction.md' : results['introduction']); | 35 out: results['out'], |
36 excludeLibraries: excludedLibraries); | |
30 } | 37 } |
31 | 38 |
32 /** | 39 /** |
33 * Creates parser for docgen command line arguments. | 40 * Creates parser for docgen command line arguments. |
34 */ | 41 */ |
35 ArgParser _initArgParser() { | 42 ArgParser _initArgParser() { |
36 var parser = new ArgParser(); | 43 var parser = new ArgParser(); |
37 parser.addFlag('help', abbr: 'h', | 44 parser.addFlag('help', abbr: 'h', |
38 help: 'Prints help and usage information.', | 45 help: 'Prints help and usage information.', |
39 negatable: false, | 46 negatable: false, |
(...skipping 22 matching lines...) Expand all Loading... | |
62 help: 'Parses the SDK libraries only.', | 69 help: 'Parses the SDK libraries only.', |
63 defaultsTo: false, negatable: false); | 70 defaultsTo: false, negatable: false); |
64 parser.addOption('package-root', | 71 parser.addOption('package-root', |
65 help: 'Sets the package root of the library being analyzed.'); | 72 help: 'Sets the package root of the library being analyzed.'); |
66 parser.addFlag('append', | 73 parser.addFlag('append', |
67 help: 'Append to the docs folder, library_list.json and index.txt', | 74 help: 'Append to the docs folder, library_list.json and index.txt', |
68 defaultsTo: false, negatable: false); | 75 defaultsTo: false, negatable: false); |
69 parser.addOption('introduction', | 76 parser.addOption('introduction', |
70 help: 'Adds the provided markdown text file as the introduction' | 77 help: 'Adds the provided markdown text file as the introduction' |
71 ' for the outputted documentation.', defaultsTo: ''); | 78 ' for the outputted documentation.', defaultsTo: ''); |
72 | 79 parser.addOption('out', |
80 help: 'The name of the output directory.', | |
81 defaultsTo: 'docs'); | |
82 parser.addOption('exclude-lib', | |
83 help: 'Exclude the library by this name from the documentation', | |
84 allowMultiple: true, | |
85 callback: (libs) => excludedLibraries.addAll(libs)); | |
73 return parser; | 86 return parser; |
74 } | 87 } |
OLD | NEW |