blob: 293f3cf416403384e1f4f1b51328e4825d73f858 [file] [log] [blame]
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'dart:io';
import 'package:args/args.dart';
import 'package:logging/logging.dart';
import '../lib/docgen.dart';
* Analyzes Dart files and generates a representation of included libraries,
* classes, and members.
void main() {
logger.onRecord.listen((record) => print(record.message));
var results = _initArgParser().parse(new Options().arguments);
packageRoot: results['package-root'],
outputToYaml: !results['json'],
includePrivate: results['include-private'],
includeSdk: results['parse-sdk'] || results['include-sdk'],
parseSdk: results['parse-sdk'],
append: results['append'] && new Directory('docs').existsSync(),
introduction: results['parse-sdk'] ?
'' : results['introduction']);
* Creates parser for docgen command line arguments.
ArgParser _initArgParser() {
var parser = new ArgParser();
parser.addFlag('help', abbr: 'h',
help: 'Prints help and usage information.',
negatable: false,
callback: (help) {
if (help) {;;
parser.addFlag('verbose', abbr: 'v',
help: 'Output more logging information.', negatable: false,
callback: (verbose) {
if (verbose) Logger.root.level = Level.FINEST;
parser.addFlag('json', abbr: 'j',
help: 'Outputs to JSON. Files are outputted to YAML by default. '
'If --append is used, it takes the file-format of the previous '
'run stated in library_list.json ignoring the flag.',
negatable: true);
help: 'Flag to include private declarations.', negatable: false);
help: 'Flag to parse SDK Library files.', negatable: false);
help: 'Parses the SDK libraries only.',
defaultsTo: false, negatable: false);
help: 'Sets the package root of the library being analyzed.');
help: 'Append to the docs folder, library_list.json and index.txt',
defaultsTo: false, negatable: false);
help: 'Adds the provided markdown text file as the introduction'
' for the outputted documentation.', defaultsTo: '');
return parser;