| Index: pkg/docgen/lib/docgen.dart
|
| diff --git a/pkg/docgen/lib/docgen.dart b/pkg/docgen/lib/docgen.dart
|
| index 6ad260988ed81ff2477cc6d544e4242bf6a8e149..d775f1e024e1aefeba31a80b7ae3f7ee415f0cc6 100644
|
| --- a/pkg/docgen/lib/docgen.dart
|
| +++ b/pkg/docgen/lib/docgen.dart
|
| @@ -53,6 +53,14 @@ markdown.Resolver linkResolver;
|
| /// Index of all the qualified names documented.
|
| Set<String> qualifiedNameIndex = new Set<String>();
|
|
|
| +/// Index of all the classes created. This is to ensure that no class is
|
| +/// created more than once.
|
| +Map<String, Class> classMap = new Map<String, Class>();
|
| +
|
| +/// Index of all the libraries that needs to be outputted after all objects are
|
| +/// created and updated.
|
| +Set<Library> libraries = new Set<Library>();
|
| +
|
| /**
|
| * Docgen constructor initializes the link resolver for markdown parsing.
|
| * Also initializes the command line arguments.
|
| @@ -195,16 +203,17 @@ Future<MirrorSystem> _analyzeLibraries(List<String> libraries,
|
| /**
|
| * Creates documentation for filtered libraries.
|
| */
|
| -void _documentLibraries(List<LibraryMirror> libraries,
|
| +void _documentLibraries(List<LibraryMirror> libs,
|
| {bool includeSdk:false, bool includePrivate:false, bool
|
| outputToYaml:true}) {
|
| - libraries.forEach((lib) {
|
| + libs.forEach((lib) {
|
| // Files belonging to the SDK have a uri that begins with 'dart:'.
|
| if (includeSdk || !lib.uri.toString().startsWith('dart:')) {
|
| var library = generateLibrary(lib, includePrivate: includePrivate);
|
| - _writeLibraryToFile(library, outputToYaml);
|
| + libraries.add(library);
|
| }
|
| });
|
| + libraries.forEach((lib) => _writeLibraryToFile(lib, outputToYaml));
|
| // Outputs a text file with a list of files available after creating all
|
| // the libraries. This will help the viewer know what files are available
|
| // to read in.
|
| @@ -232,7 +241,6 @@ void _writeLibraryToFile(Library result, bool outputToYaml) {
|
| } else {
|
| _writeToFile(stringify(result.toMap()), '${result.name}.json');
|
| }
|
| -
|
| }
|
|
|
| /**
|
| @@ -360,15 +368,71 @@ Map<String, Class> _getClasses(Map<String, ClassMirror> mirrorMap,
|
|
|
| mirrorMap.forEach((String mirrorName, ClassMirror mirror) {
|
| if (includePrivate || !mirror.isPrivate) {
|
| + _currentClass = mirror;
|
| var superclass = (mirror.superclass != null) ?
|
| mirror.superclass.qualifiedName : '';
|
| var interfaces =
|
| mirror.superinterfaces.map((interface) => interface.qualifiedName);
|
| - var clazz = new Class(mirrorName, superclass, _getComment(mirror),
|
| - interfaces.toList(), _getVariables(mirror.variables, includePrivate),
|
| - _getMethods(mirror.methods, includePrivate),
|
| - _getAnnotations(mirror), _getGenerics(mirror), mirror.qualifiedName);
|
| - _currentClass = mirror;
|
| + var clazz = classMap[mirror.qualifiedName];
|
| + if (clazz == null) {
|
| + clazz = new Class(mirrorName, superclass, _getComment(mirror),
|
| + interfaces.toList(),
|
| + _getVariables(mirror.variables, includePrivate),
|
| + _getMethods(mirror.methods, includePrivate),
|
| + _getAnnotations(mirror),
|
| + _getGenerics(mirror), mirror.qualifiedName);
|
| + classMap[mirror.qualifiedName] = clazz;
|
| + }
|
| +
|
| + // Adding inherited superclass variables and methods.
|
| + if (superclass != '') {
|
| + var superclazz = classMap[superclass];
|
| + if (superclazz == null) {
|
| + var supersuperclass = (mirror.superclass.superclass != null) ?
|
| + mirror.superclass.superclass.qualifiedName : '';
|
| + var superclassInterfaces = mirror.superclass.superinterfaces
|
| + .map((interface) => interface.qualifiedName);
|
| + superclazz = new Class(mirror.superclass.simpleName, supersuperclass,
|
| + _getComment(mirror.superclass), superclassInterfaces.toList(),
|
| + _getVariables(mirror.superclass.variables, includePrivate),
|
| + _getMethods(mirror.superclass.methods, includePrivate),
|
| + _getAnnotations(mirror.superclass),
|
| + _getGenerics(mirror.superclass), mirror.superclass.qualifiedName);
|
| + classMap[mirror.superclass.qualifiedName] = superclazz;
|
| + }
|
| + superclazz.subclasses.add(clazz.qualifiedName);
|
| + superclazz.methods.keys.forEach((key) {
|
| + if (key != 'constructors') {
|
| + clazz.inheritedMethods[key].addAll(superclazz.methods[key]);
|
| + }
|
| + });
|
| + }
|
| +
|
| + // Adding inherited interface variables and methods.
|
| + mirror.superinterfaces.forEach((interface) {
|
| + var interfaceClass = classMap[interface.qualifiedName];
|
| + if (interfaceClass == null) {
|
| + var interfaceSuperClass = (interface.superclass != null) ?
|
| + interface.superclass.qualifiedName : '';
|
| + var interfaceInterfaces = interface.superinterfaces
|
| + .map((i) => i.qualifiedName);
|
| + interfaceClass = new Class(interface.simpleName,
|
| + interfaceSuperClass, _getComment(interface),
|
| + interfaceInterfaces.toList(),
|
| + _getVariables(interface.variables, includePrivate),
|
| + _getMethods(interface.methods, includePrivate),
|
| + _getAnnotations(interface), _getGenerics(interface),
|
| + interface.qualifiedName);
|
| + classMap[interface.qualifiedName] = interfaceClass;
|
| + }
|
| + interfaceClass.subclasses.add(clazz.qualifiedName);
|
| + clazz.inheritedVariables.addAll(interfaceClass.variables);
|
| + interfaceClass.methods.keys.forEach((key) {
|
| + if (key != 'constructors') {
|
| + clazz.inheritedMethods[key].addAll(interfaceClass.methods[key]);
|
| + }
|
| + });
|
| + });
|
|
|
| if (isError(mirror.qualifiedName)) {
|
| errors[mirrorName] = clazz;
|
| @@ -527,13 +591,27 @@ class Class extends Indexable {
|
|
|
| /// List of the names of interfaces that this class implements.
|
| List<String> interfaces;
|
| +
|
| + List<String> subclasses = [];
|
|
|
| /// Top-level variables in the class.
|
| Map<String, Variable> variables;
|
| +
|
| + /// Inherited variables in the class.
|
| + Map<String, Variable> inheritedVariables = {};
|
|
|
| /// Methods in the class.
|
| Map<String, Map<String, Method>> methods;
|
|
|
| + /// Inherited methods in the class.
|
| + Map<String, Map<String, Method>> inheritedMethods = {
|
| + 'setters': {},
|
| + 'getters': {},
|
| + 'constructors': {},
|
| + 'operators': {},
|
| + 'methods': {}
|
| + };
|
| +
|
| /// Generic infomation about the class.
|
| Map<String, Generic> generics;
|
|
|
| @@ -553,8 +631,11 @@ class Class extends Indexable {
|
| 'comment': comment,
|
| 'superclass': superclass,
|
| 'implements': new List.from(interfaces),
|
| + 'subclass': new List.from(subclasses),
|
| 'variables': recurseMap(variables),
|
| + 'inheritedvariables': recurseMap(inheritedVariables),
|
| 'methods': recurseMap(methods),
|
| + 'inheritedmethods': recurseMap(inheritedMethods),
|
| 'annotations': new List.from(annotations),
|
| 'generics': recurseMap(generics)
|
| };
|
|
|