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

Side by Side Diff: tools/html-json-doc/bin/htmlJsonDoc.dart

Issue 11280133: Both halves of the HTMLDoc to JSON doc converter! (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fixed bin. Created 8 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
(Empty)
1 /**
2 * TODO(amouravski): Document stuff here.
3 */
4
5 import 'dart:io';
6
7 import '../lib/HtmlToJson.dart' as htmlToJson;
8 import '../lib/JsonToHtml.dart' as jsonToHtml;
9 import '../../../pkg/args/lib/args.dart';
10
11 // Need this because ArgParser.getUsage doesn't show command invocation.
12 final USAGE = 'Usage htmlJsonDoc [options] --mode=<mode> <HTML.dart directory> '
Bob Nystrom 2012/11/26 22:00:19 Make this "const" or rename to "usage".
Andrei Mouravski 2012/11/27 03:11:45 Done.
13 '<json path>\n[options] include:';
14 final argParser = htmlJsonDocArgParser();
15
16 main() {
17 final args = new Options().arguments;
18
19 if (args.isEmpty) {
20 printUsage('No arguments provided.');
21 return;
22 }
23
24 var htmlToJsonMode;
25
26 final argResults = argParser.parse(args);
27 try {
28 htmlToJsonMode = argResults['mode'] == 'html-to-json';
29 } on ArgumentError catch (e) {
Bob Nystrom 2012/11/26 22:00:19 You shouldn't catch ArgumentError. (In general, yo
Andrei Mouravski 2012/11/27 03:11:45 Done.
30 printUsage('Mode is a required option.');
31 }
32
33 var htmlPath = new Path.fromNative(argResults.rest[0]);
34 var jsonPath = new Path.fromNative(argResults.rest[1]);
35
36 if (htmlPath == null || jsonPath == null) {
Bob Nystrom 2012/11/26 22:00:19 How would these ever be null? Maybe just: if (ar
Andrei Mouravski 2012/11/27 03:11:45 Done.
37 printUsage('Insufficient arguments.');
38 return;
39 }
40
41 var convertFuture;
42 if (htmlToJsonMode) {
43 convertFuture = htmlToJson.convert(htmlPath, jsonPath);
44 } else {
45 convertFuture = jsonToHtml.convert(htmlPath, jsonPath);
46 }
47
48 convertFuture.then((anyErrors) {
49 print('Completed ${anyErrors ? "with" : "without"} errrors.');
Bob Nystrom 2012/11/26 22:00:19 Arrrrr, ye have too many Rs in yer errors!
Andrei Mouravski 2012/11/27 03:11:45 Done. Amusingly I was trying to debug some of my o
50 });
51 }
52
53 /// Prints the usage of the tool. [message] is printed if provided.
54 void printUsage([String message]) {
55 print(message);
56 print(USAGE);
57 print(argParser.getUsage());
58 }
59
60 ArgParser htmlJsonDocArgParser() {
61 final argParser = new ArgParser();
62
63 argParser.addOption('mode', abbr: 'm',
64 help: '(Required) Convert from HTML docs to JSON or vice versa.',
65 allowed: ['html-to-json', 'json-to-html'], allowedHelp: {
66 'html-to-json': 'Processes all HTML .dart files at given\n'
67 'location and outputs JSON.',
68 'json-to-html': 'Takes JSON file at location and inserts docs into\n'
69 'HTML .dart files.'}
Bob Nystrom 2012/11/26 22:00:19 Yay usage help!
Andrei Mouravski 2012/11/27 03:11:45 P.S. Copied wholesale from pub I think. Maybe one
70 );
71
72 return argParser;
73 }
OLDNEW
« no previous file with comments | « no previous file | tools/html-json-doc/lib/HtmlToJson.dart » ('j') | tools/html-json-doc/lib/HtmlToJson.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698