| OLD | NEW |
| 1 // Copyright (c) 2012, 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 * |
| 11 * This will create a "docs" directory with the docs for your libraries. To | 11 * This will create a "docs" directory with the docs for your libraries. To |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 /** | 100 /** |
| 101 * Copies all of the files in the directory [from] to [to]. Does *not* | 101 * Copies all of the files in the directory [from] to [to]. Does *not* |
| 102 * recursively copy subdirectories. | 102 * recursively copy subdirectories. |
| 103 * | 103 * |
| 104 * Note: runs asynchronously, so you won't see any files copied until after the | 104 * Note: runs asynchronously, so you won't see any files copied until after the |
| 105 * event loop has had a chance to pump (i.e. after `main()` has returned). | 105 * event loop has had a chance to pump (i.e. after `main()` has returned). |
| 106 */ | 106 */ |
| 107 Future copyDirectory(Path from, Path to) { | 107 Future copyDirectory(Path from, Path to) { |
| 108 final completer = new Completer(); | 108 final completer = new Completer(); |
| 109 final fromDir = new Directory.fromPath(from); | 109 final fromDir = new Directory.fromPath(from); |
| 110 final lister = fromDir.list(recursive: false); | 110 fromDir.list(recursive: false).listen( |
| 111 (FileSystemEntity entity) { |
| 112 if (entity is File) { |
| 113 final name = new Path(entity.name).filename; |
| 114 // TODO(rnystrom): Hackish. Ignore 'hidden' files like .DS_Store. |
| 115 if (name.startsWith('.')) return; |
| 111 | 116 |
| 112 lister.onFile = (String path) { | 117 File fromFile = entity; |
| 113 final name = new Path(path).filename; | 118 File toFile = new File.fromPath(to.append(name)); |
| 114 // TODO(rnystrom): Hackish. Ignore 'hidden' files like .DS_Store. | 119 fromFile.openRead().pipe(toFile.openWrite()); |
| 115 if (name.startsWith('.')) return; | 120 } |
| 116 | 121 }, |
| 117 File fromFile = new File(path); | 122 onDone: () => completer.complete(true)); |
| 118 File toFile = new File.fromPath(to.append(name)); | |
| 119 fromFile.openInputStream().pipe(toFile.openOutputStream()); | |
| 120 }; | |
| 121 lister.onDone = (done) => completer.complete(true); | |
| 122 return completer.future; | 123 return completer.future; |
| 123 } | 124 } |
| 124 | 125 |
| 125 /** | 126 /** |
| 126 * Compiles the dartdoc client-side code to JavaScript using Dart2js. | 127 * Compiles the dartdoc client-side code to JavaScript using Dart2js. |
| 127 */ | 128 */ |
| 128 Future<bool> compileScript(int mode, Path outputDir, Path libPath) { | 129 Future<bool> compileScript(int mode, Path outputDir, Path libPath) { |
| 129 var clientScript = (mode == MODE_STATIC) ? 'static' : 'live-nav'; | 130 var clientScript = (mode == MODE_STATIC) ? 'static' : 'live-nav'; |
| 130 var dartPath = libPath.append( | 131 var dartPath = libPath.append( |
| 131 'lib/_internal/dartdoc/lib/src/client/client-$clientScript.dart'); | 132 'lib/_internal/dartdoc/lib/src/client/client-$clientScript.dart'); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 final String fullVersion; | 169 final String fullVersion; |
| 169 /** | 170 /** |
| 170 * Source control revision number for the package. For SVN this is a number | 171 * Source control revision number for the package. For SVN this is a number |
| 171 * while for GIT it is a hash. | 172 * while for GIT it is a hash. |
| 172 */ | 173 */ |
| 173 final String revision; | 174 final String revision; |
| 174 /** | 175 /** |
| 175 * Path to the directory containing data files for each library. | 176 * Path to the directory containing data files for each library. |
| 176 * | 177 * |
| 177 * Currently this is the serialized json version of the LibraryElement for | 178 * Currently this is the serialized json version of the LibraryElement for |
| 178 * the library. | 179 * the library. |
| 179 */ | 180 */ |
| 180 String location; | 181 String location; |
| 181 /** | 182 /** |
| 182 * Packages depended on by this package. | 183 * Packages depended on by this package. |
| 183 * We currently store the entire manifest for the depency here the manifests | 184 * We currently store the entire manifest for the depency here the manifests |
| 184 * are small. We may want to change this to a reference in the future. | 185 * are small. We may want to change this to a reference in the future. |
| 185 */ | 186 */ |
| 186 final List<PackageManifest> dependencies = <PackageManifest>[]; | 187 final List<PackageManifest> dependencies = <PackageManifest>[]; |
| 187 | 188 |
| 188 PackageManifest(this.name, this.description, this.fullVersion, this.revision); | 189 PackageManifest(this.name, this.description, this.fullVersion, this.revision); |
| (...skipping 1706 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1895 generateAppCacheManifest() { | 1896 generateAppCacheManifest() { |
| 1896 if (verbose) { | 1897 if (verbose) { |
| 1897 print('Generating app cache manifest from output $outputDir'); | 1898 print('Generating app cache manifest from output $outputDir'); |
| 1898 } | 1899 } |
| 1899 startFile('appcache.manifest'); | 1900 startFile('appcache.manifest'); |
| 1900 write("CACHE MANIFEST\n\n"); | 1901 write("CACHE MANIFEST\n\n"); |
| 1901 write("# VERSION: ${new DateTime.now()}\n\n"); | 1902 write("# VERSION: ${new DateTime.now()}\n\n"); |
| 1902 write("NETWORK:\n*\n\n"); | 1903 write("NETWORK:\n*\n\n"); |
| 1903 write("CACHE:\n"); | 1904 write("CACHE:\n"); |
| 1904 var toCache = new Directory.fromPath(outputDir); | 1905 var toCache = new Directory.fromPath(outputDir); |
| 1905 var toCacheLister = toCache.list(recursive: true); | 1906 toCache.list(recursive: true).listen( |
| 1906 toCacheLister.onFile = (filename) { | 1907 (FileSystemEntity entity) { |
| 1907 if (filename.endsWith('appcache.manifest')) { | 1908 if (entity.isFile) { |
| 1908 return; | 1909 var filename = entity.path; |
| 1909 } | 1910 if (filename.endsWith('appcache.manifest')) { |
| 1910 Path relativeFilePath = new Path(filename).relativeTo(outputDir); | 1911 return; |
| 1911 write("$relativeFilePath\n"); | 1912 } |
| 1912 }; | 1913 Path relativeFilePath = new Path(filename).relativeTo(outputDir); |
| 1913 toCacheLister.onDone = (done) => endFile(); | 1914 write("$relativeFilePath\n"); |
| 1915 } |
| 1916 }, |
| 1917 onDone: () => endFile()); |
| 1914 } | 1918 } |
| 1915 | 1919 |
| 1916 /** | 1920 /** |
| 1917 * Returns [:true:] if [type] should be regarded as an exception. | 1921 * Returns [:true:] if [type] should be regarded as an exception. |
| 1918 */ | 1922 */ |
| 1919 bool isException(TypeMirror type) { | 1923 bool isException(TypeMirror type) { |
| 1920 return type.simpleName.endsWith('Exception') || | 1924 return type.simpleName.endsWith('Exception') || |
| 1921 type.simpleName.endsWith('Error'); | 1925 type.simpleName.endsWith('Error'); |
| 1922 } | 1926 } |
| 1923 } | 1927 } |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2003 return ''' | 2007 return ''' |
| 2004 <div class="mdn"> | 2008 <div class="mdn"> |
| 2005 $mdnComment | 2009 $mdnComment |
| 2006 <div class="mdn-note"><a href="$mdnUrl">from MDN</a></div> | 2010 <div class="mdn-note"><a href="$mdnUrl">from MDN</a></div> |
| 2007 </div> | 2011 </div> |
| 2008 '''; | 2012 '''; |
| 2009 } | 2013 } |
| 2010 | 2014 |
| 2011 String toString() => mdnComment; | 2015 String toString() => mdnComment; |
| 2012 } | 2016 } |
| OLD | NEW |