Chromium Code Reviews| Index: pkg/docgen/lib/docgen.dart |
| diff --git a/pkg/docgen/lib/docgen.dart b/pkg/docgen/lib/docgen.dart |
| index ecdafd6eefa427d6bd83ed397c5a6f98b58a85fe..8520607b6522bbe8302bef5e842902f678ab104d 100644 |
| --- a/pkg/docgen/lib/docgen.dart |
| +++ b/pkg/docgen/lib/docgen.dart |
| @@ -266,9 +266,9 @@ String _getComment(DeclarationMirror mirror) { |
| } |
| } |
| }); |
| + |
| commentText = commentText == null ? '' : |
| - markdown.markdownToHtml(commentText.trim(), linkResolver: linkResolver) |
| - .replaceAll('\n', ' '); |
| + markdown.markdownToHtml(commentText.trim(), linkResolver: linkResolver); |
| return commentText; |
| } |
| @@ -300,9 +300,9 @@ Map<String, Variable> _getVariables(Map<String, VariableMirror> mirrorMap, |
| mirrorMap.forEach((String mirrorName, VariableMirror mirror) { |
| if (includePrivate || !mirror.isPrivate) { |
| _currentMember = mirror; |
| - data[mirrorName] = new Variable(mirrorName, mirror.qualifiedName, |
| - mirror.isFinal, mirror.isStatic, mirror.type.qualifiedName, |
| - _getComment(mirror), _getAnnotations(mirror)); |
| + data[mirrorName] = new Variable(mirrorName, mirror.isFinal, |
| + mirror.isStatic, mirror.type.qualifiedName, _getComment(mirror), |
| + _getAnnotations(mirror)); |
| } |
| }); |
| return data; |
| @@ -311,19 +311,49 @@ Map<String, Variable> _getVariables(Map<String, VariableMirror> mirrorMap, |
| /** |
| * Returns a map of [Method] objects constructed from inputted mirrors. |
| */ |
| -Map<String, Method> _getMethods(Map<String, MethodMirror> mirrorMap, |
| - bool includePrivate) { |
| - var data = {}; |
| +Map<String, Map<String, Method>> _getMethods |
| + (Map<String, MethodMirror> mirrorMap, bool includePrivate) { |
| + |
| + var setters = {}; |
| + var getters = {}; |
| + var constructors = {}; |
| + var operators = {}; |
| + var methods = {}; |
| + |
| mirrorMap.forEach((String mirrorName, MethodMirror mirror) { |
| if (includePrivate || !mirror.isPrivate) { |
| _currentMember = mirror; |
| - data[mirrorName] = new Method(mirrorName, mirror.qualifiedName, |
| - mirror.isSetter, mirror.isGetter, mirror.isConstructor, |
| - mirror.isOperator, mirror.isStatic, mirror.returnType.qualifiedName, |
| - _getComment(mirror), _getParameters(mirror.parameters), |
| - _getAnnotations(mirror)); |
| + if (mirror.isSetter) { |
| + setters[mirrorName] = new Method(mirrorName, mirror.isStatic, |
| + mirror.returnType.qualifiedName, _getComment(mirror), |
| + _getParameters(mirror.parameters), _getAnnotations(mirror)); |
|
Bob Nystrom
2013/07/15 22:16:03
This constructor call is the same for every case,
janicejl
2013/07/15 22:38:43
Done.
|
| + } else if (mirror.isGetter) { |
| + getters[mirrorName] = new Method(mirrorName, mirror.isStatic, |
| + mirror.returnType.qualifiedName, _getComment(mirror), |
| + _getParameters(mirror.parameters), _getAnnotations(mirror)); |
| + } else if (mirror.isConstructor) { |
| + constructors[mirrorName] = new Method(mirrorName, mirror.isStatic, |
| + mirror.returnType.qualifiedName, _getComment(mirror), |
| + _getParameters(mirror.parameters), _getAnnotations(mirror)); |
| + } else if (mirror.isOperator) { |
| + operators[mirrorName] = new Method(mirrorName, mirror.isStatic, |
| + mirror.returnType.qualifiedName, _getComment(mirror), |
| + _getParameters(mirror.parameters), _getAnnotations(mirror)); |
| + } else if (mirror.isRegularMethod) { |
| + methods[mirrorName] = new Method(mirrorName, mirror.isStatic, |
| + mirror.returnType.qualifiedName, _getComment(mirror), |
| + _getParameters(mirror.parameters), _getAnnotations(mirror)); |
| + } else { |
| + throw new StateError('${mirror.qualifiedName} - no method type match'); |
| + } |
| } |
| }); |
| + var data = {'setters' : setters, |
|
Bob Nystrom
2013/07/15 22:16:03
The variable isn't doing much for you here. May as
janicejl
2013/07/15 22:38:43
Done.
|
| + 'getters' : getters, |
| + 'constructors' : constructors, |
| + 'operators' : operators, |
| + 'methods' : methods}; |
| + |
| return data; |
| } |
| @@ -340,9 +370,8 @@ Map<String, Class> _getClasses(Map<String, ClassMirror> mirrorMap, |
| mirror.superclass.qualifiedName : ''; |
| var interfaces = |
| mirror.superinterfaces.map((interface) => interface.qualifiedName); |
| - data[mirrorName] = new Class(mirrorName, mirror.qualifiedName, |
| - superclass, mirror.isAbstract, mirror.isTypedef, |
| - _getComment(mirror), interfaces.toList(), |
| + data[mirrorName] = new Class(mirrorName, superclass, mirror.isAbstract, |
| + mirror.isTypedef, _getComment(mirror), interfaces.toList(), |
| _getVariables(mirror.variables, includePrivate), |
| _getMethods(mirror.methods, includePrivate), |
| _getAnnotations(mirror)); |
| @@ -359,9 +388,9 @@ Map<String, Parameter> _getParameters(List<ParameterMirror> mirrorList) { |
| mirrorList.forEach((ParameterMirror mirror) { |
| _currentMember = mirror; |
| data[mirror.simpleName] = new Parameter(mirror.simpleName, |
| - mirror.qualifiedName, mirror.isOptional, mirror.isNamed, |
| - mirror.hasDefaultValue, mirror.type.qualifiedName, |
| - mirror.defaultValue, _getAnnotations(mirror)); |
| + mirror.isOptional, mirror.isNamed, mirror.hasDefaultValue, |
| + mirror.type.qualifiedName, mirror.defaultValue, |
| + _getAnnotations(mirror)); |
| }); |
| return data; |
| } |
| @@ -388,7 +417,11 @@ void _writeToFile(String text, String filename) { |
| Map recurseMap(Map inputMap) { |
| var outputMap = {}; |
| inputMap.forEach((key, value) { |
| - outputMap[key] = value.toMap(); |
| + if (value is Map) { |
| + outputMap[key] = recurseMap(value); |
| + } else { |
| + outputMap[key] = value.toMap(); |
| + } |
| }); |
| return outputMap; |
| } |
| @@ -405,7 +438,7 @@ class Library { |
| Map<String, Variable> variables; |
| /// Top-level functions in the library. |
| - Map<String, Method> functions; |
| + Map<String, Map<String, Method>> functions; |
| /// Classes defined within the library |
| Map<String, Class> classes; |
| @@ -443,10 +476,9 @@ class Class { |
| Map<String, Variable> variables; |
| /// Methods in the class. |
| - Map<String, Method> methods; |
| + Map<String, Map<String, Method>> methods; |
| String name; |
| - String qualifiedName; |
| String superclass; |
| bool isAbstract; |
| bool isTypedef; |
| @@ -454,15 +486,14 @@ class Class { |
| /// List of the meta annotations on the class. |
| List<String> annotations; |
| - Class(this.name, this.qualifiedName, this.superclass, this.isAbstract, |
| - this.isTypedef, this.comment, this.interfaces, this.variables, |
| - this.methods, this.annotations); |
| + Class(this.name, this.superclass, this.isAbstract, this.isTypedef, |
| + this.comment, this.interfaces, this.variables, this.methods, |
| + this.annotations); |
| /// Generates a map describing the [Class] object. |
| Map toMap() { |
| var classMap = {}; |
| classMap['name'] = name; |
| - classMap['qualifiedname'] = qualifiedName; |
| classMap['comment'] = comment; |
| classMap['superclass'] = superclass; |
| classMap['abstract'] = isAbstract.toString(); |
| @@ -484,7 +515,6 @@ class Variable { |
| String comment; |
| String name; |
| - String qualifiedName; |
| bool isFinal; |
| bool isStatic; |
| String type; |
| @@ -492,14 +522,13 @@ class Variable { |
| /// List of the meta annotations on the variable. |
| List<String> annotations; |
| - Variable(this.name, this.qualifiedName, this.isFinal, this.isStatic, |
| - this.type, this.comment, this.annotations); |
| + Variable(this.name, this.isFinal, this.isStatic, this.type, this.comment, |
| + this.annotations); |
| /// Generates a map describing the [Variable] object. |
| Map toMap() { |
| var variableMap = {}; |
| variableMap['name'] = name; |
| - variableMap['qualifiedname'] = qualifiedName; |
| variableMap['comment'] = comment; |
| variableMap['final'] = isFinal.toString(); |
| variableMap['static'] = isStatic.toString(); |
| @@ -521,29 +550,20 @@ class Method { |
| Map<String, Parameter> parameters; |
| String name; |
| - String qualifiedName; |
| - bool isSetter; |
| - bool isGetter; |
| - bool isConstructor; |
| - bool isOperator; |
| bool isStatic; |
| String returnType; |
| /// List of the meta annotations on the method. |
| List<String> annotations; |
| - Method(this.name, this.qualifiedName, this.isSetter, this.isGetter, |
| - this.isConstructor, this.isOperator, this.isStatic, this.returnType, |
| - this.comment, this.parameters, this.annotations); |
| + Method(this.name, this.isStatic, this.returnType, this.comment, |
| + this.parameters, this.annotations); |
| /// Generates a map describing the [Method] object. |
| Map toMap() { |
| var methodMap = {}; |
| methodMap['name'] = name; |
| - methodMap['qualifiedname'] = qualifiedName; |
| methodMap['comment'] = comment; |
| - methodMap['type'] = isSetter ? 'setter' : isGetter ? 'getter' : |
| - isOperator ? 'operator' : isConstructor ? 'constructor' : 'method'; |
| methodMap['static'] = isStatic.toString(); |
| methodMap['return'] = returnType; |
| methodMap['parameters'] = recurseMap(parameters); |
| @@ -558,7 +578,6 @@ class Method { |
| class Parameter { |
| String name; |
| - String qualifiedName; |
| bool isOptional; |
| bool isNamed; |
| bool hasDefaultValue; |
| @@ -568,14 +587,13 @@ class Parameter { |
| /// List of the meta annotations on the parameter. |
| List<String> annotations; |
| - Parameter(this.name, this.qualifiedName, this.isOptional, this.isNamed, |
| - this.hasDefaultValue, this.type, this.defaultValue, this.annotations); |
| + Parameter(this.name, this.isOptional, this.isNamed, this.hasDefaultValue, |
| + this.type, this.defaultValue, this.annotations); |
| /// Generates a map describing the [Parameter] object. |
| Map toMap() { |
| var parameterMap = {}; |
| parameterMap['name'] = name; |
| - parameterMap['qualifiedname'] = qualifiedName; |
| parameterMap['optional'] = isOptional.toString(); |
| parameterMap['named'] = isNamed.toString(); |
| parameterMap['default'] = hasDefaultValue.toString(); |