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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: pkg/docgen/bin/docgen_main.dart
diff --git a/pkg/docgen/bin/docgen_main.dart b/pkg/docgen/bin/docgen_main.dart
new file mode 100644
index 0000000000000000000000000000000000000000..49de1246af284f9ab19e40c96f67f1182aa4a876
--- /dev/null
+++ b/pkg/docgen/bin/docgen_main.dart
@@ -0,0 +1,55 @@
+import 'dart:io';
+import 'package:docgen/docgen.dart';
+import 'package:args/args.dart';
+import 'package:compiler_unsupported/implementation/mirrors/dart2js_mirror.dart';
+import '../lib/src/dart2js_mirrors.dart' as dart2js;
+import 'package:compiler_unsupported/implementation/mirrors/mirrors.dart';
+import 'package:compiler_unsupported/implementation/mirrors/mirrors_util.dart';
+
+/**
+ * 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.
+ */
+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
+ 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.
+ Docgen docgen = new Docgen();
+
+ var parser = createArgParser(docgen);
+ var results = parser.parse(opts.arguments);
+
+ 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.
+ 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.
+ } else {
+ 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.
+ var libraries = [];
+ 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
+ Path packageDir = directory.append("packages");
Andrei Mouravski 2013/06/18 10:17:45 What if the packages directory isn't there?
+
+ 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.
+ libraries = [new Path(opts.arguments.last)];
+ } else {
+ libraries = new List<Path>();
+ new Directory.fromPath(directory).listSync(recursive: true,
+ followLinks: true).forEach((file) {
+ if (new Path(file.path).extension == "dart") {
+ if (!file.path.contains("/packages/")) {
+ libraries.add(new Path(file.path));
+ }
+ }
+ });
+ }
+
+ var workingMirrors = dart2js.analyze(libraries, sdkDirectory,
+ packageRoot: packageDir,
+ options: ['--preserve-comments', '--categories=Client,Server']);
Andrei Mouravski 2013/06/18 10:17:45 We may want to just hardcode these into the dart2j
+
+ workingMirrors.then( (MirrorSystem mirrorSystem) {
Andrei Mouravski 2013/06/18 10:17:45 No space between ( (.
janicejl 2013/06/18 18:42:46 Done.
+ var mirrors = mirrorSystem.libraries.values;
+ 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.
+ print("no LibraryMirrors");
Andrei Mouravski 2013/06/18 10:17:45 Don't print. Log.
janicejl 2013/06/18 18:42:46 Done.
+ } else {
+ 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.
+ 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.
+ }
+ });
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698