Chromium Code Reviews| 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 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 376 mirror.superinterfaces.map((interface) => interface.qualifiedName); | 376 mirror.superinterfaces.map((interface) => interface.qualifiedName); |
| 377 var clazz = new Class(mirrorName, superclass, _getComment(mirror), | 377 var clazz = new Class(mirrorName, superclass, _getComment(mirror), |
| 378 interfaces.toList(), _getVariables(mirror.variables, includePrivate), | 378 interfaces.toList(), _getVariables(mirror.variables, includePrivate), |
| 379 _getMethods(mirror.methods, includePrivate), | 379 _getMethods(mirror.methods, includePrivate), |
| 380 _getAnnotations(mirror), _getGenerics(mirror), mirror.qualifiedName); | 380 _getAnnotations(mirror), _getGenerics(mirror), mirror.qualifiedName); |
| 381 _currentClass = mirror; | 381 _currentClass = mirror; |
| 382 | 382 |
| 383 if (isError(mirror.qualifiedName)) { | 383 if (isError(mirror.qualifiedName)) { |
| 384 errors[mirrorName] = clazz; | 384 errors[mirrorName] = clazz; |
| 385 } else if (mirror.isTypedef) { | 385 } else if (mirror.isTypedef) { |
| 386 typedefs[mirrorName] = clazz; | 386 typedefs[mirrorName] = new Typedef(mirrorName, |
| 387 mirror.value.returnType.qualifiedName, _getComment(mirror), | |
| 388 _getGenerics(mirror), _getParameters(mirror.value.parameters), | |
| 389 _getAnnotations(mirror), mirror.qualifiedName); | |
| 387 } else if (mirror.isAbstract) { | 390 } else if (mirror.isAbstract) { |
| 388 abstractClasses[mirrorName] = clazz; | 391 abstractClasses[mirrorName] = clazz; |
| 389 } else if (mirror.isClass) { | 392 } else if (mirror.isClass) { |
| 390 classes[mirrorName] = clazz; | 393 classes[mirrorName] = clazz; |
| 391 } else { | 394 } else { |
| 392 throw new ArgumentError('$mirrorName - no class type match. '); | 395 throw new ArgumentError('$mirrorName - no class type match. '); |
| 393 } | 396 } |
| 394 } | 397 } |
| 395 }); | 398 }); |
| 396 return { | 399 return { |
| 397 'abstract': abstractClasses, | 400 'abstract': abstractClasses, |
| 398 'class': classes, | 401 'class': classes, |
| 399 'typedef': typedefs, | 402 'typedef': typedefs, |
| 400 'error': errors | 403 'error': errors |
| 401 }; | 404 }; |
| 402 } | 405 } |
| 403 | 406 |
| 404 /** | 407 /** |
| 405 * Returns a map of [Parameter] objects constructed from inputted mirrors. | 408 * Returns a map of [Parameter] objects constructed from inputted mirrors. |
|
Alan Knight
2013/07/19 20:28:15
Inputted isn't a word, and better to just write wr
janicejl
2013/07/19 21:26:57
Done.
| |
| 406 */ | 409 */ |
| 407 Map<String, Parameter> _getParameters(List<ParameterMirror> mirrorList) { | 410 Map<String, Parameter> _getParameters(List<ParameterMirror> mirrorList) { |
| 408 var data = {}; | 411 var data = {}; |
| 409 mirrorList.forEach((ParameterMirror mirror) { | 412 mirrorList.forEach((ParameterMirror mirror) { |
| 410 _currentMember = mirror; | 413 _currentMember = mirror; |
| 411 data[mirror.simpleName] = new Parameter(mirror.simpleName, | 414 data[mirror.simpleName] = new Parameter(mirror.simpleName, |
| 412 mirror.isOptional, mirror.isNamed, mirror.hasDefaultValue, | 415 mirror.isOptional, mirror.isNamed, mirror.hasDefaultValue, |
| 413 mirror.type.qualifiedName, mirror.defaultValue, | 416 mirror.type.qualifiedName, mirror.defaultValue, |
| 414 _getAnnotations(mirror)); | 417 _getAnnotations(mirror)); |
| 415 }); | 418 }); |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 545 classMap['superclass'] = superclass; | 548 classMap['superclass'] = superclass; |
| 546 classMap['implements'] = new List.from(interfaces); | 549 classMap['implements'] = new List.from(interfaces); |
| 547 classMap['variables'] = recurseMap(variables); | 550 classMap['variables'] = recurseMap(variables); |
| 548 classMap['methods'] = recurseMap(methods); | 551 classMap['methods'] = recurseMap(methods); |
| 549 classMap['annotations'] = new List.from(annotations); | 552 classMap['annotations'] = new List.from(annotations); |
| 550 classMap['generics'] = recurseMap(generics); | 553 classMap['generics'] = recurseMap(generics); |
| 551 return classMap; | 554 return classMap; |
| 552 } | 555 } |
| 553 } | 556 } |
| 554 | 557 |
| 558 class Typedef extends Indexable { | |
| 559 String name; | |
|
Alan Knight
2013/07/19 20:28:15
Do all Indexables have a name? Could this be pushe
janicejl
2013/07/19 21:26:57
Done. I have moved name and comment up to indexabl
| |
| 560 String returnType; | |
| 561 | |
| 562 /// Documentation comment with converted markdown. | |
| 563 String comment; | |
| 564 | |
| 565 Map<String, Parameter> parameters; | |
| 566 | |
| 567 /// Generic information about the typedef. | |
| 568 Map<String, Generic> generics; | |
| 569 | |
| 570 /// List of the meta annotations on the typedef. | |
| 571 List<String> annotations; | |
| 572 | |
| 573 Typedef(this.name, this.returnType, this.comment, this.generics, | |
| 574 this.parameters, this.annotations, | |
| 575 String qualifiedName) : super(qualifiedName) {} | |
| 576 | |
| 577 Map toMap() { | |
| 578 var typedefMap = {}; | |
| 579 typedefMap['name'] = name; | |
|
Alan Knight
2013/07/19 20:28:15
Either write this as a literal map, or use cascade
janicejl
2013/07/19 21:26:57
Done. Also modified all the other toMap functions
| |
| 580 typedefMap['comment'] = comment; | |
| 581 typedefMap['return'] = returnType; | |
| 582 typedefMap['parameters'] = recurseMap(parameters); | |
| 583 typedefMap['annotations'] = new List.from(annotations); | |
| 584 typedefMap['generics'] = recurseMap(generics); | |
| 585 return typedefMap; | |
| 586 } | |
| 587 } | |
| 588 | |
| 555 /** | 589 /** |
| 556 * A class containing properties of a Dart variable. | 590 * A class containing properties of a Dart variable. |
| 557 */ | 591 */ |
| 558 class Variable extends Indexable { | 592 class Variable extends Indexable { |
| 559 | 593 |
| 560 /// Documentation comment with converted markdown. | 594 /// Documentation comment with converted markdown. |
| 561 String comment; | 595 String comment; |
| 562 | 596 |
| 563 String name; | 597 String name; |
| 564 bool isFinal; | 598 bool isFinal; |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 660 | 694 |
| 661 Generic(this.name, this.type); | 695 Generic(this.name, this.type); |
| 662 | 696 |
| 663 Map toMap() { | 697 Map toMap() { |
| 664 return { | 698 return { |
| 665 'name': name, | 699 'name': name, |
| 666 'type': type | 700 'type': type |
| 667 }; | 701 }; |
| 668 } | 702 } |
| 669 } | 703 } |
| OLD | NEW |