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

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
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 * Entry function to create YAML documentation from Dart files.
Andrei Mouravski 2013/06/18 02:42:36 "Analyzes Dart files and generates a representatio
janicejl 2013/06/18 18:42:46 Done.
11 */
12 void main() {
Andrei Mouravski 2013/06/18 02:42:36 Why did you make this file? The entry point should
janicejl 2013/06/18 18:42:46 I moved everything to the Lib folder so that I can
Andrei Mouravski 2013/06/18 19:31:00 main should stay in bin/docgen.dart so that people
13 Options opts = new Options();
Andrei Mouravski 2013/06/18 02:42:36 This whole section is very inconsistent. I have to
Andrei Mouravski 2013/06/18 10:17:45 I think the Docgen constructor should take all of
janicejl 2013/06/18 18:42:46 Done.
14 Docgen docgen = new Docgen();
15
16 var parser = createArgParser(docgen);
17 var results = parser.parse(opts.arguments);
18
19 if (results.rest.length != 1) {
Andrei Mouravski 2013/06/18 10:17:45 This should really be: if (results.rest.length !=
janicejl 2013/06/18 18:42:46 Done.
20 print ("Usage: dart docgen.dart [OPTIONS] [FILE/DIR]");
Andrei Mouravski 2013/06/18 10:17:45 Don't use print. Create a logger and use that inst
janicejl 2013/06/18 18:42:46 Done.
21 } else {
22 var directory = new Path(opts.arguments.last).directoryPath;
Andrei Mouravski 2013/06/18 10:17:45 Use pathos instead, please.
Andrei Mouravski 2013/06/18 10:17:45 This should probably use results.rest, yo.
janicejl 2013/06/18 18:42:46 Done.
23 var libraries = [];
24 Path sdkDirectory = new Path("../../../../../dart/dart-sdk");
Andrei Mouravski 2013/06/18 10:17:45 Make these vars.
Andrei Mouravski 2013/06/18 10:17:45 Ugh. The pain. I'm not sure this will work in ever
janicejl 2013/06/18 18:42:46 Will it be better to get the user to pass in the l
Andrei Mouravski 2013/06/18 22:54:01 No. Just use what pub does in pub/lib/src/sdk.dart
25 Path packageDir = directory.append("packages");
Andrei Mouravski 2013/06/18 10:17:45 What if the packages directory isn't there?
26
27 if (FileSystemEntity.isFileSync(opts.arguments.last)) {
Andrei Mouravski 2013/06/18 10:17:45 This all feels rather clumsy. I think Pub might ha
janicejl 2013/06/18 18:42:46 Done.
28 libraries = [new Path(opts.arguments.last)];
29 } else {
30 libraries = new List<Path>();
31 new Directory.fromPath(directory).listSync(recursive: true,
32 followLinks: true).forEach((file) {
33 if (new Path(file.path).extension == "dart") {
34 if (!file.path.contains("/packages/")) {
35 libraries.add(new Path(file.path));
36 }
37 }
38 });
39 }
40
41 var workingMirrors = dart2js.analyze(libraries, sdkDirectory,
42 packageRoot: packageDir,
43 options: ['--preserve-comments', '--categories=Client,Server']);
Andrei Mouravski 2013/06/18 10:17:45 We may want to just hardcode these into the dart2j
44
45 workingMirrors.then( (MirrorSystem mirrorSystem) {
Andrei Mouravski 2013/06/18 10:17:45 No space between ( (.
janicejl 2013/06/18 18:42:46 Done.
46 var mirrors = mirrorSystem.libraries.values;
47 if (mirrors.isEmpty) {
Andrei Mouravski 2013/06/18 10:17:45 Don't just print, throw an error! They screwed up!
janicejl 2013/06/18 18:42:46 Done.
48 print("no LibraryMirrors");
Andrei Mouravski 2013/06/18 10:17:45 Don't print. Log.
janicejl 2013/06/18 18:42:46 Done.
49 } else {
50 docgen.libraries = mirrors;
Andrei Mouravski 2013/06/18 10:17:45 Instead of holding onto the mirrors object, just s
janicejl 2013/06/18 18:42:46 Done.
51 docgen.documentLibraries();
Andrei Mouravski 2013/06/18 10:17:45 This is the only operative bit of code here. I thi
janicejl 2013/06/18 18:42:46 Done.
52 }
53 });
54 }
55 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698