Chromium Code Reviews| 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 19 matching lines...) Expand all Loading... | |
| 30 | 30 |
| 31 void main() { | 31 void main() { |
| 32 final args = new Options().arguments; | 32 final args = new Options().arguments; |
| 33 | 33 |
| 34 int mode = MODE_STATIC; | 34 int mode = MODE_STATIC; |
| 35 Path outputDir = new Path('docs'); | 35 Path outputDir = new Path('docs'); |
| 36 bool generateAppCache = false; | 36 bool generateAppCache = false; |
| 37 | 37 |
| 38 List<String> excludedLibraries = <String>[]; | 38 List<String> excludedLibraries = <String>[]; |
| 39 List<String> includedLibraries = <String>[]; | 39 List<String> includedLibraries = <String>[]; |
| 40 Path pkgPath; | 40 Path packageRoot; |
| 41 String version; | 41 String version; |
| 42 | 42 |
| 43 // Parse the command-line arguments. | 43 // Parse the command-line arguments. |
| 44 for (int i = 0; i < args.length; i++) { | 44 for (int i = 0; i < args.length; i++) { |
| 45 final arg = args[i]; | 45 final arg = args[i]; |
| 46 | 46 |
| 47 switch (arg) { | 47 switch (arg) { |
| 48 case '--mode=static': | 48 case '--mode=static': |
| 49 mode = MODE_STATIC; | 49 mode = MODE_STATIC; |
| 50 break; | 50 break; |
| 51 | 51 |
| 52 case '--mode=live-nav': | 52 case '--mode=live-nav': |
| 53 mode = MODE_LIVE_NAV; | 53 mode = MODE_LIVE_NAV; |
| 54 break; | 54 break; |
| 55 | 55 |
| 56 case '--generate-app-cache=true': | 56 case '--generate-app-cache=true': |
| 57 generateAppCache = true; | 57 generateAppCache = true; |
| 58 break; | 58 break; |
| 59 | 59 |
| 60 default: | 60 default: |
| 61 if (arg.startsWith('--exclude-lib=')) { | 61 if (arg.startsWith('--exclude-lib=')) { |
| 62 excludedLibraries.add(arg.substring('--exclude-lib='.length)); | 62 excludedLibraries.add(arg.substring('--exclude-lib='.length)); |
| 63 } else if (arg.startsWith('--include-lib=')) { | 63 } else if (arg.startsWith('--include-lib=')) { |
| 64 includedLibraries.add(arg.substring('--include-lib='.length)); | 64 includedLibraries.add(arg.substring('--include-lib='.length)); |
| 65 } else if (arg.startsWith('--out=')) { | 65 } else if (arg.startsWith('--out=')) { |
| 66 outputDir = new Path(arg.substring('--out='.length)); | 66 outputDir = new Path(arg.substring('--out='.length)); |
| 67 } else if (arg.startsWith('--pkg=')) { | 67 } else if (arg.startsWith('--package-root=')) { |
| 68 pkgPath = new Path(arg.substring('--pkg='.length)); | 68 packageRoot = new Path(arg.substring('--package-root='.length)); |
| 69 } else if (arg.startsWith('--version=')) { | 69 } else if (arg.startsWith('--version=')) { |
| 70 version = arg.substring('--version='.length); | 70 version = arg.substring('--version='.length); |
| 71 } else { | 71 } else { |
| 72 print('Unknown option: $arg'); | 72 print('Unknown option: $arg'); |
| 73 return; | 73 return; |
| 74 } | 74 } |
| 75 break; | 75 break; |
| 76 } | 76 } |
| 77 } | 77 } |
| 78 | 78 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 140 final apidoc = new Apidoc(mdn, outputDir, mode, generateAppCache, | 140 final apidoc = new Apidoc(mdn, outputDir, mode, generateAppCache, |
| 141 excludedLibraries, version); | 141 excludedLibraries, version); |
| 142 apidoc.dartdocPath = | 142 apidoc.dartdocPath = |
| 143 scriptDir.append('../../sdk/lib/_internal/dartdoc/'); | 143 scriptDir.append('../../sdk/lib/_internal/dartdoc/'); |
| 144 // Select the libraries to include in the produced documentation: | 144 // Select the libraries to include in the produced documentation: |
| 145 apidoc.includeApi = true; | 145 apidoc.includeApi = true; |
| 146 apidoc.includedLibraries = includedLibraries; | 146 apidoc.includedLibraries = includedLibraries; |
| 147 | 147 |
| 148 // TODO(amouravski): make apidoc use roughly the same flow as bin/dartdoc. | 148 // TODO(amouravski): make apidoc use roughly the same flow as bin/dartdoc. |
| 149 Future.wait([copiedStatic, copiedApiDocStatic, htmlDiff]) | 149 Future.wait([copiedStatic, copiedApiDocStatic, htmlDiff]) |
| 150 .then((_) => apidoc.documentLibraries(apidocLibraries, libPath, pkgPath)) | 150 .then((_) => apidoc.documentLibraries(apidocLibraries, libPath, packageRoo t)) |
|
Jacob
2013/04/02 01:03:41
>80 chars
Andrei Mouravski
2013/04/02 01:05:47
Done.
| |
| 151 .then((_) => compileScript(mode, outputDir, libPath)) | 151 .then((_) => compileScript(mode, outputDir, libPath)) |
| 152 .then((_) => print(apidoc.status)) | 152 .then((_) => print(apidoc.status)) |
| 153 .catchError((e) => print('Error: generation failed: ${e.error}')) | 153 .catchError((e) => print('Error: generation failed: ${e.error}')) |
| 154 .whenComplete(() => apidoc.cleanup()); | 154 .whenComplete(() => apidoc.cleanup()); |
| 155 }); | 155 }); |
| 156 } | 156 } |
| 157 | 157 |
| 158 class Apidoc extends Dartdoc { | 158 class Apidoc extends Dartdoc { |
| 159 /** Big ball of JSON containing the scraped MDN documentation. */ | 159 /** Big ball of JSON containing the scraped MDN documentation. */ |
| 160 final Map mdn; | 160 final Map mdn; |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 435 final typeName = member.owner.simpleName; | 435 final typeName = member.owner.simpleName; |
| 436 var memberName = '$typeName.${member.simpleName}'; | 436 var memberName = '$typeName.${member.simpleName}'; |
| 437 if (member is MethodMirror && (member.isConstructor || member.isFactory)) { | 437 if (member is MethodMirror && (member.isConstructor || member.isFactory)) { |
| 438 final separator = member.constructorName == '' ? '' : '.'; | 438 final separator = member.constructorName == '' ? '' : '.'; |
| 439 memberName = 'new $typeName$separator${member.constructorName}'; | 439 memberName = 'new $typeName$separator${member.constructorName}'; |
| 440 } | 440 } |
| 441 | 441 |
| 442 return a(memberUrl(member), memberName); | 442 return a(memberUrl(member), memberName); |
| 443 } | 443 } |
| 444 } | 444 } |
| OLD | NEW |