OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 /** | 5 /** |
6 * To generate docs for a library, run this script with the path to an | 6 * To generate docs for a library, run this script with the path to an |
7 * entrypoint .dart file, like: | 7 * entrypoint .dart file, like: |
8 * | 8 * |
9 * $ dart dartdoc.dart foo.dart | 9 * $ dart dartdoc.dart foo.dart |
10 * | 10 * |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 final outputDir = new Directory.fromPath(path); | 246 final outputDir = new Directory.fromPath(path); |
247 if (outputDir.existsSync()) { | 247 if (outputDir.existsSync()) { |
248 outputDir.deleteRecursivelySync(); | 248 outputDir.deleteRecursivelySync(); |
249 } | 249 } |
250 | 250 |
251 try { | 251 try { |
252 // TODO(3914): Hack to avoid 'file already exists' exception thrown | 252 // TODO(3914): Hack to avoid 'file already exists' exception thrown |
253 // due to invalid result from dir.existsSync() (probably due to race | 253 // due to invalid result from dir.existsSync() (probably due to race |
254 // conditions). | 254 // conditions). |
255 outputDir.createSync(); | 255 outputDir.createSync(); |
256 } catch (DirectoryIOException e) { | 256 } on DirectoryIOException catch (e) { |
257 // Ignore. | 257 // Ignore. |
258 } | 258 } |
259 } | 259 } |
260 | 260 |
261 /** | 261 /** |
262 * Copies all of the files in the directory [from] to [to]. Does *not* | 262 * Copies all of the files in the directory [from] to [to]. Does *not* |
263 * recursively copy subdirectories. | 263 * recursively copy subdirectories. |
264 * | 264 * |
265 * Note: runs asynchronously, so you won't see any files copied until after the | 265 * Note: runs asynchronously, so you won't see any files copied until after the |
266 * event loop has had a chance to pump (i.e. after `main()` has returned). | 266 * event loop has had a chance to pump (i.e. after `main()` has returned). |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
513 | 513 |
514 void endFile() { | 514 void endFile() { |
515 final outPath = outputDir.join(_filePath); | 515 final outPath = outputDir.join(_filePath); |
516 final dir = new Directory.fromPath(outPath.directoryPath); | 516 final dir = new Directory.fromPath(outPath.directoryPath); |
517 if (!dir.existsSync()) { | 517 if (!dir.existsSync()) { |
518 // TODO(3914): Hack to avoid 'file already exists' exception | 518 // TODO(3914): Hack to avoid 'file already exists' exception |
519 // thrown due to invalid result from dir.existsSync() (probably due to | 519 // thrown due to invalid result from dir.existsSync() (probably due to |
520 // race conditions). | 520 // race conditions). |
521 try { | 521 try { |
522 dir.createSync(); | 522 dir.createSync(); |
523 } catch (DirectoryIOException e) { | 523 } on DirectoryIOException catch (e) { |
524 // Ignore. | 524 // Ignore. |
525 } | 525 } |
526 } | 526 } |
527 | 527 |
528 writeString(new File.fromPath(outPath), _file.toString()); | 528 writeString(new File.fromPath(outPath), _file.toString()); |
529 _filePath = null; | 529 _filePath = null; |
530 _file = null; | 530 _file = null; |
531 } | 531 } |
532 | 532 |
533 void write(String s) { | 533 void write(String s) { |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
689 } | 689 } |
690 | 690 |
691 void docNavigationDart() { | 691 void docNavigationDart() { |
692 final dir = new Directory.fromPath(tmpPath); | 692 final dir = new Directory.fromPath(tmpPath); |
693 if (!dir.existsSync()) { | 693 if (!dir.existsSync()) { |
694 // TODO(3914): Hack to avoid 'file already exists' exception | 694 // TODO(3914): Hack to avoid 'file already exists' exception |
695 // thrown due to invalid result from dir.existsSync() (probably due to | 695 // thrown due to invalid result from dir.existsSync() (probably due to |
696 // race conditions). | 696 // race conditions). |
697 try { | 697 try { |
698 dir.createSync(); | 698 dir.createSync(); |
699 } catch (DirectoryIOException e) { | 699 } on DirectoryIOException catch (e) { |
700 // Ignore. | 700 // Ignore. |
701 } | 701 } |
702 } | 702 } |
703 String jsonString = JSON.stringify(createNavigationInfo()); | 703 String jsonString = JSON.stringify(createNavigationInfo()); |
704 String dartString = jsonString.replaceAll(@"$", @"\$"); | 704 String dartString = jsonString.replaceAll(@"$", @"\$"); |
705 final filePath = tmpPath.append('nav.dart'); | 705 final filePath = tmpPath.append('nav.dart'); |
706 writeString(new File.fromPath(filePath), | 706 writeString(new File.fromPath(filePath), |
707 'get json() => $dartString;'); | 707 'get json() => $dartString;'); |
708 } | 708 } |
709 | 709 |
(...skipping 1010 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1720 } | 1720 } |
1721 | 1721 |
1722 /** | 1722 /** |
1723 * Returns [:true:] if [type] should be regarded as an exception. | 1723 * Returns [:true:] if [type] should be regarded as an exception. |
1724 */ | 1724 */ |
1725 bool isException(TypeMirror type) { | 1725 bool isException(TypeMirror type) { |
1726 return type.simpleName.endsWith('Exception'); | 1726 return type.simpleName.endsWith('Exception'); |
1727 } | 1727 } |
1728 } | 1728 } |
1729 | 1729 |
OLD | NEW |