Chromium Code Reviews| Index: pkg/docgen/lib/docgen.dart |
| diff --git a/pkg/docgen/lib/docgen.dart b/pkg/docgen/lib/docgen.dart |
| index 5d0b391ebb710d0dd49095aca7374987ce53e310..0bccb44833cd48e56698043c6ca034b12211dac5 100644 |
| --- a/pkg/docgen/lib/docgen.dart |
| +++ b/pkg/docgen/lib/docgen.dart |
| @@ -368,7 +368,7 @@ Map<String, Class> _getClasses(Map<String, ClassMirror> mirrorMap, |
| var typedefs = {}; |
| var errors = {}; |
| - mirrorMap.forEach((String mirrorName, ClassMirror mirror) { |
| + mirrorMap.forEach((String mirrorName, ClassMirror mirror) { |
| if (includePrivate || !mirror.isPrivate) { |
| var superclass = (mirror.superclass != null) ? |
| mirror.superclass.qualifiedName : ''; |
| @@ -377,7 +377,7 @@ Map<String, Class> _getClasses(Map<String, ClassMirror> mirrorMap, |
| var clazz = new Class(mirrorName, superclass, _getComment(mirror), |
| interfaces.toList(), _getVariables(mirror.variables, includePrivate), |
| _getMethods(mirror.methods, includePrivate), |
| - _getAnnotations(mirror), mirror.qualifiedName); |
| + _getAnnotations(mirror), _getGenerics(mirror), mirror.qualifiedName); |
| _currentClass = mirror; |
| if (isError(mirror.qualifiedName)) { |
| @@ -417,6 +417,17 @@ Map<String, Parameter> _getParameters(List<ParameterMirror> mirrorList) { |
| } |
| /** |
| + * Returns a map of [Generic] objects constructed from the class mirror. |
| + */ |
| +Map<String, Generic> _getGenerics(ClassMirror mirror) { |
| + var data = {}; |
|
Alan Knight
2013/07/18 22:20:46
Today I learned... you could write this as
new Map
janicejl
2013/07/19 01:12:22
Done. That's really neat. Thanks for letting me kn
|
| + mirror.typeVariables.forEach((e) { |
| + data[e.toString()] = new Generic(e.toString(), e.upperBound.qualifiedName); |
| + }); |
| + return data; |
| +} |
| + |
| +/** |
| * Writes text to a file in the 'docs' directory. |
| */ |
| void _writeToFile(String text, String filename) { |
| @@ -515,6 +526,9 @@ class Class extends Indexable { |
| /// Methods in the class. |
| Map<String, Map<String, Method>> methods; |
| + /// Generic infomation about the class. |
| + Map<String, Generic> generics; |
| + |
| String name; |
| String superclass; |
| @@ -522,7 +536,7 @@ class Class extends Indexable { |
| List<String> annotations; |
| Class(this.name, this.superclass, this.comment, this.interfaces, |
| - this.variables, this.methods, this.annotations, |
| + this.variables, this.methods, this.annotations, this.generics, |
| String qualifiedName) : super(qualifiedName) {} |
| /// Generates a map describing the [Class] object. |
| @@ -535,6 +549,7 @@ class Class extends Indexable { |
| classMap['variables'] = recurseMap(variables); |
| classMap['methods'] = recurseMap(methods); |
| classMap['annotations'] = new List.from(annotations); |
| + classMap['generics'] = recurseMap(generics); |
| return classMap; |
| } |
| } |
| @@ -637,3 +652,20 @@ class Parameter { |
| return parameterMap; |
| } |
| } |
| + |
| +/** |
| + * A class containing properties of a Generic. |
| + */ |
| +class Generic { |
| + String name; |
| + String type; |
| + |
| + Generic(this.name, this.type); |
| + |
| + Map toMap() { |
| + var genericMap = {}; |
| + genericMap['name'] = name; |
|
Alan Knight
2013/07/18 22:20:46
You could write this as
=> {"name" : name, "type"
janicejl
2013/07/19 01:12:22
Done.
|
| + genericMap['type'] = type; |
| + return genericMap; |
| + } |
| +} |