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

Side by Side Diff: tools/line_doc_comments.dart

Issue 12316036: Merge IO v2 branch to bleeding edge (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebased to r18818 Created 7 years, 10 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 | « tests/standalone/standalone.status ('k') | utils/apidoc/apidoc.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env dart 1 #!/usr/bin/env dart
2 2
3 /// Converts block-style Doc comments in Dart code to line style. 3 /// Converts block-style Doc comments in Dart code to line style.
4 library line_doc_comments; 4 library line_doc_comments;
5 import 'dart:io'; 5 import 'dart:io';
6 6
7 import '../pkg/path/lib/path.dart' as path; 7 import '../pkg/path/lib/path.dart' as path;
8 8
9 final oneLineBlock = new RegExp(r'^(\s*)/\*\*\s?(.*)\*/\s*$'); 9 final oneLineBlock = new RegExp(r'^(\s*)/\*\*\s?(.*)\*/\s*$');
10 final startBlock = new RegExp(r'^(\s*)/\*\*(.*)$'); 10 final startBlock = new RegExp(r'^(\s*)/\*\*(.*)$');
11 final blockLine = new RegExp(r'^\s*\*\s?(.*)$'); 11 final blockLine = new RegExp(r'^\s*\*\s?(.*)$');
12 final endBlock = new RegExp(r'^\s*\*/\s*$'); 12 final endBlock = new RegExp(r'^\s*\*/\s*$');
13 13
14 main() { 14 main() {
15 var args = new Options().arguments; 15 var args = new Options().arguments;
16 if (args.length != 1) { 16 if (args.length != 1) {
17 print('Converts "/**"-style block doc comments in a directory '); 17 print('Converts "/**"-style block doc comments in a directory ');
18 print('containing Dart code to "///"-style line doc comments.'); 18 print('containing Dart code to "///"-style line doc comments.');
19 print(''); 19 print('');
20 print('Usage: line_doc_coments.dart <dir>'); 20 print('Usage: line_doc_coments.dart <dir>');
21 return; 21 return;
22 } 22 }
23 23
24 var dir = new Directory(args[0]); 24 var dir = new Directory(args[0]);
25 var lister = dir.list(recursive: true); 25 dir.list(recursive: true).listen(
26 lister.onFile = (file) { 26 (entity) {
27 if (path.extension(file) != '.dart') return; 27 if (entity is File) {
28 fixFile(file); 28 var file = entity.name;
29 }; 29 if (path.extension(file) != '.dart') return;
30 fixFile(file);
31 }
32 });
30 } 33 }
31 34
32 void fixFile(String path) { 35 void fixFile(String path) {
33 var file = new File(path); 36 var file = new File(path);
34 file.readAsLines().transform(fixContents).chain((fixed) { 37 file.readAsLines().transform(fixContents).chain((fixed) {
35 return new File(path).writeAsString(fixed); 38 return new File(path).writeAsString(fixed);
36 }).then((file) { 39 }).then((file) {
37 print(file.name); 40 print(file.name);
38 }); 41 });
39 } 42 }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 } 81 }
79 } 82 }
80 } 83 }
81 } 84 }
82 85
83 if (line != null) buffer.add('$line\n'); 86 if (line != null) buffer.add('$line\n');
84 } 87 }
85 88
86 return buffer.toString(); 89 return buffer.toString();
87 } 90 }
OLDNEW
« no previous file with comments | « tests/standalone/standalone.status ('k') | utils/apidoc/apidoc.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698