| 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 15 matching lines...) Expand all Loading... |
| 26 | 26 |
| 27 HtmlDiff _diff; | 27 HtmlDiff _diff; |
| 28 | 28 |
| 29 void main() { | 29 void main() { |
| 30 final args = new Options().arguments; | 30 final args = new Options().arguments; |
| 31 | 31 |
| 32 int mode = doc.MODE_STATIC; | 32 int mode = doc.MODE_STATIC; |
| 33 Path outputDir = new Path('docs'); | 33 Path outputDir = new Path('docs'); |
| 34 bool generateAppCache = false; | 34 bool generateAppCache = false; |
| 35 | 35 |
| 36 List<String> excludedLibraries = <String>[]; |
| 37 |
| 36 // Parse the command-line arguments. | 38 // Parse the command-line arguments. |
| 37 for (int i = 0; i < args.length; i++) { | 39 for (int i = 0; i < args.length; i++) { |
| 38 final arg = args[i]; | 40 final arg = args[i]; |
| 39 | 41 |
| 40 switch (arg) { | 42 switch (arg) { |
| 41 case '--mode=static': | 43 case '--mode=static': |
| 42 mode = doc.MODE_STATIC; | 44 mode = doc.MODE_STATIC; |
| 43 break; | 45 break; |
| 44 | 46 |
| 45 case '--mode=live-nav': | 47 case '--mode=live-nav': |
| 46 mode = doc.MODE_LIVE_NAV; | 48 mode = doc.MODE_LIVE_NAV; |
| 47 break; | 49 break; |
| 48 | 50 |
| 49 case '--generate-app-cache=true': | 51 case '--generate-app-cache=true': |
| 50 generateAppCache = true; | 52 generateAppCache = true; |
| 51 break; | 53 break; |
| 52 | 54 |
| 53 default: | 55 default: |
| 54 if (arg.startsWith('--out=')) { | 56 if (arg.startsWith('--exclude-lib=')) { |
| 57 excludedLibraries.add(arg.substring('--exclude-lib='.length)); |
| 58 } else if (arg.startsWith('--out=')) { |
| 55 outputDir = new Path.fromNative(arg.substring('--out='.length)); | 59 outputDir = new Path.fromNative(arg.substring('--out='.length)); |
| 56 } else { | 60 } else { |
| 57 print('Unknown option: $arg'); | 61 print('Unknown option: $arg'); |
| 58 return; | 62 return; |
| 59 } | 63 } |
| 60 break; | 64 break; |
| 61 } | 65 } |
| 62 } | 66 } |
| 63 | 67 |
| 64 final libPath = doc.scriptDir.append('../../'); | 68 final libPath = doc.scriptDir.append('../../'); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 } else if (new File.fromPath(newStylePath).existsSync()) { | 127 } else if (new File.fromPath(newStylePath).existsSync()) { |
| 124 apidocLibraries.add(newStylePath); | 128 apidocLibraries.add(newStylePath); |
| 125 includedLibraries.add(libName); | 129 includedLibraries.add(libName); |
| 126 } else { | 130 } else { |
| 127 print('Warning: could not find package at $path'); | 131 print('Warning: could not find package at $path'); |
| 128 } | 132 } |
| 129 }; | 133 }; |
| 130 | 134 |
| 131 lister.onDone = (success) { | 135 lister.onDone = (success) { |
| 132 print('Generating docs...'); | 136 print('Generating docs...'); |
| 133 final apidoc = new Apidoc(mdn, htmldoc, outputDir, mode, generateAppCache); | 137 final apidoc = new Apidoc(mdn, htmldoc, outputDir, mode, generateAppCache, |
| 138 excludedLibraries); |
| 134 apidoc.dartdocPath = doc.scriptDir.append('../../pkg/dartdoc/'); | 139 apidoc.dartdocPath = doc.scriptDir.append('../../pkg/dartdoc/'); |
| 135 // Select the libraries to include in the produced documentation: | 140 // Select the libraries to include in the produced documentation: |
| 136 apidoc.includeApi = true; | 141 apidoc.includeApi = true; |
| 137 apidoc.includedLibraries = includedLibraries; | 142 apidoc.includedLibraries = includedLibraries; |
| 138 | 143 |
| 139 Futures.wait([copiedStatic, copiedApiDocStatic]).then((_) { | 144 Futures.wait([copiedStatic, copiedApiDocStatic]).then((_) { |
| 140 apidoc.documentLibraries(apidocLibraries, libPath, pkgPath); | 145 apidoc.documentLibraries(apidocLibraries, libPath, pkgPath); |
| 141 | 146 |
| 142 final compiled = doc.compileScript(mode, outputDir, libPath); | 147 final compiled = doc.compileScript(mode, outputDir, libPath); |
| 143 | 148 |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 static Set<String> _mdnTypeNamesToSkip = null; | 256 static Set<String> _mdnTypeNamesToSkip = null; |
| 252 | 257 |
| 253 /** | 258 /** |
| 254 * The URL to the page on MDN that content was pulled from for the current | 259 * The URL to the page on MDN that content was pulled from for the current |
| 255 * type being documented. Will be `null` if the type doesn't use any MDN | 260 * type being documented. Will be `null` if the type doesn't use any MDN |
| 256 * content. | 261 * content. |
| 257 */ | 262 */ |
| 258 String mdnUrl = null; | 263 String mdnUrl = null; |
| 259 | 264 |
| 260 Apidoc(this.mdn, this.htmldoc, Path outputDir, int mode, | 265 Apidoc(this.mdn, this.htmldoc, Path outputDir, int mode, |
| 261 bool generateAppCache) { | 266 bool generateAppCache, [excludedLibraries]) { |
| 267 if (?excludedLibraries) { |
| 268 this.excludedLibraries = excludedLibraries; |
| 269 } |
| 270 |
| 262 this.outputDir = outputDir; | 271 this.outputDir = outputDir; |
| 263 this.mode = mode; | 272 this.mode = mode; |
| 264 this.generateAppCache = generateAppCache; | 273 this.generateAppCache = generateAppCache; |
| 265 | 274 |
| 266 // Skip bad entries in the checked-in mdn/database.json: | 275 // Skip bad entries in the checked-in mdn/database.json: |
| 267 // * UnknownElement has a top-level Gecko DOM page in German. | 276 // * UnknownElement has a top-level Gecko DOM page in German. |
| 268 if (_mdnTypeNamesToSkip == null) | 277 if (_mdnTypeNamesToSkip == null) |
| 269 _mdnTypeNamesToSkip = new Set.from(['UnknownElement']); | 278 _mdnTypeNamesToSkip = new Set.from(['UnknownElement']); |
| 270 | 279 |
| 271 mainTitle = 'Dart API Reference'; | 280 mainTitle = 'Dart API Reference'; |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 569 return ''' | 578 return ''' |
| 570 <div class="mdn"> | 579 <div class="mdn"> |
| 571 $mdnComment | 580 $mdnComment |
| 572 <div class="mdn-note"><a href="$mdnUrl">from MDN</a></div> | 581 <div class="mdn-note"><a href="$mdnUrl">from MDN</a></div> |
| 573 </div> | 582 </div> |
| 574 '''; | 583 '''; |
| 575 } | 584 } |
| 576 | 585 |
| 577 String toString() => mdnComment; | 586 String toString() => mdnComment; |
| 578 } | 587 } |
| OLD | NEW |