| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 * **docgen** is a tool for creating machine readable representations of Dart | 6 * **docgen** is a tool for creating machine readable representations of Dart |
| 7 * code metadata, including: classes, members, comments and annotations. | 7 * code metadata, including: classes, members, comments and annotations. |
| 8 * | 8 * |
| 9 * docgen is run on a `.dart` file or a directory containing `.dart` files. | 9 * docgen is run on a `.dart` file or a directory containing `.dart` files. |
| 10 * | 10 * |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 import '../../../sdk/lib/_internal/compiler/implementation/mirrors/dart2js_mirro
r.dart' | 30 import '../../../sdk/lib/_internal/compiler/implementation/mirrors/dart2js_mirro
r.dart' |
| 31 as dart2js; | 31 as dart2js; |
| 32 import '../../../sdk/lib/_internal/compiler/implementation/mirrors/mirrors.dart'
; | 32 import '../../../sdk/lib/_internal/compiler/implementation/mirrors/mirrors.dart'
; |
| 33 import '../../../sdk/lib/_internal/compiler/implementation/source_file_provider.
dart'; | 33 import '../../../sdk/lib/_internal/compiler/implementation/source_file_provider.
dart'; |
| 34 import '../../../sdk/lib/_internal/libraries.dart'; | 34 import '../../../sdk/lib/_internal/libraries.dart'; |
| 35 | 35 |
| 36 var logger = new Logger('Docgen'); | 36 var logger = new Logger('Docgen'); |
| 37 | 37 |
| 38 const String USAGE = 'Usage: dart docgen.dart [OPTIONS] [fooDir/barFile]'; | 38 const String USAGE = 'Usage: dart docgen.dart [OPTIONS] [fooDir/barFile]'; |
| 39 | 39 |
| 40 |
| 41 List<String> validAnnotations = const ['metadata.Experimental', |
| 42 'metadata.DomName', 'metadata.Deprecated', 'metadata.Unstable', |
| 43 'meta.deprecated', 'metadata.SupportedBrowser']; |
| 44 |
| 40 /// Current library being documented to be used for comment links. | 45 /// Current library being documented to be used for comment links. |
| 41 LibraryMirror _currentLibrary; | 46 LibraryMirror _currentLibrary; |
| 42 | 47 |
| 43 /// Current class being documented to be used for comment links. | 48 /// Current class being documented to be used for comment links. |
| 44 ClassMirror _currentClass; | 49 ClassMirror _currentClass; |
| 45 | 50 |
| 46 /// Current member being documented to be used for comment links. | 51 /// Current member being documented to be used for comment links. |
| 47 MemberMirror _currentMember; | 52 MemberMirror _currentMember; |
| 48 | 53 |
| 49 /// Support for [:foo:]-style code comments to the markdown parser. | 54 /// Support for [:foo:]-style code comments to the markdown parser. |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 List<String> _annotations(DeclarationMirror mirror) { | 316 List<String> _annotations(DeclarationMirror mirror) { |
| 312 var annotationMirrors = mirror.metadata.where((e) => | 317 var annotationMirrors = mirror.metadata.where((e) => |
| 313 e is dart2js.Dart2JsConstructedConstantMirror); | 318 e is dart2js.Dart2JsConstructedConstantMirror); |
| 314 var annotations = []; | 319 var annotations = []; |
| 315 annotationMirrors.forEach((annotation) { | 320 annotationMirrors.forEach((annotation) { |
| 316 var parameterList = annotation.type.variables.values | 321 var parameterList = annotation.type.variables.values |
| 317 .where((e) => e.isFinal) | 322 .where((e) => e.isFinal) |
| 318 .map((e) => annotation.getField(e.simpleName).reflectee) | 323 .map((e) => annotation.getField(e.simpleName).reflectee) |
| 319 .where((e) => e != null) | 324 .where((e) => e != null) |
| 320 .toList(); | 325 .toList(); |
| 321 annotations.add(new Annotation(annotation.type.qualifiedName, | 326 if (validAnnotations.contains(annotation.type.qualifiedName)) { |
| 322 parameterList)); | 327 annotations.add(new Annotation(annotation.type.qualifiedName, |
| 328 parameterList)); |
| 329 } |
| 323 }); | 330 }); |
| 324 return annotations; | 331 return annotations; |
| 325 } | 332 } |
| 326 | 333 |
| 327 /** | 334 /** |
| 328 * Returns any documentation comments associated with a mirror with | 335 * Returns any documentation comments associated with a mirror with |
| 329 * simple markdown converted to html. | 336 * simple markdown converted to html. |
| 330 */ | 337 */ |
| 331 String _commentToHtml(DeclarationMirror mirror) { | 338 String _commentToHtml(DeclarationMirror mirror) { |
| 332 String commentText; | 339 String commentText; |
| (...skipping 747 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1080 String qualifiedName; | 1087 String qualifiedName; |
| 1081 List<String> parameters; | 1088 List<String> parameters; |
| 1082 | 1089 |
| 1083 Annotation(this.qualifiedName, this.parameters); | 1090 Annotation(this.qualifiedName, this.parameters); |
| 1084 | 1091 |
| 1085 Map toMap() => { | 1092 Map toMap() => { |
| 1086 'name': qualifiedName, | 1093 'name': qualifiedName, |
| 1087 'parameters': parameters | 1094 'parameters': parameters |
| 1088 }; | 1095 }; |
| 1089 } | 1096 } |
| OLD | NEW |