| 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 * |
| 11 * Usage: | 11 * Usage: |
| 12 * | 12 * |
| 13 * $ dart apidoc.dart [--out=<output directory>] | 13 * $ dart apidoc.dart [--out=<output directory>] |
| 14 */ | 14 */ |
| 15 library apidoc; | 15 library apidoc; |
| 16 | 16 |
| 17 import 'dart:async'; | 17 import 'dart:async'; |
| 18 import 'dart:io'; | 18 import 'dart:io'; |
| 19 import 'dart:json' as json; | 19 import 'dart:json' as json; |
| 20 import 'dart:uri'; |
| 20 | 21 |
| 21 import 'html_diff.dart'; | 22 import 'html_diff.dart'; |
| 22 | 23 |
| 23 // TODO(rnystrom): Use "package:" URL (#4968). | 24 // TODO(rnystrom): Use "package:" URL (#4968). |
| 24 import '../../sdk/lib/_internal/compiler/implementation/mirrors/mirrors.dart'; | 25 import '../../sdk/lib/_internal/compiler/implementation/mirrors/mirrors.dart'; |
| 25 import '../../sdk/lib/_internal/compiler/implementation/mirrors/mirrors_util.dar
t'; | 26 import '../../sdk/lib/_internal/compiler/implementation/mirrors/mirrors_util.dar
t'; |
| 26 import '../../sdk/lib/_internal/dartdoc/lib/dartdoc.dart'; | 27 import '../../sdk/lib/_internal/dartdoc/lib/dartdoc.dart'; |
| 27 import '../../sdk/lib/_internal/libraries.dart'; | 28 import '../../sdk/lib/_internal/libraries.dart'; |
| 29 import 'package:pathos/path.dart' as pathos; |
| 28 | 30 |
| 29 HtmlDiff _diff; | 31 HtmlDiff _diff; |
| 30 | 32 |
| 31 void main() { | 33 void main() { |
| 32 final args = new Options().arguments; | 34 final args = new Options().arguments; |
| 33 | 35 |
| 34 int mode = MODE_STATIC; | 36 int mode = MODE_STATIC; |
| 35 Path outputDir = new Path('docs'); | 37 Path outputDir = new Path('docs'); |
| 36 bool generateAppCache = false; | 38 bool generateAppCache = false; |
| 37 | 39 |
| 38 List<String> excludedLibraries = <String>[]; | 40 List<String> excludedLibraries = <String>[]; |
| 39 List<String> includedLibraries = <String>[]; | 41 List<String> includedLibraries = <String>[]; |
| 40 Path packageRoot; | 42 String packageRoot; |
| 41 String version; | 43 String version; |
| 42 | 44 |
| 43 // Parse the command-line arguments. | 45 // Parse the command-line arguments. |
| 44 for (int i = 0; i < args.length; i++) { | 46 for (int i = 0; i < args.length; i++) { |
| 45 final arg = args[i]; | 47 final arg = args[i]; |
| 46 | 48 |
| 47 switch (arg) { | 49 switch (arg) { |
| 48 case '--mode=static': | 50 case '--mode=static': |
| 49 mode = MODE_STATIC; | 51 mode = MODE_STATIC; |
| 50 break; | 52 break; |
| 51 | 53 |
| 52 case '--mode=live-nav': | 54 case '--mode=live-nav': |
| 53 mode = MODE_LIVE_NAV; | 55 mode = MODE_LIVE_NAV; |
| 54 break; | 56 break; |
| 55 | 57 |
| 56 case '--generate-app-cache=true': | 58 case '--generate-app-cache=true': |
| 57 generateAppCache = true; | 59 generateAppCache = true; |
| 58 break; | 60 break; |
| 59 | 61 |
| 60 default: | 62 default: |
| 61 if (arg.startsWith('--exclude-lib=')) { | 63 if (arg.startsWith('--exclude-lib=')) { |
| 62 excludedLibraries.add(arg.substring('--exclude-lib='.length)); | 64 excludedLibraries.add(arg.substring('--exclude-lib='.length)); |
| 63 } else if (arg.startsWith('--include-lib=')) { | 65 } else if (arg.startsWith('--include-lib=')) { |
| 64 includedLibraries.add(arg.substring('--include-lib='.length)); | 66 includedLibraries.add(arg.substring('--include-lib='.length)); |
| 65 } else if (arg.startsWith('--out=')) { | 67 } else if (arg.startsWith('--out=')) { |
| 66 outputDir = new Path(arg.substring('--out='.length)); | 68 outputDir = new Path(arg.substring('--out='.length)); |
| 67 } else if (arg.startsWith('--package-root=')) { | 69 } else if (arg.startsWith('--package-root=')) { |
| 68 packageRoot = new Path(arg.substring('--package-root='.length)); | 70 packageRoot = arg.substring('--package-root='.length); |
| 69 } else if (arg.startsWith('--version=')) { | 71 } else if (arg.startsWith('--version=')) { |
| 70 version = arg.substring('--version='.length); | 72 version = arg.substring('--version='.length); |
| 71 } else { | 73 } else { |
| 72 print('Unknown option: $arg'); | 74 print('Unknown option: $arg'); |
| 73 return; | 75 return; |
| 74 } | 76 } |
| 75 break; | 77 break; |
| 76 } | 78 } |
| 77 } | 79 } |
| 78 | 80 |
| (...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 442 if (member is MethodMirror && (member.isConstructor || member.isFactory)) { | 444 if (member is MethodMirror && (member.isConstructor || member.isFactory)) { |
| 443 final separator = member.constructorName == '' ? '' : '.'; | 445 final separator = member.constructorName == '' ? '' : '.'; |
| 444 memberName = 'new $typeName$separator${member.constructorName}'; | 446 memberName = 'new $typeName$separator${member.constructorName}'; |
| 445 } | 447 } |
| 446 | 448 |
| 447 return a(memberUrl(member), memberName); | 449 return a(memberUrl(member), memberName); |
| 448 } | 450 } |
| 449 } | 451 } |
| 450 | 452 |
| 451 /** Converts a local path string to a `file:` [Uri]. */ | 453 /** Converts a local path string to a `file:` [Uri]. */ |
| 452 Uri _pathToFileUri(String pathString) { | 454 Uri _pathToFileUri(String path) { |
| 453 pathString = path.absolute(pathString); | 455 path = pathos.absolute(path); |
| 454 if (Platform.operatingSystem != 'windows') { | 456 if (Platform.operatingSystem != 'windows') { |
| 455 return Uri.parse('file://$pathString'); | 457 return Uri.parse('file://$path'); |
| 456 } else { | 458 } else { |
| 457 return Uri.parse('file:///${pathString.replaceAll("\\", "/")}'); | 459 return Uri.parse('file:///${path.replaceAll("\\", "/")}'); |
| 458 } | 460 } |
| 459 } | 461 } |
| 460 | 462 |
| OLD | NEW |