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

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

Issue 16948010: added Command Line Arguments, support for directories, hiding private data, not parsing the SDK, rem (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 6 months 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
« no previous file with comments | « pkg/docgen/bin/docgen.dart ('k') | pkg/docgen/example/test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 import 'dart:io';
2 import 'package:docgen/docgen.dart';
3 import 'package:args/args.dart';
4 import 'package:compiler_unsupported/implementation/mirrors/dart2js_mirror.dart' ;
5 import '../lib/src/dart2js_mirrors.dart' as dart2js;
6 import 'package:compiler_unsupported/implementation/mirrors/mirrors.dart';
7 import 'package:compiler_unsupported/implementation/mirrors/mirrors_util.dart';
8
9 /**
10 * Analyzes Dart files and generate a representation of included libraries,
Andrei Mouravski 2013/06/18 19:31:00 generates
janicejl 2013/06/18 21:52:34 Done.
11 * classes and members.
Andrei Mouravski 2013/06/18 22:54:01 Please use the Oxford Comma, that is to say, "lib
12 */
13 void main() {
14 var results = createArgParser().parse(new Options().arguments);
15 Docgen docgen = new Docgen(sdkRoot: new Path("../../../../../dart/dart-sdk"),
Andrei Mouravski 2013/06/18 22:54:01 Why does Docgen need the sdkRoot?
16 argResults: results);
17
18 var libraries = _listLibraries(results.rest);
19 Path packageDir = libraries.last.directoryPath.append("packages");
20
21 var workingMirrors = dart2js.analyze(libraries, docgen.sdkRoot,
Andrei Mouravski 2013/06/18 22:54:01 This work looks like it should be done in the cont
22 packageRoot: packageDir,
23 options: ['--preserve-comments', '--categories=Client,Server']);
24
25 workingMirrors.then((MirrorSystem mirrorSystem) {
26 if (mirrorSystem.libraries.values.isEmpty) {
27 throw new UnsupportedError("No Library Mirrors. ");
28 }
29 docgen.libraries = mirrorSystem.libraries.values;
30 docgen.documentLibraries();
31 });
32 }
33
34 /**
35 * Returns a ArgParser with all the flags and options created.
36 */
37 ArgParser createArgParser() {
Andrei Mouravski 2013/06/18 19:31:00 How about initArgParser
janicejl 2013/06/18 21:52:34 Done.
38 var parser = new ArgParser();
39 parser.addFlag("help", abbr: "h",
40 help: "Prints help and usage information",
41 negatable: false,
42 callback: (help) {
43 if (help) print(parser.getUsage());
44 });
45 parser.addFlag("yaml", abbr: "y",
46 help: "Outputs to YAML",
47 defaultsTo: true, negatable: true);
48 parser.addFlag("json", abbr: "j",
49 help: "Outputs to JSON",
50 defaultsTo: false, negatable: true);
51 parser.addFlag("hide-private",
52 help: "Hides private declarations" ,
53 defaultsTo: false, negatable: false);
54 parser.addFlag("sdk",
55 help: "Flag to parse SDK Library files",
56 defaultsTo: true, negatable: true);
57
58 return parser;
59 }
60
61 List<Path> _listLibraries(List<String> args) {
62 if (args.length != 1) {
63 throw new UnsupportedError("Usage: dart docgen.dart [OPTIONS] [FILE/DIR]");
Andrei Mouravski 2013/06/18 22:54:01 Make a string constant for this since you use it o
64 }
65 var libraries = new List<Path>();
66 var type = FileSystemEntity.typeSync(args[0]);
67
68 if (type == FileSystemEntityType.LINK) {
69 throw new UnsupportedError("""File should not be a link.
Andrei Mouravski 2013/06/18 22:54:01 Why are these """ literal strings?
70 Usage: dart docgen.dart [OPTIONS] [FILE/DIR]""");
71 } else if (type == FileSystemEntityType.NOT_FOUND) {
72 throw new UnsupportedError("""File does not exist.
73 Usage: dart docgen.dart [OPTIONS] [FILE/DIR]""");
74 } else if (type == FileSystemEntityType.FILE) {
75 libraries.add(new Path(args[0]));
76 } else if (type == FileSystemEntityType.DIRECTORY) {
77 new Directory(args[0]).listSync(recursive: true,
78 followLinks: true).forEach((file) {
79 if (new Path(file.path).extension == "dart") {
80 if (!file.path.contains("/packages/")) {
81 libraries.add(new Path(file.path));
82 }
83 }
84 });
85 }
86 return libraries;
87 }
OLDNEW
« no previous file with comments | « pkg/docgen/bin/docgen.dart ('k') | pkg/docgen/example/test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698