OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 final outputDir = new Directory.fromPath(path); | 80 final outputDir = new Directory.fromPath(path); |
81 if (outputDir.existsSync()) { | 81 if (outputDir.existsSync()) { |
82 outputDir.deleteSync(recursive: true); | 82 outputDir.deleteSync(recursive: true); |
83 } | 83 } |
84 | 84 |
85 try { | 85 try { |
86 // TODO(3914): Hack to avoid 'file already exists' exception thrown | 86 // TODO(3914): Hack to avoid 'file already exists' exception thrown |
87 // due to invalid result from dir.existsSync() (probably due to race | 87 // due to invalid result from dir.existsSync() (probably due to race |
88 // conditions). | 88 // conditions). |
89 outputDir.createSync(); | 89 outputDir.createSync(); |
90 } on DirectoryIOException catch (e) { | 90 } on DirectoryException catch (e) { |
91 // Ignore. | 91 // Ignore. |
92 } | 92 } |
93 } | 93 } |
94 | 94 |
95 /** | 95 /** |
96 * Copies all of the files in the directory [from] to [to]. Does *not* | 96 * Copies all of the files in the directory [from] to [to]. Does *not* |
97 * recursively copy subdirectories. | 97 * recursively copy subdirectories. |
98 * | 98 * |
99 * Note: runs asynchronously, so you won't see any files copied until after the | 99 * Note: runs asynchronously, so you won't see any files copied until after the |
100 * event loop has had a chance to pump (i.e. after `main()` has returned). | 100 * event loop has had a chance to pump (i.e. after `main()` has returned). |
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
595 | 595 |
596 void endFile() { | 596 void endFile() { |
597 final outPath = outputDir.join(_filePath); | 597 final outPath = outputDir.join(_filePath); |
598 final dir = new Directory.fromPath(outPath.directoryPath); | 598 final dir = new Directory.fromPath(outPath.directoryPath); |
599 if (!dir.existsSync()) { | 599 if (!dir.existsSync()) { |
600 // TODO(3914): Hack to avoid 'file already exists' exception | 600 // TODO(3914): Hack to avoid 'file already exists' exception |
601 // thrown due to invalid result from dir.existsSync() (probably due to | 601 // thrown due to invalid result from dir.existsSync() (probably due to |
602 // race conditions). | 602 // race conditions). |
603 try { | 603 try { |
604 dir.createSync(); | 604 dir.createSync(); |
605 } on DirectoryIOException catch (e) { | 605 } on DirectoryException catch (e) { |
606 // Ignore. | 606 // Ignore. |
607 } | 607 } |
608 } | 608 } |
609 | 609 |
610 writeString(new File.fromPath(outPath), _file.toString()); | 610 writeString(new File.fromPath(outPath), _file.toString()); |
611 _filePath = null; | 611 _filePath = null; |
612 _file = null; | 612 _file = null; |
613 } | 613 } |
614 | 614 |
615 void write(String s) { | 615 void write(String s) { |
(...skipping 1668 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2284 return ''' | 2284 return ''' |
2285 <div class="mdn"> | 2285 <div class="mdn"> |
2286 $mdnComment | 2286 $mdnComment |
2287 <div class="mdn-note"><a href="$mdnUrl">from MDN</a></div> | 2287 <div class="mdn-note"><a href="$mdnUrl">from MDN</a></div> |
2288 </div> | 2288 </div> |
2289 '''; | 2289 '''; |
2290 } | 2290 } |
2291 | 2291 |
2292 String toString() => mdnComment; | 2292 String toString() => mdnComment; |
2293 } | 2293 } |
OLD | NEW |