| OLD | NEW |
| 1 /** | 1 /** |
| 2 * The docgen tool takes in a library as input and produces documentation | 2 * The docgen tool takes in a library as input and produces documentation |
| 3 * for the library as well as all libraries it imports and uses. The tool can | 3 * for the library as well as all libraries it imports and uses. The tool can |
| 4 * be run by passing in the path to a .dart file like this: | 4 * be run by passing in the path to a .dart file like this: |
| 5 * | 5 * |
| 6 * ./dart docgen.dart path/to/file.dart | 6 * ./dart docgen.dart path/to/file.dart |
| 7 * | 7 * |
| 8 * This outputs information about all classes, variables, functions, and | 8 * This outputs information about all classes, variables, functions, and |
| 9 * methods defined in the library and its imported libraries. | 9 * methods defined in the library and its imported libraries. |
| 10 */ | 10 */ |
| 11 library docgen; | 11 library docgen; |
| 12 | 12 |
| 13 import 'dart:io'; | 13 import 'dart:io'; |
| 14 import 'dart:async'; | 14 import 'dart:async'; |
| 15 import 'lib/dart2yaml.dart'; | 15 import '../lib/dart2yaml.dart'; |
| 16 import 'lib/src/dart2js_mirrors.dart'; | 16 import '../lib/src/dart2js_mirrors.dart'; |
| 17 import 'package:markdown/markdown.dart' as markdown; | 17 import 'package:markdown/markdown.dart' as markdown; |
| 18 import '../../../../pkg/args/lib/args.dart'; | 18 import '../../args/lib/args.dart'; |
| 19 import '../compiler/implementation/mirrors/mirrors.dart'; | 19 import '../../../sdk/lib/_internal/compiler/implementation/mirrors/mirrors.dart'
; |
| 20 import '../compiler/implementation/mirrors/mirrors_util.dart'; | 20 import '../../../sdk/lib/_internal/compiler/implementation/mirrors/mirrors_util.
dart'; |
| 21 | 21 |
| 22 /** | 22 /** |
| 23 * Entry function to create YAML documentation from Dart files. | 23 * Entry function to create YAML documentation from Dart files. |
| 24 */ | 24 */ |
| 25 void main() { | 25 void main() { |
| 26 // TODO(tmandel): Use args library once flags are clear. | 26 // TODO(tmandel): Use args library once flags are clear. |
| 27 Options opts = new Options(); | 27 Options opts = new Options(); |
| 28 Docgen docgen = new Docgen(); | 28 Docgen docgen = new Docgen(); |
| 29 | 29 |
| 30 if (opts.arguments.length > 0) { | 30 if (opts.arguments.length > 0) { |
| 31 List<Path> libraries = [new Path(opts.arguments[0])]; | 31 List<Path> libraries = [new Path(opts.arguments[0])]; |
| 32 Path sdkDirectory = new Path("../../../"); | 32 Path sdkDirectory = new Path("../../../sdk/"); |
| 33 var workingMirrors = analyze(libraries, sdkDirectory, | 33 var workingMirrors = analyze(libraries, sdkDirectory, |
| 34 options: ['--preserve-comments', '--categories=Client,Server']); | 34 options: ['--preserve-comments', '--categories=Client,Server']); |
| 35 workingMirrors.then( (MirrorSystem mirrorSystem) { | 35 workingMirrors.then( (MirrorSystem mirrorSystem) { |
| 36 var mirrors = mirrorSystem.libraries.values; | 36 var mirrors = mirrorSystem.libraries.values; |
| 37 if (mirrors.isEmpty) { | 37 if (mirrors.isEmpty) { |
| 38 print("no LibraryMirrors"); | 38 print("no LibraryMirrors"); |
| 39 } else { | 39 } else { |
| 40 docgen.libraries = mirrors; | 40 docgen.libraries = mirrors; |
| 41 docgen.documentLibraries(); | 41 docgen.documentLibraries(); |
| 42 } | 42 } |
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 if (!dir.existsSync()) { | 350 if (!dir.existsSync()) { |
| 351 dir.createSync(); | 351 dir.createSync(); |
| 352 } | 352 } |
| 353 File file = new File('docs/$filename'); | 353 File file = new File('docs/$filename'); |
| 354 if (!file.exists()) { | 354 if (!file.exists()) { |
| 355 file.createSync(); | 355 file.createSync(); |
| 356 } | 356 } |
| 357 file.openSync(); | 357 file.openSync(); |
| 358 file.writeAsString(text); | 358 file.writeAsString(text); |
| 359 } | 359 } |
| OLD | NEW |