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

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

Issue 35743002: Make docgen able to generate pkg docs and save the package names (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Make sure we have an ending newline in index.txt, also write a JSON index, and include packageName … Created 7 years, 1 month 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
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 import 'package:path/path.dart' as path;
11 12
12 /** 13 /**
13 * Analyzes Dart files and generates a representation of included libraries, 14 * Analyzes Dart files and generates a representation of included libraries,
14 * classes, and members. 15 * classes, and members.
15 */ 16 */
16 void main() { 17 void main() {
17 logger.onRecord.listen((record) => print(record.message)); 18 logger.onRecord.listen((record) => print(record.message));
18 var results = _initArgParser().parse(new Options().arguments); 19 var results = _initArgParser().parse(new Options().arguments);
19 20
20 docgen(results.rest, 21 docgen(results.rest.map(path.normalize).toList(),
21 packageRoot: results['package-root'], 22 packageRoot: results['package-root'],
22 outputToYaml: !results['json'], 23 outputToYaml: !results['json'],
23 includePrivate: results['include-private'], 24 includePrivate: results['include-private'],
24 includeSdk: results['parse-sdk'] || results['include-sdk'], 25 includeSdk: results['parse-sdk'] || results['include-sdk'],
25 parseSdk: results['parse-sdk'], 26 parseSdk: results['parse-sdk'],
26 append: results['append'] && new Directory('docs').existsSync(), 27 append: results['append'] && new Directory('docs').existsSync(),
27 introduction: results['parse-sdk'] ? 28 introduction: results['parse-sdk'] ?
28 'sdk-introduction.md' : results['introduction']); 29 'sdk-introduction.md' : results['introduction']);
29 } 30 }
30 31
31 /** 32 /**
32 * Creates parser for docgen command line arguments. 33 * Creates parser for docgen command line arguments.
33 */ 34 */
34 ArgParser _initArgParser() { 35 ArgParser _initArgParser() {
35 var parser = new ArgParser(); 36 var parser = new ArgParser();
36 parser.addFlag('help', abbr: 'h', 37 parser.addFlag('help', abbr: 'h',
37 help: 'Prints help and usage information.', 38 help: 'Prints help and usage information.',
38 negatable: false, 39 negatable: false,
39 callback: (help) { 40 callback: (help) {
40 if (help) { 41 if (help) {
41 logger.info(parser.getUsage()); 42 logger.info(parser.getUsage());
42 logger.info(USAGE); 43 logger.info(USAGE);
43 exit(0); 44 exit(0);
44 } 45 }
45 }); 46 });
46 parser.addFlag('verbose', abbr: 'v', 47 parser.addFlag('verbose', abbr: 'v',
47 help: 'Output more logging information.', negatable: false, 48 help: 'Output more logging information.', negatable: false,
48 callback: (verbose) { 49 callback: (verbose) {
49 if (verbose) Logger.root.level = Level.FINEST; 50 if (verbose) Logger.root.level = Level.FINEST;
50 }); 51 });
51 parser.addFlag('json', abbr: 'j', 52 parser.addFlag('json', abbr: 'j',
52 help: 'Outputs to JSON. Files are outputted to YAML by default. ' 53 help: 'Outputs to JSON. Files are outputted to YAML by default. '
53 'If --append is used, it takes the file-format of the previous ' 54 'If --append is used, it takes the file-format of the previous '
54 'run stated in library_list.json ignoring the flag.', 55 'run stated in library_list.json ignoring the flag.',
55 negatable: true); 56 negatable: true);
56 parser.addFlag('include-private', 57 parser.addFlag('include-private',
57 help: 'Flag to include private declarations.', negatable: false); 58 help: 'Flag to include private declarations.', negatable: false);
58 parser.addFlag('include-sdk', 59 parser.addFlag('include-sdk',
59 help: 'Flag to parse SDK Library files.', negatable: false); 60 help: 'Flag to parse SDK Library files.', negatable: false);
60 parser.addFlag('parse-sdk', 61 parser.addFlag('parse-sdk',
61 help: 'Parses the SDK libraries only.', 62 help: 'Parses the SDK libraries only.',
62 defaultsTo: false, negatable: false); 63 defaultsTo: false, negatable: false);
63 parser.addOption('package-root', 64 parser.addOption('package-root',
64 help: 'Sets the package root of the library being analyzed.'); 65 help: 'Sets the package root of the library being analyzed.');
65 parser.addFlag('append', 66 parser.addFlag('append',
66 help: 'Append to the docs folder, library_list.json and index.txt', 67 help: 'Append to the docs folder, library_list.json and index.txt',
67 defaultsTo: false, negatable: false); 68 defaultsTo: false, negatable: false);
68 parser.addOption('introduction', 69 parser.addOption('introduction',
69 help: 'Adds the provided markdown text file as the introduction' 70 help: 'Adds the provided markdown text file as the introduction'
70 ' for the outputted documentation.', defaultsTo: ''); 71 ' for the outputted documentation.', defaultsTo: '');
71 72
72 return parser; 73 return parser;
73 } 74 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698