| 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 * This generates the reference documentation for the core libraries that come | 6 * This generates the reference documentation for the core libraries that come |
| 7 * with dart. It is built on top of dartdoc, which is a general-purpose library | 7 * with dart. It is built on top of dartdoc, which is a general-purpose library |
| 8 * for generating docs from any Dart code. This library extends that to include | 8 * for generating docs from any Dart code. This library extends that to include |
| 9 * additional information and styling specific to our standard library. | 9 * additional information and styling specific to our standard library. |
| 10 * | 10 * |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 // TODO(johnniwinther): Libraries for the compilation seem to be more like | 101 // TODO(johnniwinther): Libraries for the compilation seem to be more like |
| 102 // URIs. Perhaps Path should have a toURI() method. | 102 // URIs. Perhaps Path should have a toURI() method. |
| 103 // Add all of the core libraries. | 103 // Add all of the core libraries. |
| 104 final apidocLibraries = <Path>[]; | 104 final apidocLibraries = <Path>[]; |
| 105 LIBRARIES.forEach((String name, LibraryInfo info) { | 105 LIBRARIES.forEach((String name, LibraryInfo info) { |
| 106 if (info.documented) { | 106 if (info.documented) { |
| 107 apidocLibraries.add(new Path('dart:$name')); | 107 apidocLibraries.add(new Path('dart:$name')); |
| 108 } | 108 } |
| 109 }); | 109 }); |
| 110 | 110 |
| 111 var lister = new Directory.fromPath(doc.scriptDir.append('../../pkg')).list(); | 111 print('Generating docs...'); |
| 112 lister.listen( | 112 final apidoc = new Apidoc(mdn, outputDir, mode, generateAppCache, |
| 113 (entity) { | 113 excludedLibraries, version); |
| 114 if (entity is Directory) { | 114 apidoc.dartdocPath = |
| 115 var path = new Path(entity.path); | 115 doc.scriptDir.append('../../sdk/lib/_internal/dartdoc/'); |
| 116 var libName = path.filename; | 116 // Select the libraries to include in the produced documentation: |
| 117 apidoc.includeApi = true; |
| 118 apidoc.includedLibraries = includedLibraries; |
| 117 | 119 |
| 118 // Ignore hidden directories (like .svn) as well as pkg.xcodeproj. | 120 Future.wait([copiedStatic, copiedApiDocStatic, htmlDiff]).then((_) { |
| 119 if (libName.startsWith('.') || libName.endsWith('.xcodeproj')) { | 121 Future<bool> documented = |
| 120 return; | 122 apidoc.documentLibraries(apidocLibraries, libPath, pkgPath); |
| 121 } | |
| 122 | 123 |
| 123 // TODO(rnystrom): Get rid of oldStylePath support when all | 124 documented.then((_) { |
| 124 // packages are using new layout. See #5106. | 125 final compiled = doc.compileScript(mode, outputDir, libPath); |
| 125 var oldStylePath = path.append('${libName}.dart'); | |
| 126 var newStylePath = path.append('lib/${libName}.dart'); | |
| 127 | 126 |
| 128 if (new File.fromPath(oldStylePath).existsSync()) { | 127 Future.wait([compiled]).then((_) { |
| 129 apidocLibraries.add(oldStylePath); | 128 apidoc.cleanup(); |
| 130 includedLibraries.add(libName); | |
| 131 } else if (new File.fromPath(newStylePath).existsSync()) { | |
| 132 apidocLibraries.add(newStylePath); | |
| 133 includedLibraries.add(libName); | |
| 134 } else { | |
| 135 print('Warning: could not find package at $path'); | |
| 136 } | |
| 137 } | |
| 138 }, | |
| 139 onDone: () { | |
| 140 print('Generating docs...'); | |
| 141 final apidoc = new Apidoc(mdn, outputDir, mode, generateAppCache, | |
| 142 excludedLibraries, version); | |
| 143 apidoc.dartdocPath = | |
| 144 doc.scriptDir.append('../../sdk/lib/_internal/dartdoc/'); | |
| 145 // Select the libraries to include in the produced documentation: | |
| 146 apidoc.includeApi = true; | |
| 147 apidoc.includedLibraries = includedLibraries; | |
| 148 | |
| 149 Future.wait([copiedStatic, copiedApiDocStatic, htmlDiff]).then((_) { | |
| 150 Future<bool> documented = | |
| 151 apidoc.documentLibraries(apidocLibraries, libPath, pkgPath); | |
| 152 | |
| 153 documented.then((_) { | |
| 154 final compiled = doc.compileScript(mode, outputDir, libPath); | |
| 155 | |
| 156 Future.wait([compiled]).then((_) { | |
| 157 apidoc.cleanup(); | |
| 158 }); | |
| 159 }, onError: (AsyncError asyncError) { | |
| 160 print('Generation failed: ${asyncError.error}'); | |
| 161 apidoc.cleanup(); | |
| 162 }); | |
| 163 }); | |
| 164 }); | 129 }); |
| 130 }, onError: (AsyncError asyncError) { |
| 131 print('Generation failed: ${asyncError.error}'); |
| 132 apidoc.cleanup(); |
| 133 }); |
| 134 }); |
| 165 } | 135 } |
| 166 | 136 |
| 167 class Apidoc extends doc.Dartdoc { | 137 class Apidoc extends doc.Dartdoc { |
| 168 /** Big ball of JSON containing the scraped MDN documentation. */ | 138 /** Big ball of JSON containing the scraped MDN documentation. */ |
| 169 final Map mdn; | 139 final Map mdn; |
| 170 | 140 |
| 171 | 141 |
| 172 // A set of type names (TypeMirror.simpleName values) to ignore while | 142 // A set of type names (TypeMirror.simpleName values) to ignore while |
| 173 // looking up information from MDN data. TODO(eub, jacobr): fix up the MDN | 143 // looking up information from MDN data. TODO(eub, jacobr): fix up the MDN |
| 174 // import scripts so they run correctly and generate data that doesn't have | 144 // import scripts so they run correctly and generate data that doesn't have |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 445 final typeName = member.owner.simpleName; | 415 final typeName = member.owner.simpleName; |
| 446 var memberName = '$typeName.${member.simpleName}'; | 416 var memberName = '$typeName.${member.simpleName}'; |
| 447 if (member is MethodMirror && (member.isConstructor || member.isFactory)) { | 417 if (member is MethodMirror && (member.isConstructor || member.isFactory)) { |
| 448 final separator = member.constructorName == '' ? '' : '.'; | 418 final separator = member.constructorName == '' ? '' : '.'; |
| 449 memberName = 'new $typeName$separator${member.constructorName}'; | 419 memberName = 'new $typeName$separator${member.constructorName}'; |
| 450 } | 420 } |
| 451 | 421 |
| 452 return a(memberUrl(member), memberName); | 422 return a(memberUrl(member), memberName); |
| 453 } | 423 } |
| 454 } | 424 } |
| OLD | NEW |