From 45c5ed2851dfddf4a16c9d5a8fbd2c1a246f196c Mon Sep 17 00:00:00 2001 From: Janice Collins Date: Fri, 8 May 2020 11:57:41 -0700 Subject: [PATCH 1/6] intermediate --- lib/src/generator/generator_frontend.dart | 47 ++-- lib/src/markdown_processor.dart | 2 +- lib/src/model/accessor.dart | 4 +- lib/src/model/class.dart | 220 +++++----------- lib/src/model/container.dart | 236 ++++++++++++------ lib/src/model/documentable.dart | 3 +- lib/src/model/enum.dart | 13 - lib/src/model/extension.dart | 20 +- lib/src/model/extension_target.dart | 5 +- lib/src/model/inheritable.dart | 4 +- lib/src/model/top_level_variable.dart | 2 +- lib/src/model/typedef.dart | 2 +- lib/templates/html/_sidebar_for_class.html | 54 ++-- .../html/_sidebar_for_container.html | 98 ++++---- lib/templates/html/_sidebar_for_enum.html | 54 ++-- .../html/_sidebar_for_extension.html | 44 ++-- lib/templates/html/_source_link.html | 2 +- lib/templates/html/class.html | 58 ++--- lib/templates/html/enum.html | 54 ++-- lib/templates/html/extension.html | 44 ++-- lib/templates/html/mixin.html | 42 ++-- lib/templates/html/top_level_property.html | 2 +- test/model_special_cases_test.dart | 44 ++-- test/model_test.dart | 232 ++++++++--------- 24 files changed, 619 insertions(+), 667 deletions(-) diff --git a/lib/src/generator/generator_frontend.dart b/lib/src/generator/generator_frontend.dart index 6039579fb6..48e8b27653 100644 --- a/lib/src/generator/generator_frontend.dart +++ b/lib/src/generator/generator_frontend.dart @@ -68,7 +68,7 @@ class GeneratorFrontEnd implements Generator { writer, packageGraph, lib, clazz, constructor); } - for (var constant in filterNonDocumented(clazz.constants)) { + for (var constant in filterNonDocumented(clazz.constantFields)) { if (!constant.isCanonical) continue; indexAccumulator.add(constant); @@ -76,7 +76,7 @@ class GeneratorFrontEnd implements Generator { writer, packageGraph, lib, clazz, constant); } - for (var property in filterNonDocumented(clazz.staticProperties)) { + for (var property in filterNonDocumented(clazz.staticFields)) { if (!property.isCanonical) continue; indexAccumulator.add(property); @@ -84,7 +84,7 @@ class GeneratorFrontEnd implements Generator { writer, packageGraph, lib, clazz, property); } - for (var property in filterNonDocumented(clazz.allInstanceFields)) { + for (var property in filterNonDocumented(clazz.instanceFields)) { if (!property.isCanonical) continue; indexAccumulator.add(property); @@ -92,7 +92,7 @@ class GeneratorFrontEnd implements Generator { writer, packageGraph, lib, clazz, property); } - for (var method in filterNonDocumented(clazz.allInstanceMethods)) { + for (var method in filterNonDocumented(clazz.instanceMethods)) { if (!method.isCanonical) continue; indexAccumulator.add(method); @@ -100,7 +100,7 @@ class GeneratorFrontEnd implements Generator { writer, packageGraph, lib, clazz, method); } - for (var operator in filterNonDocumented(clazz.allOperators)) { + for (var operator in filterNonDocumented(clazz.instanceOperators)) { if (!operator.isCanonical) continue; indexAccumulator.add(operator); @@ -122,40 +122,27 @@ class GeneratorFrontEnd implements Generator { _generatorBackend.generateExtension( writer, packageGraph, lib, extension); - for (var constant in filterNonDocumented(extension.constants)) { + for (var constant in filterNonDocumented(extension.constantFields)) { indexAccumulator.add(constant); _generatorBackend.generateConstant( writer, packageGraph, lib, extension, constant); } - for (var property - in filterNonDocumented(extension.staticProperties)) { - indexAccumulator.add(property); - _generatorBackend.generateProperty( - writer, packageGraph, lib, extension, property); - } - for (var method - in filterNonDocumented(extension.allPublicInstanceMethods)) { - indexAccumulator.add(method); - _generatorBackend.generateMethod( - writer, packageGraph, lib, extension, method); - } - - for (var method in filterNonDocumented(extension.staticMethods)) { + in filterNonDocumented(extension.publicInstanceMethods)) { indexAccumulator.add(method); _generatorBackend.generateMethod( writer, packageGraph, lib, extension, method); } - for (var operator in filterNonDocumented(extension.allOperators)) { + for (var operator in filterNonDocumented(extension.instanceOperators)) { indexAccumulator.add(operator); _generatorBackend.generateMethod( writer, packageGraph, lib, extension, operator); } for (var property - in filterNonDocumented(extension.allInstanceFields)) { + in filterNonDocumented(extension.instanceFields)) { indexAccumulator.add(property); _generatorBackend.generateProperty( writer, packageGraph, lib, extension, property); @@ -174,14 +161,14 @@ class GeneratorFrontEnd implements Generator { writer, packageGraph, lib, mixin, constructor); } - for (var constant in filterNonDocumented(mixin.constants)) { + for (var constant in filterNonDocumented(mixin.constantFields)) { if (!constant.isCanonical) continue; indexAccumulator.add(constant); _generatorBackend.generateConstant( writer, packageGraph, lib, mixin, constant); } - for (var property in filterNonDocumented(mixin.staticProperties)) { + for (var property in filterNonDocumented(mixin.staticFields)) { if (!property.isCanonical) continue; indexAccumulator.add(property); @@ -189,7 +176,7 @@ class GeneratorFrontEnd implements Generator { writer, packageGraph, lib, mixin, property); } - for (var property in filterNonDocumented(mixin.allInstanceFields)) { + for (var property in filterNonDocumented(mixin.instanceFields)) { if (!property.isCanonical) continue; indexAccumulator.add(property); @@ -197,7 +184,7 @@ class GeneratorFrontEnd implements Generator { writer, packageGraph, lib, mixin, property); } - for (var method in filterNonDocumented(mixin.allInstanceMethods)) { + for (var method in filterNonDocumented(mixin.instanceMethods)) { if (!method.isCanonical) continue; indexAccumulator.add(method); @@ -205,7 +192,7 @@ class GeneratorFrontEnd implements Generator { writer, packageGraph, lib, mixin, method); } - for (var operator in filterNonDocumented(mixin.allOperators)) { + for (var operator in filterNonDocumented(mixin.instanceOperators)) { if (!operator.isCanonical) continue; indexAccumulator.add(operator); @@ -226,17 +213,17 @@ class GeneratorFrontEnd implements Generator { indexAccumulator.add(eNum); _generatorBackend.generateEnum(writer, packageGraph, lib, eNum); - for (var property in filterNonDocumented(eNum.allInstanceFields)) { + for (var property in filterNonDocumented(eNum.instanceFields)) { indexAccumulator.add(property); _generatorBackend.generateConstant( writer, packageGraph, lib, eNum, property); } - for (var operator in filterNonDocumented(eNum.allOperators)) { + for (var operator in filterNonDocumented(eNum.instanceOperators)) { indexAccumulator.add(operator); _generatorBackend.generateMethod( writer, packageGraph, lib, eNum, operator); } - for (var method in filterNonDocumented(eNum.allInstanceMethods)) { + for (var method in filterNonDocumented(eNum.instanceMethods)) { indexAccumulator.add(method); _generatorBackend.generateMethod( writer, packageGraph, lib, eNum, method); diff --git a/lib/src/markdown_processor.dart b/lib/src/markdown_processor.dart index 630bce6cb0..977782eda5 100644 --- a/lib/src/markdown_processor.dart +++ b/lib/src/markdown_processor.dart @@ -551,7 +551,7 @@ class _MarkdownCommentReference { for (final modelElement in packageGraph.findRefElementCache[maybeEnumName]) { if (modelElement is Enum) { - if (modelElement.constants.any((e) => e.name == maybeEnumMember)) { + if (modelElement.constantFields.any((e) => e.name == maybeEnumMember)) { results.add(modelElement); break; } diff --git a/lib/src/model/accessor.dart b/lib/src/model/accessor.dart index 321e345a59..a95d37dc7f 100644 --- a/lib/src/model/accessor.dart +++ b/lib/src/model/accessor.dart @@ -180,8 +180,8 @@ class ContainerAccessor extends Accessor with ContainerMember, Inheritable { Class parentClass = ModelElement.fromElement(t.element, packageGraph); var possibleFields = []; - possibleFields.addAll(parentClass.allInstanceFields); - possibleFields.addAll(parentClass.staticProperties); + possibleFields.addAll(parentClass.instanceFields); + possibleFields.addAll(parentClass.staticFields); var fieldName = accessor.name.replaceFirst('=', ''); var foundField = possibleFields.firstWhere( (f) => f.element.name == fieldName, diff --git a/lib/src/model/class.dart b/lib/src/model/class.dart index 81f5835b7a..35ff57ea77 100644 --- a/lib/src/model/class.dart +++ b/lib/src/model/class.dart @@ -10,16 +10,23 @@ import 'package:dartdoc/src/model/model.dart'; import 'package:dartdoc/src/model_utils.dart' as model_utils; import 'package:quiver/iterables.dart' as quiver; + +/// A [Container] defined with a `class` declaration in Dart. +/// +/// Members follow similar naming rules to [Container], with the following +/// additions: +/// +/// **instance**: As with [Container], but also includes inherited children. +/// **inherited**: Filtered getters giving only inherited children. class Class extends Container with TypeParameters, Categorization, ExtensionTarget implements EnclosedElement { List mixins; DefinedElementType supertype; List _interfaces; - List _constructors; List _inheritedOperators; List _inheritedMethods; - List _inheritedProperties; + List _inheritedFields; Class(ClassElement element, Library library, PackageGraph packageGraph) : super(element, library, packageGraph) { @@ -51,104 +58,25 @@ class Class extends Container return _defaultConstructor; } - Iterable get allInstanceMethods => - quiver.concat([instanceMethods, inheritedMethods]); - @override - Iterable get allPublicInstanceMethods => - model_utils.filterNonPublic(allInstanceMethods); + Iterable get instanceMethods => + quiver.concat([super.instanceMethods, inheritedMethods]); - bool get allPublicInstanceMethodsInherited => + bool get publicInstanceMethodsInherited => instanceMethods.every((f) => f.isInherited); @override - Iterable get allInstanceFields => - quiver.concat([instanceProperties, inheritedProperties]); - - bool get allPublicInstancePropertiesInherited => - allPublicInstanceProperties.every((f) => f.isInherited); - - @override - Iterable get allOperators => - quiver.concat([operators, inheritedOperators]); - - bool get allPublicOperatorsInherited => - allPublicOperators.every((f) => f.isInherited); - - Map _allElements; - - Map get allElements { - if (_allElements == null) { - _allElements = {}; - for (var me in allModelElements) { - assert(!_allElements.containsKey(me.element)); - _allElements[me.element] = me; - } - } - return _allElements; - } - - Map> _allModelElementsByNamePart; - - /// Helper for `_MarkdownCommentReference._getResultsForClass`. - Map> get allModelElementsByNamePart { - if (_allModelElementsByNamePart == null) { - _allModelElementsByNamePart = {}; - for (var me in allModelElements) { - _allModelElementsByNamePart.update( - me.namePart, (List v) => v..add(me), - ifAbsent: () => [me]); - } - } - return _allModelElementsByNamePart; - } - - /// This class might be canonical for elements it does not contain. - /// See [Inheritable.canonicalEnclosingContainer]. - bool contains(Element element) => allElements.containsKey(element); - - Map> _membersByName; + Iterable get instanceOperators => + quiver.concat([super.instanceOperators, inheritedOperators]); - /// Given a ModelElement that is a member of some other class, return - /// a member of this class that has the same name and return type. - /// - /// This enables object substitution for canonicalization, such as Interceptor - /// for Object. - ModelElement memberByExample(ModelElement example) { - if (_membersByName == null) { - _membersByName = {}; - for (var me in allModelElements) { - if (!_membersByName.containsKey(me.name)) { - _membersByName[me.name] = []; - } - _membersByName[me.name].add(me); - } - } - ModelElement member; - var possibleMembers = _membersByName[example.name] - .where((e) => e.runtimeType == example.runtimeType); - if (example.runtimeType == Accessor) { - possibleMembers = possibleMembers.where( - (e) => (example as Accessor).isGetter == (e as Accessor).isGetter); - } - member = possibleMembers.first; - assert(possibleMembers.length == 1); - return member; - } List _allModelElements; - + @override List get allModelElements { _allModelElements ??= List.from( quiver.concat([ - allInstanceMethods, - allInstanceFields, - allAccessors, - allOperators, - constants, + super.allModelElements, constructors, - staticMethods, - staticProperties, typeParameters, ]), growable: false); @@ -162,16 +90,9 @@ class Class extends Container allModelElements.where((e) => e.isCanonical).toList()); } - List get constructors { - if (_constructors != null) return _constructors; - - _constructors = element.constructors.map((e) { + Iterable get constructors => element.constructors.map((e) { return ModelElement.from(e, library, packageGraph) as Constructor; - }).toList(growable: true) - ..sort(byName); - - return _constructors; - } + }); Iterable get publicConstructors => model_utils.filterNonPublic(constructors); @@ -194,18 +115,15 @@ class Class extends Container return kind; } - bool get hasPublicConstructors => publicConstructors.isNotEmpty; + bool get hasPublicConstructors => publicConstructorsSorted.isNotEmpty; - bool get hasPublicImplementors => publicImplementors.isNotEmpty; + List _publicConstructorsSorted; + List get publicConstructorsSorted => _publicConstructorsSorted ??= publicConstructors.toList()..sort(byName); - bool get hasInstanceProperties => instanceProperties.isNotEmpty; + bool get hasPublicImplementors => publicImplementors.isNotEmpty; bool get hasPublicInterfaces => publicInterfaces.isNotEmpty; - @override - bool get hasPublicMethods => - publicInstanceMethods.isNotEmpty || publicInheritedMethods.isNotEmpty; - bool get hasPublicMixins => publicMixins.isNotEmpty; @override @@ -217,18 +135,6 @@ class Class extends Container hasPublicImplementors || hasPotentiallyApplicableExtensions; - @override - bool get hasPublicOperators => - publicOperators.isNotEmpty || publicInheritedOperators.isNotEmpty; - - @override - bool get hasPublicProperties => - publicInheritedProperties.isNotEmpty || - publicInstanceProperties.isNotEmpty; - - @override - bool get hasPublicStaticMethods => publicStaticMethods.isNotEmpty; - bool get hasPublicSuperChainReversed => publicSuperChainReversed.isNotEmpty; @override @@ -247,10 +153,10 @@ class Class extends Container model_utils.findCanonicalFor(packageGraph.implementors[href] ?? [])); } - List get inheritedMethods { + Iterable get inheritedMethods { if (_inheritedMethods == null) { _inheritedMethods = []; - var methodNames = methods.map((m) => m.element.name).toSet(); + var methodNames = declaredMethods.map((m) => m.element.name).toSet(); var inheritedMethodElements = _inheritedElements.where((e) { return (e is MethodElement && @@ -264,7 +170,6 @@ class Class extends Container enclosingContainer: this); _inheritedMethods.add(m); } - _inheritedMethods.sort(byName); } return _inheritedMethods; } @@ -274,10 +179,10 @@ class Class extends Container bool get hasPublicInheritedMethods => publicInheritedMethods.isNotEmpty; - List get inheritedOperators { + Iterable get inheritedOperators { if (_inheritedOperators == null) { _inheritedOperators = []; - var operatorNames = operators.map((o) => o.element.name).toSet(); + var operatorNames = declaredOperators.map((o) => o.element.name).toSet(); var inheritedOperatorElements = _inheritedElements.where((e) { return (e is MethodElement && @@ -289,24 +194,18 @@ class Class extends Container enclosingContainer: this); _inheritedOperators.add(o); } - _inheritedOperators.sort(byName); } return _inheritedOperators; } - Iterable get publicInheritedOperators => + Iterable get publicInstanceOperatorsInherited => model_utils.filterNonPublic(inheritedOperators); - List get inheritedProperties { - _inheritedProperties ??= allFields.where((f) => f.isInherited).toList() - ..sort(byName); - return _inheritedProperties; - } - - Iterable get publicInheritedProperties => - model_utils.filterNonPublic(inheritedProperties); + Iterable get fieldsInherited => + _inheritedFields ??= allFields.where((f) => f.isInherited); - Iterable get publicInstanceMethods => instanceMethods; + Iterable get publicFieldsInherited => + model_utils.filterNonPublic(fieldsInherited); List get interfaces => _interfaces; @@ -331,7 +230,6 @@ class Class extends Container } /// Returns true if [other] is a parent class for this class. - @override bool isInheritingFrom(covariant Class other) => superChain.map((et) => (et.element as Class)).contains(other); @@ -426,19 +324,17 @@ class Class extends Container return __inheritedElements; } - List _fields; - - @override + List _allFields; List get allFields { - if (_fields == null) { - _fields = []; - var inheritedAccessors = {} + if (_allFields == null) { + _allFields = []; + var inheritedAccessorElements = {} ..addAll(_inheritedElements.whereType()); // This structure keeps track of inherited accessors, allowing lookup // by field name (stripping the '=' from setters). var accessorMap = >{}; - for (var accessorElement in inheritedAccessors) { + for (var accessorElement in inheritedAccessorElements) { var name = accessorElement.name.replaceFirst('=', ''); accessorMap.putIfAbsent(name, () => []); accessorMap[name].add(accessorElement); @@ -448,6 +344,8 @@ class Class extends Container // to the [FieldElement]. Compose our [Field] class by hand by looking up // inherited accessors that may be related. for (var f in element.fields) { + if (name == 'Animal') + print('hmm'); var getterElement = f.getter; if (getterElement == null && accessorMap.containsKey(f.name)) { getterElement = accessorMap[f.name] @@ -458,7 +356,7 @@ class Class extends Container setterElement = accessorMap[f.name] .firstWhere((e) => e.isSetter, orElse: () => null); } - _addSingleField(getterElement, setterElement, inheritedAccessors, f); + _addSingleField(getterElement, setterElement, inheritedAccessorElements, f); accessorMap.remove(f.name); } @@ -470,14 +368,16 @@ class Class extends Container elements.firstWhere((e) => e.isGetter, orElse: () => null); var setterElement = elements.firstWhere((e) => e.isSetter, orElse: () => null); - _addSingleField(getterElement, setterElement, inheritedAccessors); + _addSingleField(getterElement, setterElement, inheritedAccessorElements); } - _fields.sort(byName); } - return _fields; + return _allFields; } + @override + Iterable get declaredFields => allFields.where((f) => !f.isInherited); + /// Add a single Field to _fields. /// /// If [f] is not specified, pick the FieldElement from the PropertyAccessorElement @@ -510,7 +410,7 @@ class Class extends Container // different places in the inheritance chain, there are two FieldElements // for this single Field we're trying to compose. Pick the one closest // to this class on the inheritance chain. - if ((setter.enclosingElement) + if (setter.enclosingElement is Class && (setter.enclosingElement as Class) .isInheritingFrom(getter.enclosingElement)) { f = setterElement.variable; } else { @@ -532,22 +432,19 @@ class Class extends Container field = ModelElement.from(f, library, packageGraph, getter: getter, setter: setter); } - _fields.add(field); + _allFields.add(field); } - List _methods; - + List _declaredMethods; @override - List get methods { - _methods ??= element.methods.map((e) { - return ModelElement.from(e, library, packageGraph) as Method; - }).toList(growable: false) - ..sort(byName); - return _methods; - } + Iterable get declaredMethods => _declaredMethods ??= + element.methods.map((e) { + return ModelElement.from(e, library, packageGraph) as Method; + }).toList(growable: false); - List _typeParameters; + + List _typeParameters; // a stronger hash? @override List get typeParameters { @@ -558,6 +455,17 @@ class Class extends Container return _typeParameters; } + Iterable _instanceFields; + @override + Iterable get instanceFields => _instanceFields ??= allFields + .where((f) => !f.isStatic); + + bool get publicInstanceFieldsInherited => + publicInstanceFields.every((f) => f.isInherited); + + @override + Iterable get constantFields => allFields.where((f) => f.isConst); + @override bool operator ==(o) => o is Class && diff --git a/lib/src/model/container.dart b/lib/src/model/container.dart index 8961380cce..8fbf6e5e57 100644 --- a/lib/src/model/container.dart +++ b/lib/src/model/container.dart @@ -5,121 +5,197 @@ import 'package:analyzer/dart/element/element.dart'; import 'package:dartdoc/src/model/model.dart'; import 'package:dartdoc/src/model_utils.dart' as model_utils; +import 'package:meta/meta.dart'; import 'package:quiver/iterables.dart' as quiver; -// Can be either a Class or Extension, used in the package graph and template data. -// Aggregates some of the common getters. +/// A [Container] represents a Dart construct that can contain methods, +/// operators, and fields, such as [Class], [Enum], or [Extension]. +/// +/// Member naming in [Container] follows these general rules: +/// +/// **instance** : Members named 'instance' contain the children of this +/// container that can be referenced from within the container without a prefix +/// and are not statics. +/// Usually overridden in subclasses with calls to super. +/// **constant** : Members named 'constant' contain children declared constant. +/// **variable** : Members names 'variable' contain children not declared constant. +/// **static** : Members named 'static' are related to static children of this +/// container. +/// **public** : Filtered versions of the getters showing only public items. +/// Mostly for the templating system. +/// **sorted** : Filtered versions of the getters creating a sorted list by +/// name. For the templating system. +/// **has** : boolean getters indicating whether the underlying getters are +/// empty. Mostly for the templating system. +/// **all** : Referring to all children. abstract class Container extends ModelElement { - List _constants; - List _operators; - List _staticMethods; - List _instanceMethods; - List _staticFields; - List _instanceFields; - Container(Element element, Library library, PackageGraph packageGraph) : super(element, library, packageGraph, null); bool get isClass => element is ClassElement; - bool get isExtension => element is ExtensionElement; - List get methods => []; - - List get instanceMethods { - if (_instanceMethods != null) return _instanceMethods; - - _instanceMethods = methods + @mustCallSuper + Iterable get allModelElements => quiver.concat([ + instanceMethods, + instanceFields, + instanceOperators, + instanceAccessors, + staticFields, + staticAccessors, + staticMethods, + ]); + + /// All methods, including operators and statics, declared as part of this + /// [Container]. [declaredMethods] must be the union of [instanceMethods], + /// [staticMethods], and [instanceOperators]. + /// + Iterable get declaredMethods; + + /// All methods declared as part of this [Container] that are [staticMethods] + /// or [operators]. + /// + /// Subclasses may extend this with inheritance or extensions. + Iterable get instanceMethods => declaredMethods .where((m) => !m.isStatic && !m.isOperator) - .toList(growable: false) - ..sort(byName); - return _instanceMethods; - } + .toList(growable: false); + + @Deprecated('Use instanceMethods instead') + Iterable get allInstanceMethods => instanceMethods; - bool get hasPublicMethods => + @nonVirtual + bool get hasPublicInstanceMethods => model_utils.filterNonPublic(instanceMethods).isNotEmpty; - Iterable get allPublicInstanceMethods => - model_utils.filterNonPublic(instanceMethods); - List get staticMethods { - _staticMethods ??= methods.where((m) => m.isStatic).toList(growable: false) - ..sort(byName); - return _staticMethods; + Iterable get publicInstanceMethods => model_utils.filterNonPublic(instanceMethods); + + List _publicInstanceMethodsSorted; + List get publicInstanceMethodsSorted => _publicInstanceMethodsSorted ?? publicInstanceMethods.toList()..sort(byName); + + Iterable _declaredOperators; + @nonVirtual + Iterable get declaredOperators { + _declaredOperators ??= declaredMethods + .whereType() + .toList(growable: false); + return _declaredOperators; } - bool get hasPublicStaticMethods => - model_utils.filterNonPublic(staticMethods).isNotEmpty; + Iterable get instanceOperators => declaredOperators; - Iterable get publicStaticMethods => - model_utils.filterNonPublic(staticMethods); + @nonVirtual + bool get hasPublicInstanceOperators => publicInstanceOperatorsSorted.isNotEmpty; - List get operators { - _operators ??= methods - .where((m) => m.isOperator) - .cast() - .toList(growable: false) - ..sort(byName); - return _operators; - } + @nonVirtual + Iterable get publicInstanceOperators => + model_utils.filterNonPublic(instanceOperators); - Iterable get allOperators => operators; + List _publicInstanceOperatorsSorted; + List get publicInstanceOperatorsSorted => _publicInstanceOperatorsSorted ??= publicInstanceOperators.toList()..sort(byName); - bool get hasPublicOperators => publicOperators.isNotEmpty; + /// Fields fully declared in this [Container]. + Iterable get declaredFields; - Iterable get allPublicOperators => - model_utils.filterNonPublic(allOperators); + /// All fields accessible in this instance that are not static. + Iterable get instanceFields => declaredFields.where((f) => !f.isStatic); - Iterable get publicOperators => - model_utils.filterNonPublic(operators); + bool get hasInstanceFields => instanceFields.isNotEmpty; - List get allFields => []; + @nonVirtual + Iterable get publicInstanceFields => + model_utils.filterNonPublic(instanceFields); - List get staticProperties { - _staticFields ??= allFields - .where((f) => f.isStatic && !f.isConst) - .toList(growable: false) - ..sort(byName); - return _staticFields; - } + @nonVirtual + bool get hasPublicInstanceFields => publicInstanceFields.isNotEmpty; - Iterable get publicStaticProperties => - model_utils.filterNonPublic(staticProperties); - bool get hasPublicStaticProperties => publicStaticProperties.isNotEmpty; + List _publicInstanceFieldsSorted; + List get publicInstanceFieldsSorted => _publicInstanceFieldsSorted ??= publicInstanceFields.toList()..sort(byName); - List get instanceProperties { - _instanceFields ??= allFields - .where((f) => !f.isStatic && !f.isInherited && !f.isConst) - .toList(growable: false) - ..sort(byName); - return _instanceFields; - } + Iterable get constantFields => declaredFields.where((f) => f.isConst); + + Iterable get publicConstantFields => model_utils.filterNonPublic(constantFields); + + bool get hasPublicConstantFields => publicConstantFieldsSorted.isNotEmpty; + + List _publicConstantFieldsSorted; + List get publicConstantFieldsSorted => _publicConstantFieldsSorted ??= publicConstantFields.toList()..sort(byName); - Iterable get publicInstanceProperties => - model_utils.filterNonPublic(instanceProperties); + Iterable get instanceAccessors => instanceFields.expand((f) => f.allAccessors); - bool get hasPublicProperties => publicInstanceProperties.isNotEmpty; + Iterable get constantAccessors => constantFields.expand((f) => f.allAccessors); - Iterable get allInstanceFields => instanceProperties; + Iterable get staticAccessors => staticFields.expand((f) => f.allAccessors); - Iterable get allPublicInstanceProperties => - model_utils.filterNonPublic(allInstanceFields); + /// This container might be canonical for elements it does not contain. + /// See [Inheritable.canonicalEnclosingContainer]. + bool containsElement(Element element) => allElements.contains(element); - bool isInheritingFrom(Container other) => false; + Set _allElements; + Set get allElements => _allElements ??= allModelElements.map((e) => e.element).toSet(); - List get constants { - _constants ??= allFields.where((f) => f.isConst).toList(growable: false) - ..sort(byName); - return _constants; + Map> _membersByName; + /// Given a ModelElement that is a member of some other class, return + /// a member of this class that has the same name and return type. + /// + /// This enables object substitution for canonicalization, such as Interceptor + /// for Object. + ModelElement memberByExample(ModelElement example) { + if (_membersByName == null) { + _membersByName = {}; + for (var me in allModelElements) { + if (!_membersByName.containsKey(me.name)) { + _membersByName[me.name] = []; + } + _membersByName[me.name].add(me); + } + } + ModelElement member; + var possibleMembers = _membersByName[example.name] + .where((e) => e.runtimeType == example.runtimeType); + if (example.runtimeType == Accessor) { + possibleMembers = possibleMembers.where( + (e) => (example as Accessor).isGetter == (e as Accessor).isGetter); + } + member = possibleMembers.first; + assert(possibleMembers.length == 1); + return member; } - Iterable get publicConstants => model_utils.filterNonPublic(constants); + Map> _allModelElementsByNamePart; + /// Helper for `_MarkdownCommentReference._getResultsForClass`. + Map> get allModelElementsByNamePart { + if (_allModelElementsByNamePart == null) { + _allModelElementsByNamePart = {}; + for (var me in allModelElements) { + _allModelElementsByNamePart.update( + me.namePart, (List v) => v..add(me), + ifAbsent: () => [me]); + } + } + return _allModelElementsByNamePart; + } + + bool get hasPublicStaticFields => publicStaticFieldsSorted.isNotEmpty; + + Iterable get publicStaticFields => + model_utils.filterNonPublic(staticFields); - bool get hasPublicConstants => publicConstants.isNotEmpty; + List _publicStaticFieldsSorted; + List get publicStaticFieldsSorted => _publicStaticFieldsSorted ??= publicStaticFields.toList()..sort(byName); - Iterable get allAccessors => quiver.concat([ - allInstanceFields.expand((f) => f.allAccessors), - constants.map((c) => c.getter) - ]); + Iterable _staticFields; + Iterable get staticFields => _staticFields ??= declaredFields + .where((f) => f.isStatic); + + Iterable _staticMethods; + Iterable get staticMethods => _staticMethods ??= + instanceMethods.where((m) => m.isStatic); + + bool get hasPublicStaticMethods => + model_utils.filterNonPublic(staticMethods).isNotEmpty; + + Iterable get publicStaticMethods => + model_utils.filterNonPublic(staticMethods); } diff --git a/lib/src/model/documentable.dart b/lib/src/model/documentable.dart index e8b1e5ca4c..5dc01b7a62 100644 --- a/lib/src/model/documentable.dart +++ b/lib/src/model/documentable.dart @@ -38,8 +38,7 @@ enum DocumentLocation { remote, } -abstract class MarkdownFileDocumentation - implements Documentable, Canonicalization { +mixin MarkdownFileDocumentation implements Documentable, Canonicalization { DocumentLocation get documentedWhere; @override diff --git a/lib/src/model/enum.dart b/lib/src/model/enum.dart index 21202bf6a4..c6c6da6f85 100644 --- a/lib/src/model/enum.dart +++ b/lib/src/model/enum.dart @@ -11,19 +11,6 @@ class Enum extends Class { Enum(ClassElement element, Library library, PackageGraph packageGraph) : super(element, library, packageGraph); - List _instanceProperties; - - @override - List get instanceProperties { - _instanceProperties ??= super - .instanceProperties - .map((Field p) => ModelElement.from( - p.element, p.library, p.packageGraph, - getter: p.getter, setter: p.setter) as EnumField) - .toList(growable: false); - return _instanceProperties; - } - @override String get kind => 'enum'; } diff --git a/lib/src/model/extension.dart b/lib/src/model/extension.dart index 893a673146..0f1f41a674 100644 --- a/lib/src/model/extension.dart +++ b/lib/src/model/extension.dart @@ -53,7 +53,7 @@ class Extension extends Container List _methods; @override - List get methods { + List get declaredMethods { _methods ??= _extension.methods.map((e) { return ModelElement.from(e, library, packageGraph) as Method; }).toList(growable: false) @@ -64,11 +64,11 @@ class Extension extends Container @override String get name => super.name ?? ''; - List _fields; + List _declaredFields; @override - List get allFields { - _fields ??= _extension.fields.map((f) { + List get declaredFields { + _declaredFields ??= _extension.fields.map((f) { Accessor getter, setter; if (f.getter != null) { getter = ContainerAccessor(f.getter, library, packageGraph); @@ -80,7 +80,7 @@ class Extension extends Container getter: getter, setter: setter) as Field; }).toList(growable: false) ..sort(byName); - return _fields; + return _declaredFields; } List _typeParameters; @@ -99,17 +99,11 @@ class Extension extends Container ParameterizedElementType get modelType => super.modelType; List _allModelElements; - + @override List get allModelElements { _allModelElements ??= List.from( quiver.concat([ - instanceMethods, - allInstanceFields, - allAccessors, - allOperators, - constants, - staticMethods, - staticProperties, + super.allModelElements, typeParameters, ]), growable: false); diff --git a/lib/src/model/extension_target.dart b/lib/src/model/extension_target.dart index c40ea9098f..72e4704792 100644 --- a/lib/src/model/extension_target.dart +++ b/lib/src/model/extension_target.dart @@ -23,8 +23,9 @@ mixin ExtensionTarget on ModelElement { _potentiallyApplicableExtensions ??= packageGraph.documentedExtensions .where((e) => !e.alwaysApplies) .where((e) => e.couldApplyTo(this)) - .toList(growable: false) - ..sort(byName); + .toList(growable: false); return _potentiallyApplicableExtensions; } + + List get potentiallyApplicableExtensionsSorted => potentiallyApplicableExtensions.toList()..sort(byName); } diff --git a/lib/src/model/inheritable.dart b/lib/src/model/inheritable.dart index 0610fb06db..05ac1d5bc2 100644 --- a/lib/src/model/inheritable.dart +++ b/lib/src/model/inheritable.dart @@ -70,7 +70,7 @@ mixin Inheritable on ContainerMember { Class found; for (var c in inheritance.reversed) { // Filter out mixins. - if (c.contains(searchElement)) { + if (c.containsElement(searchElement)) { if ((packageGraph.inheritThrough.contains(previous) && c != definingEnclosingContainer) || (packageGraph.inheritThrough.contains(c) && @@ -84,7 +84,7 @@ mixin Inheritable on ContainerMember { // starting from the ModelElement. if (canonicalC != null) { assert(canonicalC.isCanonical); - assert(canonicalC.contains(searchElement)); + assert(canonicalC.containsElement(searchElement)); found = canonicalC; break; } diff --git a/lib/src/model/top_level_variable.dart b/lib/src/model/top_level_variable.dart index c07a495d81..e48d109c36 100644 --- a/lib/src/model/top_level_variable.dart +++ b/lib/src/model/top_level_variable.dart @@ -8,7 +8,7 @@ import 'package:dartdoc/src/model/model.dart'; /// Top-level variables. But also picks up getters and setters? class TopLevelVariable extends ModelElement - with Canonicalization, GetterSetterCombo, SourceCodeMixin, Categorization + with Canonicalization, GetterSetterCombo, Categorization implements EnclosedElement { @override final Accessor getter; diff --git a/lib/src/model/typedef.dart b/lib/src/model/typedef.dart index 760c24927a..f15085a74c 100644 --- a/lib/src/model/typedef.dart +++ b/lib/src/model/typedef.dart @@ -8,7 +8,7 @@ import 'package:dartdoc/src/model/model.dart'; import 'package:dartdoc/src/render/typedef_renderer.dart'; class Typedef extends ModelElement - with SourceCodeMixin, TypeParameters, Categorization + with TypeParameters, Categorization implements EnclosedElement { Typedef(FunctionTypeAliasElement element, Library library, PackageGraph packageGraph) diff --git a/lib/templates/html/_sidebar_for_class.html b/lib/templates/html/_sidebar_for_class.html index 662ec17b77..36e554f21b 100644 --- a/lib/templates/html/_sidebar_for_class.html +++ b/lib/templates/html/_sidebar_for_class.html @@ -3,54 +3,54 @@ {{#hasPublicConstructors}}
  • Constructors
  • - {{#publicConstructors}} + {{#publicConstructorsSorted}}
  • {{shortName}}
  • - {{/publicConstructors}} + {{/publicConstructorsSorted}} {{/hasPublicConstructors}} - {{#hasPublicProperties}} -
  • + {{#hasPublicInstanceFields}} +
  • Properties
  • - {{#allPublicInstanceProperties}} + {{#publicInstanceFieldsSorted}} {{{ linkedName }}} - {{/allPublicInstanceProperties}} - {{/hasPublicProperties}} + {{/publicInstanceFieldsSorted}} + {{/hasPublicInstanceFields}} - {{#hasPublicMethods}} -
  • Methods
  • - {{#allPublicInstanceMethods}} + {{#hasPublicInstanceMethods}} +
  • Methods
  • + {{#publicInstanceMethodsSorted}} {{{ linkedName }}} - {{/allPublicInstanceMethods}} - {{/hasPublicMethods}} + {{/publicInstanceMethodsSorted}} + {{/hasPublicInstanceMethods}} - {{#hasPublicOperators}} -
  • Operators
  • - {{#allPublicOperators}} + {{#hasPublicInstanceOperators}} +
  • Operators
  • + {{#publicInstanceOperatorsSorted}} {{{ linkedName }}} - {{/allPublicOperators}} - {{/hasPublicOperators}} + {{/publicInstanceOperatorsSorted}} + {{/hasPublicInstanceOperators}} - {{#hasPublicStaticProperties}} + {{#hasPublicStaticFields}}
  • Static properties
  • - {{#publicStaticProperties}} + {{#publicStaticPropertiesSorted}}
  • {{{ linkedName }}}
  • - {{/publicStaticProperties}} - {{/hasPublicStaticProperties}} + {{/publicStaticPropertiesSorted}} + {{/hasPublicStaticFields}} {{#hasPublicStaticMethods}}
  • Static methods
  • - {{#publicStaticMethods}} + {{#publicStaticMethodsSorted}}
  • {{{ linkedName }}}
  • - {{/publicStaticMethods}} + {{/publicStaticMethodsSorted}} {{/hasPublicStaticMethods}} - {{#hasPublicConstants}} + {{#hasPublicConstantFields}}
  • Constants
  • - {{#publicConstants}} + {{#publicConstantFieldsSorted}}
  • {{{linkedName}}}
  • - {{/publicConstants}} - {{/hasPublicConstants}} + {{/publicConstantFieldsSorted}} + {{/hasPublicConstantFields}} {{/clazz}} diff --git a/lib/templates/html/_sidebar_for_container.html b/lib/templates/html/_sidebar_for_container.html index 3c3b3166ec..dfec338486 100644 --- a/lib/templates/html/_sidebar_for_container.html +++ b/lib/templates/html/_sidebar_for_container.html @@ -4,99 +4,99 @@ {{#isClass}} {{#hasPublicConstructors}}
  • Constructors
  • - {{#publicConstructors}} + {{#publicConstructorsSorted}}
  • {{shortName}}
  • - {{/publicConstructors}} + {{/publicConstructorsSorted}} {{/hasPublicConstructors}} - {{#hasPublicProperties}} -
  • + {{#hasPublicInstanceFields}} +
  • Properties
  • - {{#allPublicInstanceProperties}} + {{#publicInstanceFieldsSorted}} {{{ linkedName }}} - {{/allPublicInstanceProperties}} - {{/hasPublicProperties}} + {{/publicInstanceFieldsSorted}} + {{/hasPublicInstanceFields}} - {{#hasPublicMethods}} -
  • Methods
  • - {{#allPublicInstanceMethods}} + {{#hasPublicInstanceMethods}} +
  • Methods
  • + {{#publicInstanceMethodsSorted}} {{{ linkedName }}} - {{/allPublicInstanceMethods}} - {{/hasPublicMethods}} + {{/publicInstanceMethodsSorted}} + {{/hasPublicInstanceMethods}} - {{#hasPublicOperators}} -
  • Operators
  • - {{#allPublicOperators}} + {{#hasPublicInstanceOperators}} +
  • Operators
  • + {{#publicInstanceOperatorsSorted}} {{{ linkedName }}} - {{/allPublicOperators}} - {{/hasPublicOperators}} + {{/publicInstanceOperatorsSorted}} + {{/hasPublicInstanceOperators}} - {{#hasPublicStaticProperties}} + {{#hasPublicStaticFields}}
  • Static properties
  • - {{#publicStaticProperties}} + {{#publicStaticFieldsSorted}}
  • {{{ linkedName }}}
  • - {{/publicStaticProperties}} - {{/hasPublicStaticProperties}} + {{/publicStaticFieldsSorted}} + {{/hasPublicStaticFields}} {{#hasPublicStaticMethods}}
  • Static methods
  • - {{#publicStaticMethods}} + {{#publicStaticMethodsSorted}}
  • {{{ linkedName }}}
  • - {{/publicStaticMethods}} + {{/publicStaticMethodsSorted}} {{/hasPublicStaticMethods}} - {{#hasPublicConstants}} + {{#hasPublicConstantFields}}
  • Constants
  • - {{#publicConstants}} + {{#publicConstantFieldsSorted}}
  • {{{linkedName}}}
  • - {{/publicConstants}} - {{/hasPublicConstants}} + {{/publicConstantFieldsSorted}} + {{/hasPublicConstantFields}} {{/isClass}} {{#isExtension}} - {{#hasPublicProperties}} + {{#hasPublicInstanceFields}}
  • Properties
  • - {{#allPublicInstanceProperties}} + {{#publicInstanceFieldsSorted}}
  • {{{ linkedName }}}
  • - {{/allPublicInstanceProperties}} - {{/hasPublicProperties}} + {{/publicInstanceFieldsSorted}} + {{/hasPublicInstanceFields}} - {{#hasPublicMethods}} + {{#hasPublicInstanceMethods}}
  • Methods
  • - {{#allPublicInstanceMethods}} + {{#publicInstanceMethodsSorted}}
  • {{{ linkedName }}}
  • - {{/allPublicInstanceMethods}} - {{/hasPublicMethods}} + {{/publicInstanceMethodsSorted}} + {{/hasPublicInstanceMethods}} - {{#hasPublicOperators}} + {{#hasPublicInstanceOperators}}
  • Operators
  • - {{#allPublicOperators}} + {{#publicInstanceOperatorsSorted}}
  • {{{ linkedName }}}
  • - {{/allPublicOperators}} - {{/hasPublicOperators}} + {{/publicInstanceOperatorsSorted}} + {{/hasPublicInstanceOperators}} - {{#hasPublicStaticProperties}} + {{#hasPublicStaticFields}}
  • Static properties
  • - {{#publicStaticProperties}} + {{#publicStaticFieldsSorted}}
  • {{{ linkedName }}}
  • - {{/publicStaticProperties}} - {{/hasPublicStaticProperties}} + {{/publicStaticFieldsSorted}} + {{/hasPublicStaticFields}} {{#hasPublicStaticMethods}}
  • Static methods
  • - {{#publicStaticMethods}} + {{#publicStaticMethodsSorted}}
  • {{{ linkedName }}}
  • - {{/publicStaticMethods}} + {{/publicStaticMethodsSorted}} {{/hasPublicStaticMethods}} - {{#hasPublicConstants}} + {{#hasPublicConstantFields}}
  • Constants
  • - {{#publicConstants}} + {{#publicConstantFieldsSorted}}
  • {{{linkedName}}}
  • - {{/publicConstants}} - {{/hasPublicConstants}} + {{/publicConstantFieldsSorted}} + {{/hasPublicConstantFields}} {{/isExtension}} {{/container}} diff --git a/lib/templates/html/_sidebar_for_enum.html b/lib/templates/html/_sidebar_for_enum.html index c0537825fb..2ae665f43f 100644 --- a/lib/templates/html/_sidebar_for_enum.html +++ b/lib/templates/html/_sidebar_for_enum.html @@ -1,54 +1,54 @@
      {{#eNum}} - {{#hasPublicConstants}} + {{#hasPublicConstantFields}}
    1. Constants
    2. - {{#publicConstants}} + {{#publicConstantFieldsSorted}}
    3. {{{linkedName}}}
    4. - {{/publicConstants}} - {{/hasPublicConstants}} + {{/publicConstantFieldsSorted}} + {{/hasPublicConstantFields}} {{#hasPublicConstructors}}
    5. Constructors
    6. - {{#publicConstructors}} + {{#publicConstructorsSorted}}
    7. {{shortName}}
    8. - {{/publicConstructors}} + {{/publicConstructorsSorted}} {{/hasPublicConstructors}} - {{#hasPublicProperties}} -
    9. + {{#hasPublicInstanceFields}} +
    10. Properties
    11. - {{#allPublicInstanceProperties}} + {{#publicInstanceFieldsSorted}} {{{ linkedName }}} - {{/allPublicInstanceProperties}} - {{/hasPublicProperties}} + {{/publicInstanceFieldsSorted}} + {{/hasPublicInstanceFields}} - {{#hasPublicMethods}} -
    12. Methods
    13. - {{#allPublicInstanceMethods}} + {{#hasPublicInstanceMethods}} +
    14. Methods
    15. + {{#publicInstanceMethodsSorted}} {{{ linkedName }}} - {{/allPublicInstanceMethods}} - {{/hasPublicMethods}} + {{/publicInstanceMethodsSorted}} + {{/hasPublicInstanceMethods}} - {{#hasPublicOperators}} -
    16. Operators
    17. - {{#allPublicOperators}} + {{#hasPublicInstanceOperators}} +
    18. Operators
    19. + {{#publicInstanceOperatorsSorted}} {{{ linkedName }}} - {{/allPublicOperators}} - {{/hasPublicOperators}} + {{/publicInstanceOperatorsSorted}} + {{/hasPublicInstanceOperators}} - {{#hasPublicStaticProperties}} + {{#hasPublicStaticFields}}
    20. Static properties
    21. - {{#publicStaticProperties}} + {{#publicStaticFieldsSorted}}
    22. {{{ linkedName }}}
    23. - {{/publicStaticProperties}} - {{/hasPublicStaticProperties}} + {{/publicStaticFieldsSorted}} + {{/hasPublicStaticFields}} {{#hasPublicStaticMethods}}
    24. Static methods
    25. - {{#publicStaticMethods}} + {{#publicStaticMethodsSorted}}
    26. {{{ linkedName }}}
    27. - {{/publicStaticMethods}} + {{/publicStaticMethodsSorted}} {{/hasPublicStaticMethods}} {{/eNum}}
    diff --git a/lib/templates/html/_sidebar_for_extension.html b/lib/templates/html/_sidebar_for_extension.html index 138db391fe..e50dc73fca 100644 --- a/lib/templates/html/_sidebar_for_extension.html +++ b/lib/templates/html/_sidebar_for_extension.html @@ -1,48 +1,48 @@
      {{#extension}} - {{#hasPublicProperties}} + {{#hasPublicInstanceFields}}
    1. Properties
    2. - {{#allPublicInstanceProperties}} + {{#publicInstanceFieldsSorted}}
    3. {{{ linkedName }}}
    4. - {{/allPublicInstanceProperties}} - {{/hasPublicProperties}} + {{/publicInstanceFieldsSorted}} + {{/hasPublicInstanceFields}} - {{#hasPublicMethods}} + {{#hasPublicInstanceMethods}}
    5. Methods
    6. - {{#allPublicInstanceMethods}} + {{#publicInstanceMethodsSorted}}
    7. {{{ linkedName }}}
    8. - {{/allPublicInstanceMethods}} - {{/hasPublicMethods}} + {{/publicInstanceMethodsSorted}} + {{/hasPublicInstanceMethods}} - {{#hasPublicOperators}} + {{#hasPublicInstanceOperators}}
    9. Operators
    10. - {{#allPublicOperators}} + {{#publicInstanceOperatorsSorted}}
    11. {{{ linkedName }}}
    12. - {{/allPublicOperators}} - {{/hasPublicOperators}} + {{/publicInstanceOperatorsSorted}} + {{/hasPublicInstanceOperators}} - {{#hasPublicStaticProperties}} + {{#hasPublicStaticFields}}
    13. Static properties
    14. - {{#publicStaticProperties}} + {{#publicStaticFieldsSorted}}
    15. {{{ linkedName }}}
    16. - {{/publicStaticProperties}} - {{/hasPublicStaticProperties}} + {{/publicStaticFieldsSorted}} + {{/hasPublicStaticFields}} {{#hasPublicStaticMethods}}
    17. Static methods
    18. - {{#publicStaticMethods}} + {{#publicStaticMethodsSorted}}
    19. {{{ linkedName }}}
    20. - {{/publicStaticMethods}} + {{/publicStaticMethodsSorted}} {{/hasPublicStaticMethods}} - {{#hasPublicConstants}} + {{#hasPublicConstantFields}}
    21. Constants
    22. - {{#publicConstants}} + {{#publicConstantFieldsSorted}}
    23. {{{linkedName}}}
    24. - {{/publicConstants}} - {{/hasPublicConstants}} + {{/publicConstantFieldsSorted}} + {{/hasPublicConstantFields}} {{/extension}}
    diff --git a/lib/templates/html/_source_link.html b/lib/templates/html/_source_link.html index 7db4cf91ed..0c80cf9058 100644 --- a/lib/templates/html/_source_link.html +++ b/lib/templates/html/_source_link.html @@ -1,3 +1,3 @@ {{#hasSourceHref}} -{{/hasSourceHref}} \ No newline at end of file +{{/hasSourceHref}} diff --git a/lib/templates/html/class.html b/lib/templates/html/class.html index 8a6d799ee4..02f2a7a733 100644 --- a/lib/templates/html/class.html +++ b/lib/templates/html/class.html @@ -60,9 +60,9 @@
    {{parent.name}} {{parent.kind}}
    {{#hasPotentiallyApplicableExtensions}}
    Available Extensions
      - {{#potentiallyApplicableExtensions}} + {{#potentiallyApplicableExtensionsSorted}}
    • {{{linkedName}}}
    • - {{/potentiallyApplicableExtensions}} + {{/potentiallyApplicableExtensionsSorted}}
    {{/hasPotentiallyApplicableExtensions}} @@ -83,7 +83,7 @@
    {{parent.name}} {{parent.kind}}

    Constructors

    - {{#publicConstructors}} + {{#publicConstructorsSorted}}
    {{{linkedName}}}({{{ linkedParams }}})
    @@ -96,79 +96,79 @@

    Constructors

    factory
    {{/isFactory}} - {{/publicConstructors}} + {{/publicConstructorsSorted}}
    {{/hasPublicConstructors}} - {{#hasPublicProperties}} -
    + {{#hasPublicInstanceFields}} +

    Properties

    - {{#allPublicInstanceProperties}} + {{#publicInstanceFieldsSorted}} {{>property}} - {{/allPublicInstanceProperties}} + {{/publicInstanceFieldsSorted}}
    - {{/hasPublicProperties}} + {{/hasPublicInstanceFields}} - {{#hasPublicMethods}} -
    + {{#hasPublicInstanceMethods}} +

    Methods

    - {{#allPublicInstanceMethods}} + {{#publicInstanceMethodsSorted}} {{>callable}} - {{/allPublicInstanceMethods}} + {{/publicInstanceMethodsSorted}}
    - {{/hasPublicMethods}} + {{/hasPublicInstanceMethods}} - {{#hasPublicOperators}} -
    + {{#hasPublicInstanceOperators}} +

    Operators

    - {{#allPublicOperators}} + {{#publicInstanceOperatorsSorted}} {{>callable}} - {{/allPublicOperators}} + {{/publicInstanceOperatorsSorted}}
    - {{/hasPublicOperators}} + {{/hasPublicInstanceOperators}} - {{#hasPublicStaticProperties}} + {{#hasPublicStaticFields}}

    Static Properties

    - {{#publicStaticProperties}} + {{#publicStaticFieldsSorted}} {{>property}} - {{/publicStaticProperties}} + {{/publicStaticFieldsSorted}}
    - {{/hasPublicStaticProperties}} + {{/hasPublicStaticFields}} {{#hasPublicStaticMethods}}

    Static Methods

    - {{#publicStaticMethods}} + {{#publicStaticMethodsSorted}} {{>callable}} - {{/publicStaticMethods}} + {{/publicStaticMethodsSorted}}
    {{/hasPublicStaticMethods}} - {{#hasPublicConstants}} + {{#hasPublicConstantFields}}

    Constants

    - {{#publicConstants}} + {{#publicConstantFieldsSorted}} {{>constant}} - {{/publicConstants}} + {{/publicConstantFieldsSorted}}
    - {{/hasPublicConstants}} + {{/hasPublicConstantFields}} {{/clazz}} diff --git a/lib/templates/html/enum.html b/lib/templates/html/enum.html index 1d8a18f49b..b1e3ce267e 100644 --- a/lib/templates/html/enum.html +++ b/lib/templates/html/enum.html @@ -69,24 +69,24 @@
    {{parent.name}} {{parent.kind}}
    {{/hasModifiers}} - {{#hasPublicConstants}} + {{#hasPublicConstantFields}}

    Constants

    - {{#publicConstants}} + {{#publicConstantFieldsSorted}} {{>constant}} - {{/publicConstants}} + {{/publicConstantFieldsSorted}}
    - {{/hasPublicConstants}} + {{/hasPublicConstantFields}} {{#hasPublicConstructors}}

    Constructors

    - {{#publicConstructors}} + {{#publicConstructorsSorted}}
    {{{linkedName}}}({{{ linkedParams }}})
    @@ -99,64 +99,64 @@

    Constructors

    factory
    {{/isFactory}} - {{/publicConstructors}} + {{/publicConstructorsSorted}}
    {{/hasPublicConstructors}} - {{#hasPublicProperties}} -
    + {{#hasPublicInstanceFields}} +

    Properties

    - {{#allPublicInstanceProperties}} + {{#publicInstanceFieldsSorted}} {{>property}} - {{/allPublicInstanceProperties}} + {{/publicInstanceFieldsSorted}}
    - {{/hasPublicProperties}} + {{/hasPublicInstanceFields}} - {{#hasPublicMethods}} -
    + {{#hasPublicInstanceMethods}} +

    Methods

    - {{#allPublicInstanceMethods}} + {{#publicInstanceMethodsSorted}} {{>callable}} - {{/allPublicInstanceMethods}} + {{/publicInstanceMethodsSorted}}
    - {{/hasPublicMethods}} + {{/hasPublicInstanceMethods}} - {{#hasPublicOperators}} -
    + {{#hasPublicInstanceOperators}} +

    Operators

    - {{#allPublicOperators}} + {{#publicInstanceOperatorsSorted}} {{>callable}} - {{/allPublicOperators}} + {{/publicInstanceOperatorsSorted}}
    - {{/hasPublicOperators}} + {{/hasPublicInstanceOperators}} - {{#hasPublicStaticProperties}} + {{#hasPublicStaticFields}}

    Static Properties

    - {{#publicStaticProperties}} + {{#publicStaticFieldsSorted}} {{>property}} - {{/publicStaticProperties}} + {{/publicStaticFieldsSorted}}
    - {{/hasPublicStaticProperties}} + {{/hasPublicStaticFields}} {{#hasPublicStaticMethods}}

    Static Methods

    - {{#publicStaticMethods}} + {{#publicStaticMethodsSorted}} {{>callable}} - {{/publicStaticMethods}} + {{/publicStaticMethodsSorted}}
    {{/hasPublicStaticMethods}} diff --git a/lib/templates/html/extension.html b/lib/templates/html/extension.html index e722cc7622..99316b06b6 100644 --- a/lib/templates/html/extension.html +++ b/lib/templates/html/extension.html @@ -26,74 +26,74 @@
    {{parent.name}} {{parent.kind}}
    - {{#hasPublicProperties}} + {{#hasPublicInstanceFields}}

    Properties

    - {{#allPublicInstanceProperties}} + {{#publicInstanceFieldsSorted}} {{>property}} - {{/allPublicInstanceProperties}} + {{/publicInstanceFieldsSorted}}
    - {{/hasPublicProperties}} + {{/hasPublicInstanceFields}} - {{#hasPublicMethods}} + {{#hasPublicInstanceMethods}}

    Methods

    - {{#allPublicInstanceMethods}} + {{#publicInstanceMethodsSorted}} {{>callable}} - {{/allPublicInstanceMethods}} + {{/publicInstanceMethodsSorted}}
    - {{/hasPublicMethods}} + {{/hasPublicInstanceMethods}} - {{#hasPublicOperators}} + {{#hasPublicInstanceOperators}}

    Operators

    - {{#allPublicOperators}} + {{#publicInstanceOperatorsSorted}} {{>callable}} - {{/allPublicOperators}} + {{/publicInstanceOperatorsSorted}}
    - {{/hasPublicOperators}} + {{/hasPublicInstanceOperators}} - {{#hasPublicStaticProperties}} + {{#hasPublicStaticFields}}

    Static Properties

    - {{#publicStaticProperties}} + {{#publicStaticFieldsSorted}} {{>property}} - {{/publicStaticProperties}} + {{/publicStaticFieldsSorted}}
    - {{/hasPublicStaticProperties}} + {{/hasPublicStaticFields}} {{#hasPublicStaticMethods}}

    Static Methods

    - {{#publicStaticMethods}} + {{#publicStaticMethodsSorted}} {{>callable}} - {{/publicStaticMethods}} + {{/publicStaticMethodsSorted}}
    {{/hasPublicStaticMethods}} - {{#hasPublicConstants}} + {{#hasPublicConstantFields}}

    Constants

    - {{#publicConstants}} + {{#publicConstantFieldsSorted}} {{>constant}} - {{/publicConstants}} + {{/publicConstantFieldsSorted}}
    - {{/hasPublicConstants}} + {{/hasPublicConstantFields}} {{/extension}} diff --git a/lib/templates/html/mixin.html b/lib/templates/html/mixin.html index da5f418c71..61917470e7 100644 --- a/lib/templates/html/mixin.html +++ b/lib/templates/html/mixin.html @@ -101,41 +101,41 @@

    Constructors

    {{/hasPublicConstructors}} - {{#hasPublicProperties}} -
    + {{#hasPublicInstanceFields}} +

    Properties

    - {{#allPublicInstanceProperties}} + {{#publicInstanceFields}} {{>property}} - {{/allPublicInstanceProperties}} + {{/publicInstanceFields}}
    - {{/hasPublicProperties}} + {{/hasPublicInstanceFields}} - {{#hasPublicMethods}} -
    + {{#hasPublicInstanceMethods}} +

    Methods

    - {{#allPublicInstanceMethods}} + {{#publicInstanceMethods}} {{>callable}} - {{/allPublicInstanceMethods}} + {{/publicInstanceMethods}}
    - {{/hasPublicMethods}} + {{/hasPublicInstanceMethods}} - {{#hasPublicOperators}} -
    + {{#hasPublicInstanceOperators}} +

    Operators

    - {{#allPublicOperators}} + {{#publicInstanceOperatorsSorted}} {{>callable}} - {{/allPublicOperators}} + {{/publicInstanceOperatorsSorted}}
    - {{/hasPublicOperators}} + {{/hasPublicInstanceOperators}} - {{#hasPublicStaticProperties}} + {{#hasPublicStaticFields}}

    Static Properties

    @@ -145,7 +145,7 @@

    Static Properties

    {{/publicStaticProperties}}
    - {{/hasPublicStaticProperties}} + {{/hasPublicStaticFields}} {{#hasPublicStaticMethods}}
    @@ -158,17 +158,17 @@

    Static Methods

    {{/hasPublicStaticMethods}} - {{#hasPublicConstants}} + {{#hasPublicConstantFields}}

    Constants

    - {{#publicConstants}} + {{#publicConstantFieldsSorted}} {{>constant}} - {{/publicConstants}} + {{/publicConstantFieldsSorted}}
    - {{/hasPublicConstants}} + {{/hasPublicConstantFields}} {{/mixin}} diff --git a/lib/templates/html/top_level_property.html b/lib/templates/html/top_level_property.html index 2f417791c2..00bbf31845 100644 --- a/lib/templates/html/top_level_property.html +++ b/lib/templates/html/top_level_property.html @@ -33,4 +33,4 @@
    {{parent.name}} {{parent.kind}}
    -{{>footer}} \ No newline at end of file +{{>footer}} diff --git a/test/model_special_cases_test.dart b/test/model_special_cases_test.dart index 9cabd67ba7..71fa09d2fc 100644 --- a/test/model_special_cases_test.dart +++ b/test/model_special_cases_test.dart @@ -55,7 +55,7 @@ void main() { }); test('method parameters with required', () { - var m1 = b.allInstanceMethods.firstWhere((m) => m.name == 'm1'); + var m1 = b.instanceMethods.firstWhere((m) => m.name == 'm1'); var p1 = m1.allParameters.firstWhere((p) => p.name == 'p1'); var p2 = m1.allParameters.firstWhere((p) => p.name == 'p2'); expect(p1.isRequiredNamed, isTrue); @@ -76,7 +76,7 @@ void main() { }); test('verify no regression on ordinary optionals', () { - var m2 = b.allInstanceMethods.firstWhere((m) => m.name == 'm2'); + var m2 = b.instanceMethods.firstWhere((m) => m.name == 'm2'); var sometimes = m2.allParameters.firstWhere((p) => p.name == 'sometimes'); var optionals = m2.allParameters.firstWhere((p) => p.name == 'optionals'); expect(sometimes.isRequiredNamed, isFalse); @@ -99,14 +99,14 @@ void main() { test('Late final class member test', () { var c = lateFinalWithoutInitializer.allClasses .firstWhere((c) => c.name == 'C'); - var a = c.allFields.firstWhere((f) => f.name == 'a'); - var b = c.allFields.firstWhere((f) => f.name == 'b'); - var cField = c.allFields.firstWhere((f) => f.name == 'cField'); - var dField = c.allFields.firstWhere((f) => f.name == 'dField'); + var a = c.instanceFields.firstWhere((f) => f.name == 'a'); + var b = c.instanceFields.firstWhere((f) => f.name == 'b'); + var cField = c.instanceFields.firstWhere((f) => f.name == 'cField'); + var dField = c.instanceFields.firstWhere((f) => f.name == 'dField'); // If nnbd isn't enabled, fields named 'late' come back from the analyzer // instead of setting up 'isLate'. - expect(c.allFields.any((f) => f.name == 'late'), isFalse); + expect(c.instanceFields.any((f) => f.name == 'late'), isFalse); expect(a.modelType.returnType.name, equals('dynamic')); expect(a.isLate, isTrue); @@ -154,9 +154,9 @@ void main() { htmlInjection = injectionExLibrary.classes .firstWhere((c) => c.name == 'HtmlInjection'); - injectSimpleHtml = htmlInjection.allInstanceMethods + injectSimpleHtml = htmlInjection.instanceMethods .firstWhere((m) => m.name == 'injectSimpleHtml'); - injectHtmlFromTool = htmlInjection.allInstanceMethods + injectHtmlFromTool = htmlInjection.instanceMethods .firstWhere((m) => m.name == 'injectHtmlFromTool'); injectionPackageGraph.allLocalModelElements .forEach((m) => m.documentation); @@ -353,7 +353,7 @@ void main() { .singleWhere((l) => l.name == 'dart:html'); var EventTarget = htmlLibrary.allClasses.singleWhere((c) => c.name == 'EventTarget'); - var hashCode = EventTarget.allPublicInstanceProperties + var hashCode = EventTarget.publicInstanceFields .singleWhere((f) => f.name == 'hashCode'); var objectModelElement = sdkAsPackageGraph.specialClasses[SpecialClass.object]; @@ -417,20 +417,20 @@ void main() { .classes .firstWhere((c) => c.name == 'DocumentationErrors') ..documentation; - withYouTubeWrongParams = documentationErrors.allInstanceMethods + withYouTubeWrongParams = documentationErrors.instanceMethods .firstWhere((m) => m.name == 'withYouTubeWrongParams') ..documentation; - withYouTubeBadWidth = documentationErrors.allInstanceMethods + withYouTubeBadWidth = documentationErrors.instanceMethods .firstWhere((m) => m.name == 'withYouTubeBadWidth') ..documentation; - withYouTubeBadHeight = documentationErrors.allInstanceMethods + withYouTubeBadHeight = documentationErrors.instanceMethods .firstWhere((m) => m.name == 'withYouTubeBadHeight') ..documentation; - withYouTubeInvalidUrl = documentationErrors.allInstanceMethods + withYouTubeInvalidUrl = documentationErrors.instanceMethods .firstWhere((m) => m.name == 'withYouTubeInvalidUrl') ..documentation; withYouTubeUrlWithAdditionalParameters = documentationErrors - .allInstanceMethods + .instanceMethods .firstWhere((m) => m.name == 'withYouTubeUrlWithAdditionalParameters') ..documentation; }); @@ -504,25 +504,25 @@ void main() { .classes .firstWhere((c) => c.name == 'DocumentationErrors') ..documentation; - withInvalidNamedAnimation = documentationErrors.allInstanceMethods + withInvalidNamedAnimation = documentationErrors.instanceMethods .firstWhere((m) => m.name == 'withInvalidNamedAnimation') ..documentation; - withAnimationNonUnique = documentationErrors.allInstanceMethods + withAnimationNonUnique = documentationErrors.instanceMethods .firstWhere((m) => m.name == 'withAnimationNonUnique') ..documentation; - withAnimationNonUniqueDeprecated = documentationErrors.allInstanceMethods + withAnimationNonUniqueDeprecated = documentationErrors.instanceMethods .firstWhere((m) => m.name == 'withAnimationNonUniqueDeprecated') ..documentation; - withAnimationWrongParams = documentationErrors.allInstanceMethods + withAnimationWrongParams = documentationErrors.instanceMethods .firstWhere((m) => m.name == 'withAnimationWrongParams') ..documentation; - withAnimationBadWidth = documentationErrors.allInstanceMethods + withAnimationBadWidth = documentationErrors.instanceMethods .firstWhere((m) => m.name == 'withAnimationBadWidth') ..documentation; - withAnimationBadHeight = documentationErrors.allInstanceMethods + withAnimationBadHeight = documentationErrors.instanceMethods .firstWhere((m) => m.name == 'withAnimationBadHeight') ..documentation; - withAnimationUnknownArg = documentationErrors.allInstanceMethods + withAnimationUnknownArg = documentationErrors.instanceMethods .firstWhere((m) => m.name == 'withAnimationUnknownArg') ..documentation; }); diff --git a/test/model_test.dart b/test/model_test.dart index 494e0c0783..8b45af3742 100644 --- a/test/model_test.dart +++ b/test/model_test.dart @@ -157,24 +157,24 @@ void main() { .firstWhere((c) => c.name == 'CanonicalPrivateInheritedToolUser'); toolUser = exLibrary.classes.firstWhere((c) => c.name == 'ToolUser'); invokeTool = - toolUser.allInstanceMethods.firstWhere((m) => m.name == 'invokeTool'); - invokeToolNonCanonical = _NonCanonicalToolUser.allInstanceMethods + toolUser.instanceMethods.firstWhere((m) => m.name == 'invokeTool'); + invokeToolNonCanonical = _NonCanonicalToolUser.instanceMethods .firstWhere((m) => m.name == 'invokeToolNonCanonical'); - invokeToolNonCanonicalSubclass = CanonicalToolUser.allInstanceMethods + invokeToolNonCanonicalSubclass = CanonicalToolUser.instanceMethods .firstWhere((m) => m.name == 'invokeToolNonCanonical'); - invokeToolNoInput = toolUser.allInstanceMethods + invokeToolNoInput = toolUser.instanceMethods .firstWhere((m) => m.name == 'invokeToolNoInput'); - invokeToolMultipleSections = toolUser.allInstanceMethods + invokeToolMultipleSections = toolUser.instanceMethods .firstWhere((m) => m.name == 'invokeToolMultipleSections'); - invokeToolPrivateLibrary = PrivateLibraryToolUser.allInstanceMethods + invokeToolPrivateLibrary = PrivateLibraryToolUser.instanceMethods .firstWhere((m) => m.name == 'invokeToolPrivateLibrary'); invokeToolPrivateLibraryOriginal = (invokeToolPrivateLibrary.definingEnclosingContainer as Class) - .allInstanceMethods + .instanceMethods .firstWhere((m) => m.name == 'invokeToolPrivateLibrary'); - invokeToolParentDoc = CanonicalPrivateInheritedToolUser.allInstanceMethods + invokeToolParentDoc = CanonicalPrivateInheritedToolUser.instanceMethods .firstWhere((m) => m.name == 'invokeToolParentDoc'); - invokeToolParentDocOriginal = ImplementingClassForTool.allInstanceMethods + invokeToolParentDocOriginal = ImplementingClassForTool.instanceMethods .firstWhere((m) => m.name == 'invokeToolParentDoc'); packageGraph.allLocalModelElements.forEach((m) => m.documentation); }); @@ -301,7 +301,7 @@ void main() { setUpAll(() { htmlInjection = exLibrary.classes.firstWhere((c) => c.name == 'HtmlInjection'); - injectSimpleHtml = htmlInjection.allInstanceMethods + injectSimpleHtml = htmlInjection.instanceMethods .firstWhere((m) => m.name == 'injectSimpleHtml'); }); test("doesn't inject HTML if --inject-html option is not present", () { @@ -700,16 +700,16 @@ void main() { setUpAll(() { dog = exLibrary.classes.firstWhere((c) => c.name == 'Dog'); withMacro = - dog.allInstanceMethods.firstWhere((m) => m.name == 'withMacro'); + dog.instanceMethods.firstWhere((m) => m.name == 'withMacro'); withMacro2 = - dog.allInstanceMethods.firstWhere((m) => m.name == 'withMacro2'); - withPrivateMacro = dog.allInstanceMethods + dog.instanceMethods.firstWhere((m) => m.name == 'withMacro2'); + withPrivateMacro = dog.instanceMethods .firstWhere((m) => m.name == 'withPrivateMacro'); - withUndefinedMacro = dog.allInstanceMethods + withUndefinedMacro = dog.instanceMethods .firstWhere((m) => m.name == 'withUndefinedMacro'); MacrosFromAccessors = fakeLibrary.enums.firstWhere((e) => e.name == 'MacrosFromAccessors'); - macroReferencedHere = MacrosFromAccessors.publicConstants + macroReferencedHere = MacrosFromAccessors.publicConstantFields .firstWhere((e) => e.name == 'macroReferencedHere'); }); @@ -750,11 +750,11 @@ void main() { setUpAll(() { dog = exLibrary.classes.firstWhere((c) => c.name == 'Dog'); - withYouTubeWatchUrl = dog.allInstanceMethods + withYouTubeWatchUrl = dog.instanceMethods .firstWhere((m) => m.name == 'withYouTubeWatchUrl'); - withYouTubeInOneLineDoc = dog.allInstanceMethods + withYouTubeInOneLineDoc = dog.instanceMethods .firstWhere((m) => m.name == 'withYouTubeInOneLineDoc'); - withYouTubeInline = dog.allInstanceMethods + withYouTubeInline = dog.instanceMethods .firstWhere((m) => m.name == 'withYouTubeInline'); }); @@ -803,23 +803,23 @@ void main() { enumWithAnimation = exLibrary.enums.firstWhere((c) => c.name == 'EnumWithAnimation'); enumValue1 = - enumWithAnimation.constants.firstWhere((m) => m.name == 'value1'); + enumWithAnimation.constantFields.firstWhere((m) => m.name == 'value1'); enumValue2 = - enumWithAnimation.constants.firstWhere((m) => m.name == 'value2'); + enumWithAnimation.constantFields.firstWhere((m) => m.name == 'value2'); dog = exLibrary.classes.firstWhere((c) => c.name == 'Dog'); withAnimation = - dog.allInstanceMethods.firstWhere((m) => m.name == 'withAnimation'); - withNamedAnimation = dog.allInstanceMethods + dog.instanceMethods.firstWhere((m) => m.name == 'withAnimation'); + withNamedAnimation = dog.instanceMethods .firstWhere((m) => m.name == 'withNamedAnimation'); - withQuoteNamedAnimation = dog.allInstanceMethods + withQuoteNamedAnimation = dog.instanceMethods .firstWhere((m) => m.name == 'withQuotedNamedAnimation'); - withDeprecatedAnimation = dog.allInstanceMethods + withDeprecatedAnimation = dog.instanceMethods .firstWhere((m) => m.name == 'withDeprecatedAnimation'); - withAnimationInOneLineDoc = dog.allInstanceMethods + withAnimationInOneLineDoc = dog.instanceMethods .firstWhere((m) => m.name == 'withAnimationInOneLineDoc'); - withAnimationInline = dog.allInstanceMethods + withAnimationInline = dog.instanceMethods .firstWhere((m) => m.name == 'withAnimationInline'); - withAnimationOutOfOrder = dog.allInstanceMethods + withAnimationOutOfOrder = dog.instanceMethods .firstWhere((m) => m.name == 'withAnimationOutOfOrder'); }); @@ -896,11 +896,11 @@ void main() { ImplementingThingy2 = fakeLibrary.classes .firstWhere((c) => c.name == 'ImplementingThingy2'); - aImplementingThingy = ImplementingThingy2.allInstanceFields + aImplementingThingy = ImplementingThingy2.instanceFields .firstWhere((m) => m.name == 'aImplementingThingy'); - aImplementingThingyMethod = ImplementingThingy2.allInstanceMethods + aImplementingThingyMethod = ImplementingThingy2.instanceMethods .firstWhere((m) => m.name == 'aImplementingThingyMethod'); - aImplementingThingyField = ImplementingThingy2.allInstanceFields + aImplementingThingyField = ImplementingThingy2.instanceFields .firstWhere((m) => m.name == 'aImplementingThingyField'); aImplementingThingyAccessor = aImplementingThingyField.getter; }); @@ -1239,7 +1239,7 @@ void main() { test('oneLine doc references in inherited methods should not have brackets', () { var add = - specialList.allInstanceMethods.firstWhere((m) => m.name == 'add'); + specialList.instanceMethods.firstWhere((m) => m.name == 'add'); expect( add.oneLineDoc, equals( @@ -1250,7 +1250,7 @@ void main() { 'full documentation references from inherited methods should not have brackets', () { var add = - specialList.allInstanceMethods.firstWhere((m) => m.name == 'add'); + specialList.instanceMethods.firstWhere((m) => m.name == 'add'); expect( add.documentationAsHtml, startsWith( @@ -1336,7 +1336,7 @@ void main() { () { var notAMethodFromPrivateClass = fakeLibrary.allClasses .firstWhere((Class c) => c.name == 'ReferringClass') - .allPublicInstanceMethods + .publicInstanceMethods .firstWhere((Method m) => m.name == 'notAMethodFromPrivateClass'); expect( notAMethodFromPrivateClass.documentationAsHtml, @@ -1363,7 +1363,7 @@ void main() { }); test('doc comment inherited from getter', () { - var getterWithDocs = subForDocComments.instanceProperties + var getterWithDocs = subForDocComments.instanceFields .firstWhere((m) => m.name == 'getterWithDocs'); expect(getterWithDocs.documentationAsHtml, contains('Some really great topics.')); @@ -1372,7 +1372,7 @@ void main() { test( 'a property with no explicit getters and setters does not duplicate docs', () { - var powers = superAwesomeClass.instanceProperties + var powers = superAwesomeClass.instanceFields .firstWhere((p) => p.name == 'powers'); Iterable matches = RegExp('In the super class').allMatches(powers.documentationAsHtml); @@ -1412,7 +1412,7 @@ void main() { .allClasses .firstWhere((c) => c.name == 'GadgetExtender'); var gadgetGetter = - GadgetExtender.allFields.firstWhere((f) => f.name == 'gadgetGetter'); + GadgetExtender.instanceFields.firstWhere((f) => f.name == 'gadgetGetter'); expect(gadgetGetter.isCanonical, isTrue); }); @@ -1446,13 +1446,13 @@ void main() { fakeLibrary.publicMixins.firstWhere((m) => m.name == 'GenericMixin'); TypeInferenceMixedIn = classes.firstWhere((c) => c.name == 'TypeInferenceMixedIn'); - overrideByEverything = TypeInferenceMixedIn.allInstanceFields + overrideByEverything = TypeInferenceMixedIn.instanceFields .firstWhere((f) => f.name == 'overrideByEverything'); - overrideByGenericMixin = TypeInferenceMixedIn.allInstanceFields + overrideByGenericMixin = TypeInferenceMixedIn.instanceFields .firstWhere((f) => f.name == 'overrideByGenericMixin'); - overrideByBoth = TypeInferenceMixedIn.allInstanceFields + overrideByBoth = TypeInferenceMixedIn.instanceFields .firstWhere((f) => f.name == 'overrideByBoth'); - overrideByModifierClass = TypeInferenceMixedIn.allInstanceFields + overrideByModifierClass = TypeInferenceMixedIn.instanceFields .firstWhere((f) => f.name == 'overrideByModifierClass'); }); @@ -1489,11 +1489,11 @@ void main() { }); test(('Verify non-overridden members have right canonical classes'), () { - var member = TypeInferenceMixedIn.allInstanceFields + var member = TypeInferenceMixedIn.instanceFields .firstWhere((f) => f.name == 'member'); - var modifierMember = TypeInferenceMixedIn.allInstanceFields + var modifierMember = TypeInferenceMixedIn.instanceFields .firstWhere((f) => f.name == 'modifierMember'); - var mixinMember = TypeInferenceMixedIn.allInstanceFields + var mixinMember = TypeInferenceMixedIn.instanceFields .firstWhere((f) => f.name == 'mixinMember'); expect(member.canonicalEnclosingContainer, equals(GenericClass)); expect(modifierMember.canonicalEnclosingContainer, equals(ModifierClass)); @@ -1510,22 +1510,22 @@ void main() { equals(ModifierClass)); expect( overrideByEverything.documentationFrom.first, - equals(GenericClass.allInstanceFields + equals(GenericClass.instanceFields .firstWhere((f) => f.name == 'overrideByEverything') .getter)); expect( overrideByGenericMixin.documentationFrom.first, - equals(GenericClass.allInstanceFields + equals(GenericClass.instanceFields .firstWhere((f) => f.name == 'overrideByGenericMixin') .getter)); expect( overrideByBoth.documentationFrom.first, - equals(GenericClass.allInstanceFields + equals(GenericClass.instanceFields .firstWhere((f) => f.name == 'overrideByBoth') .getter)); expect( overrideByModifierClass.documentationFrom.first, - equals(GenericClass.allInstanceFields + equals(GenericClass.instanceFields .firstWhere((f) => f.name == 'overrideByModifierClass') .getter)); }); @@ -1604,10 +1604,10 @@ void main() { }); test('a class with only inherited properties has some properties', () { - expect(CatString.hasInstanceProperties, isFalse); - expect(CatString.instanceProperties, isEmpty); - expect(CatString.hasPublicProperties, isTrue); - expect(CatString.allInstanceFields, isNotEmpty); + expect(CatString.hasInstanceFields, isFalse); + expect(CatString.instanceFields, isEmpty); + expect(CatString.hasPublicInstanceFields, isTrue); + expect(CatString.instanceFields, isNotEmpty); }); test('has enclosing element', () { @@ -1661,7 +1661,7 @@ void main() { }); test('get static fields', () { - expect(Apple.publicStaticProperties, hasLength(1)); + expect(Apple.publicStaticFields, hasLength(1)); }); test('constructors have source', () { @@ -1670,17 +1670,17 @@ void main() { }); test('get constants', () { - expect(Apple.publicConstants, hasLength(1)); - expect(Apple.publicConstants.first.kind, equals('constant')); + expect(Apple.publicConstantFields, hasLength(1)); + expect(Apple.publicConstantFields.first.kind, equals('constant')); }); test('get instance fields', () { - expect(Apple.publicInstanceProperties, hasLength(3)); - expect(Apple.publicInstanceProperties.first.kind, equals('property')); + expect(Apple.publicInstanceFields, hasLength(3)); + expect(Apple.publicInstanceFields.first.kind, equals('property')); }); test('get inherited properties, including properties of Object', () { - expect(B.publicInheritedProperties, hasLength(4)); + expect(B.publicFieldsInherited, hasLength(4)); }); test('get methods', () { @@ -1688,8 +1688,8 @@ void main() { }); test('get operators', () { - expect(Dog.publicOperators, hasLength(1)); - expect(Dog.publicOperators.first.name, 'operator =='); + expect(Dog.publicInstanceOperators, hasLength(1)); + expect(Dog.publicInstanceOperators.first.name, 'operator =='); }); test('inherited methods, including from Object ', () { @@ -1698,9 +1698,9 @@ void main() { }); test('all instance methods', () { - expect(B.allPublicInstanceMethods, isNotEmpty); + expect(B.publicInstanceMethods, isNotEmpty); expect( - B.allPublicInstanceMethods.length, + B.publicInstanceMethods.length, equals(B.publicInstanceMethods.length + B.publicInheritedMethods.length)); }); @@ -1715,9 +1715,9 @@ void main() { test('exported class should have hrefs from the current library', () { expect( Dep.href, equals('${HTMLBASE_PLACEHOLDER}ex/Deprecated-class.html')); - expect(Dep.instanceMethods[0].href, + expect(Dep.instanceMethods.firstWhere((m) => m.name == 'toString').href, equals('${HTMLBASE_PLACEHOLDER}ex/Deprecated/toString.html')); - expect(Dep.instanceProperties[0].href, + expect(Dep.instanceFields.firstWhere((m) => m.name == 'expires').href, equals('${HTMLBASE_PLACEHOLDER}ex/Deprecated/expires.html')); }); @@ -1770,13 +1770,13 @@ void main() { }); test('F has zero instance properties', () { - expect(F.publicInstanceProperties, hasLength(0)); + expect(F.publicInstanceFields, hasLength(0)); }); test('F has a few inherited properties', () { - expect(F.publicInheritedProperties, hasLength(10)); + expect(F.publicFieldsInherited, hasLength(10)); expect( - F.publicInheritedProperties.map((ip) => ip.name), + F.publicFieldsInherited.map((ip) => ip.name), containsAll([ 'aFinalField', 'aGetterReturningRandomThings', @@ -1868,7 +1868,7 @@ void main() { fancyList = exLibrary.extensions.firstWhere((e) => e.name == 'FancyList'); doSomeStuff = exLibrary.classes .firstWhere((c) => c.name == 'ExtensionUser') - .allInstanceMethods + .instanceMethods .firstWhere((m) => m.name == 'doSomeStuff'); doStuff = exLibrary.extensions .firstWhere((e) => e.name == 'SimpleStringExtension') @@ -2050,11 +2050,11 @@ void main() { }); test('get methods', () { - expect(fancyList.allPublicInstanceMethods, hasLength(1)); + expect(fancyList.publicInstanceMethods, hasLength(1)); }); test('get operators', () { - expect(fancyList.allPublicOperators, hasLength(1)); + expect(fancyList.publicInstanceOperators, hasLength(1)); }); test('get static methods', () { @@ -2062,11 +2062,11 @@ void main() { }); test('get properties', () { - expect(fancyList.publicInstanceProperties, hasLength(1)); + expect(fancyList.publicInstanceFields, hasLength(1)); }); test('get contants', () { - expect(fancyList.publicConstants, hasLength(0)); + expect(fancyList.publicConstantFields, hasLength(0)); }); test('correctly finds all the extensions', () { @@ -2085,7 +2085,7 @@ void main() { setUpAll(() { animal = exLibrary.enums.firstWhere((e) => e.name == 'Animal'); animalToString = - animal.allInstanceMethods.firstWhere((m) => m.name == 'toString'); + animal.instanceMethods.firstWhere((m) => m.name == 'toString'); /// Trigger code reference resolution animal.documentationAsHtml; @@ -2106,11 +2106,11 @@ void main() { }); test('has correct number of constants', () { - expect(animal.constants, hasLength(4)); + expect(animal.constantFields, hasLength(4)); }); test('has a (synthetic) values constant', () { - var valuesField = animal.constants.firstWhere((f) => f.name == 'values'); + var valuesField = animal.constantFields.firstWhere((f) => f.name == 'values'); expect(valuesField, isNotNull); expect(valuesField.constantValue, equals(EnumFieldRendererHtml().renderValue(valuesField))); @@ -2118,7 +2118,7 @@ void main() { }); test('has a constant that does not link anywhere', () { - var dog = animal.constants.firstWhere((f) => f.name == 'DOG'); + var dog = animal.constantFields.firstWhere((f) => f.name == 'DOG'); expect(dog.linkedName, equals('DOG')); expect(dog.isConst, isTrue); expect( @@ -2128,7 +2128,7 @@ void main() { test('constants have correct indicies', () { String valueByName(var name) { - return animal.constants.firstWhere((f) => f.name == name).constantValue; + return animal.constantFields.firstWhere((f) => f.name == name).constantValue; } expect(valueByName('CAT'), equals('const Animal(0)')); @@ -2137,13 +2137,13 @@ void main() { }); test('has a single `index` property', () { - expect(animal.instanceProperties, hasLength(1)); - expect(animal.instanceProperties.first, isNotNull); - expect(animal.instanceProperties.first.name, equals('index')); + expect(animal.instanceFields, hasLength(1)); + expect(animal.instanceFields.first, isNotNull); + expect(animal.instanceFields.first.name, equals('index')); }); test('has a single `index` property that is not linked', () { - expect(animal.instanceProperties.first.linkedName, equals('index')); + expect(animal.instanceFields.first.linkedName, equals('index')); }); }); @@ -2321,7 +2321,7 @@ String topLevelFunction(int param1, bool param2, Cool coolBeans, }); test('setter that takes a function is correctly displayed', () { - var explicitSetter = ClassWithUnusualProperties.instanceProperties + var explicitSetter = ClassWithUnusualProperties.instanceFields .singleWhere((f) => f.name == 'explicitSetter'); // TODO(jcollins-g): really, these shouldn't be called "parameters" in // the span class. @@ -2330,14 +2330,14 @@ String topLevelFunction(int param1, bool param2, Cool coolBeans, }); test('parameterized type from field is correctly displayed', () { - var aField = TemplatedInterface.instanceProperties + var aField = TemplatedInterface.instanceFields .singleWhere((f) => f.name == 'aField'); expect(aField.linkedReturnType, 'AnotherParameterizedClass<Stream<List<int>>>'); }); test('parameterized type from inherited field is correctly displayed', () { - var aInheritedField = TemplatedInterface.inheritedProperties + var aInheritedField = TemplatedInterface.fieldsInherited .singleWhere((f) => f.name == 'aInheritedField'); expect(aInheritedField.linkedReturnType, 'AnotherParameterizedClass<List<int>>'); @@ -2346,7 +2346,7 @@ String topLevelFunction(int param1, bool param2, Cool coolBeans, test( 'parameterized type for return value from explicit getter is correctly displayed', () { - Accessor aGetter = TemplatedInterface.instanceProperties + Accessor aGetter = TemplatedInterface.instanceFields .singleWhere((f) => f.name == 'aGetter') .getter; expect(aGetter.linkedReturnType, @@ -2356,7 +2356,7 @@ String topLevelFunction(int param1, bool param2, Cool coolBeans, test( 'parameterized type for return value from inherited explicit getter is correctly displayed', () { - Accessor aInheritedGetter = TemplatedInterface.inheritedProperties + Accessor aInheritedGetter = TemplatedInterface.fieldsInherited .singleWhere((f) => f.name == 'aInheritedGetter') .getter; expect(aInheritedGetter.linkedReturnType, @@ -2366,7 +2366,7 @@ String topLevelFunction(int param1, bool param2, Cool coolBeans, test( 'parameterized type for return value from inherited explicit setter is correctly displayed', () { - Accessor aInheritedSetter = TemplatedInterface.inheritedProperties + Accessor aInheritedSetter = TemplatedInterface.fieldsInherited .singleWhere((f) => f.name == 'aInheritedSetter') .setter; expect(aInheritedSetter.allParameters.first.modelType.linkedName, @@ -2380,7 +2380,7 @@ String topLevelFunction(int param1, bool param2, Cool coolBeans, test( 'parameterized type for return value from method is correctly displayed', () { - var aMethodInterface = TemplatedInterface.allInstanceMethods + var aMethodInterface = TemplatedInterface.instanceMethods .singleWhere((m) => m.name == 'aMethodInterface'); expect(aMethodInterface.linkedReturnType, 'AnotherParameterizedClass<List<int>>'); @@ -2389,7 +2389,7 @@ String topLevelFunction(int param1, bool param2, Cool coolBeans, test( 'parameterized type for return value from inherited method is correctly displayed', () { - var aInheritedMethod = TemplatedInterface.allInstanceMethods + var aInheritedMethod = TemplatedInterface.instanceMethods .singleWhere((m) => m.name == 'aInheritedMethod'); expect(aInheritedMethod.linkedReturnType, 'AnotherParameterizedClass<List<int>>'); @@ -2399,7 +2399,7 @@ String topLevelFunction(int param1, bool param2, Cool coolBeans, 'parameterized type for return value containing a parameterized typedef is correctly displayed', () { var aTypedefReturningMethodInterface = TemplatedInterface - .allInstanceMethods + .instanceMethods .singleWhere((m) => m.name == 'aTypedefReturningMethodInterface'); expect(aTypedefReturningMethodInterface.linkedReturnType, 'ParameterizedTypedef<List<String>>'); @@ -2409,7 +2409,7 @@ String topLevelFunction(int param1, bool param2, Cool coolBeans, 'parameterized type for return value containing a parameterized typedef from inherited method is correctly displayed', () { var aInheritedTypedefReturningMethod = TemplatedInterface - .allInstanceMethods + .instanceMethods .singleWhere((m) => m.name == 'aInheritedTypedefReturningMethod'); expect(aInheritedTypedefReturningMethod.linkedReturnType, 'ParameterizedTypedef<List<int>>'); @@ -2508,7 +2508,7 @@ String topLevelFunction(int param1, bool param2, Cool coolBeans, }); test('returns correct overriddenDepth', () { - final bAbstractMethod = classB.allInstanceMethods + final bAbstractMethod = classB.instanceMethods .firstWhere((m) => m.name == 'abstractMethod'); expect(abstractMethod.overriddenDepth, equals(0)); expect(bAbstractMethod.overriddenDepth, equals(1)); @@ -2611,11 +2611,11 @@ String topLevelFunction(int param1, bool param2, Cool coolBeans, setUpAll(() { specializedDuration = exLibrary.classes.firstWhere((c) => c.name == 'SpecializedDuration'); - plus = specializedDuration.allOperators + plus = specializedDuration.instanceOperators .firstWhere((o) => o.name == 'operator +'); equalsOverride = exLibrary.classes .firstWhere((c) => c.name == 'Dog') - .allOperators + .instanceOperators .firstWhere((o) => o.name == 'operator =='); }); @@ -2674,9 +2674,9 @@ String topLevelFunction(int param1, bool param2, Cool coolBeans, setUpAll(() { c = exLibrary.classes.firstWhere((c) => c.name == 'Apple'); - f1 = c.staticProperties[0]; // n - f2 = c.instanceProperties[0]; - constField = c.constants[0]; // string + f1 = c.staticFields.first; // n + f2 = c.instanceFields.first; + constField = c.constantFields.first; // string LongFirstLine = fakeLibrary.classes.firstWhere((c) => c.name == 'LongFirstLine'); CatString = exLibrary.classes.firstWhere((c) => c.name == 'CatString'); @@ -2698,48 +2698,48 @@ String topLevelFunction(int param1, bool param2, Cool coolBeans, .firstWhere((e) => e.name == 'finalProperty'); isEmpty = - CatString.allInstanceFields.firstWhere((p) => p.name == 'isEmpty'); - dynamicGetter = LongFirstLine.instanceProperties + CatString.instanceFields.firstWhere((p) => p.name == 'isEmpty'); + dynamicGetter = LongFirstLine.instanceFields .firstWhere((p) => p.name == 'dynamicGetter'); - onlySetter = LongFirstLine.instanceProperties + onlySetter = LongFirstLine.instanceFields .firstWhere((p) => p.name == 'onlySetter'); lengthX = fakeLibrary.classes .firstWhere((c) => c.name == 'WithGetterAndSetter') - .allInstanceFields + .instanceFields .firstWhere((c) => c.name == 'lengthX'); var appleClass = exLibrary.allClasses.firstWhere((c) => c.name == 'Apple'); sFromApple = - appleClass.allInstanceFields.firstWhere((p) => p.name == 's'); + appleClass.instanceFields.firstWhere((p) => p.name == 's'); mFromApple = - appleClass.allInstanceFields.singleWhere((p) => p.name == 'm'); + appleClass.instanceFields.singleWhere((p) => p.name == 'm'); mInB = exLibrary.allClasses .firstWhere((c) => c.name == 'B') - .allInstanceFields + .instanceFields .firstWhere((p) => p.name == 'm'); autoCompress = exLibrary.allClasses .firstWhere((c) => c.name == 'B') - .allInstanceFields + .instanceFields .firstWhere((p) => p.name == 'autoCompress'); ExtraSpecialListLength = fakeLibrary.classes .firstWhere((c) => c.name == 'SpecialList') - .allInstanceFields + .instanceFields .firstWhere((f) => f.name == 'length'); aProperty = fakeLibrary.classes .firstWhere((c) => c.name == 'AClassWithFancyProperties') - .allInstanceFields + .instanceFields .firstWhere((f) => f.name == 'aProperty'); covariantField = fakeLibrary.classes .firstWhere((c) => c.name == 'CovariantMemberParams') - .allInstanceFields + .instanceFields .firstWhere((f) => f.name == 'covariantField'); covariantSetter = fakeLibrary.classes .firstWhere((c) => c.name == 'CovariantMemberParams') - .allInstanceFields + .instanceFields .firstWhere((f) => f.name == 'covariantSetter'); }); @@ -2996,7 +2996,7 @@ String topLevelFunction(int param1, bool param2, Cool coolBeans, var withGenericSub = exLibrary.classes.firstWhere((c) => c.name == 'WithGenericSub'); expect( - withGenericSub.inheritedProperties + withGenericSub.fieldsInherited .where((p) => p.name == 'prop') .length, equals(1)); @@ -3032,7 +3032,7 @@ String topLevelFunction(int param1, bool param2, Cool coolBeans, }); test('if overridden, gets documentation from superclasses', () { - final doc = classB.allInstanceFields + final doc = classB.instanceFields .firstWhere((p) => p.name == 's') .getter .documentation; @@ -3043,7 +3043,7 @@ String topLevelFunction(int param1, bool param2, Cool coolBeans, 'has correct linked return type if the return type is a parameterized typedef', () { var apple = exLibrary.classes.firstWhere((c) => c.name == 'Apple'); - final fieldWithTypedef = apple.allInstanceFields + final fieldWithTypedef = apple.instanceFields .firstWhere((m) => m.name == 'fieldWithTypedef'); expect( fieldWithTypedef.linkedReturnType, @@ -3225,8 +3225,8 @@ String topLevelFunction(int param1, bool param2, Cool coolBeans, customClassPrivate = fakeLibrary.constants .firstWhere((c) => c.name == 'CUSTOM_CLASS_PRIVATE'); aStaticConstField = - Dog.constants.firstWhere((f) => f.name == 'aStaticConstField'); - aName = Dog.constants.firstWhere((f) => f.name == 'aName'); + Dog.constantFields.firstWhere((f) => f.name == 'aStaticConstField'); + aName = Dog.constantFields.firstWhere((f) => f.name == 'aName'); }); test('substrings of the constant values type are not linked (#1535)', () { @@ -3298,7 +3298,7 @@ String topLevelFunction(int param1, bool param2, Cool coolBeans, constCat = exLibrary.classes.firstWhere((c) => c.name == 'ConstantCat'); constructorTester = fakeLibrary.classes.firstWhere((c) => c.name == 'ConstructorTester'); - constCatConstructor = constCat.constructors[0]; + constCatConstructor = constCat.constructors.first; appleDefaultConstructor = apple.constructors.firstWhere((c) => c.name == 'Apple'); appleConstructorFromString = @@ -3455,7 +3455,7 @@ String topLevelFunction(int param1, bool param2, Cool coolBeans, setUpAll(() { fList = exLibrary.classes .firstWhere((c) => c.name == 'B') - .instanceProperties + .instanceFields .singleWhere((p) => p.name == 'list'); }); @@ -3574,7 +3574,7 @@ String topLevelFunction(int param1, bool param2, Cool coolBeans, c = exLibrary.classes.firstWhere((c) => c.name == 'Apple'); CovariantMemberParams = fakeLibrary.classes .firstWhere((c) => c.name == 'CovariantMemberParams'); - applyCovariantParams = CovariantMemberParams.allInstanceMethods + applyCovariantParams = CovariantMemberParams.instanceMethods .firstWhere((m) => m.name == 'applyCovariantParams'); paramFromExportLib = c.instanceMethods.singleWhere((m) => m.name == 'paramFromExportLib'); From 623c3d1036cb44189398049e883f183608a60bc8 Mon Sep 17 00:00:00 2001 From: Janice Collins Date: Fri, 8 May 2020 15:17:14 -0700 Subject: [PATCH 2/6] tests pass, ship it --- lib/src/generator/generator_frontend.dart | 12 +- lib/src/markdown_processor.dart | 3 +- lib/src/model/class.dart | 47 +++-- lib/src/model/container.dart | 113 +++++++----- lib/src/model/extension_target.dart | 3 +- lib/src/model/library.dart | 3 +- lib/templates/html/_sidebar_for_class.html | 10 +- .../html/_sidebar_for_container.html | 14 +- lib/templates/html/_sidebar_for_enum.html | 10 +- .../html/_sidebar_for_extension.html | 4 +- lib/templates/html/class.html | 10 +- lib/templates/html/enum.html | 10 +- lib/templates/html/extension.html | 4 +- lib/templates/html/mixin.html | 6 +- test/dartdoc_test.dart | 4 + test/model_test.dart | 137 +++++++------- testing/test_package/lib/example.dart | 1 + .../templates/404error.html | 24 ++- .../templates/_accessor_getter.html | 13 ++ .../templates/_accessor_setter.html | 13 ++ .../templates/_callable.html | 10 + .../templates/_callable_multiline.html | 11 ++ .../templates/_categorization.html | 5 + .../templates/_class.html | 6 + .../templates/_constant.html | 12 ++ .../templates/_documentation.html | 2 +- .../templates/_extension.html | 7 + .../templates/_features.html | 1 + .../templates/_footer.html | 19 +- .../templates/_head.html | 51 +++++- .../templates/_library.html | 6 + .../templates/_mixin.html | 6 + .../templates/_name_summary.html | 1 + .../templates/_packages.html | 25 +++ .../templates/_property.html | 8 + .../templates/_search_sidebar.html | 21 +++ .../templates/_sidebar_for_category.html | 64 +++++++ .../templates/_sidebar_for_class.html | 56 ++++++ .../templates/_sidebar_for_container.html | 103 +++++++++++ .../templates/_sidebar_for_enum.html | 54 ++++++ .../templates/_sidebar_for_extension.html | 48 +++++ .../templates/_sidebar_for_library.html | 66 +++++++ .../templates/_source_code.html | 5 + .../templates/_source_link.html | 3 + .../templates/category.html | 129 ++++++++++++- .../templates/class.html | 170 +++++++++++++++-- .../templates/constant.html | 26 ++- .../templates/constructor.html | 32 +++- .../templates/enum.html | 163 ++++++++++++++++- .../templates/extension.html | 60 +++--- .../templates/function.html | 21 ++- .../templates/index.html | 25 +-- .../templates/library.html | 121 ++++++++++-- .../templates/method.html | 22 ++- .../templates/mixin.html | 172 +++++++++++++++++- .../templates/property.html | 25 ++- .../templates/top_level_constant.html | 25 ++- .../templates/top_level_property.html | 25 ++- .../templates/typedef.html | 22 ++- 59 files changed, 1762 insertions(+), 307 deletions(-) create mode 100644 testing/test_package_custom_templates/templates/_accessor_getter.html create mode 100644 testing/test_package_custom_templates/templates/_accessor_setter.html create mode 100644 testing/test_package_custom_templates/templates/_callable.html create mode 100644 testing/test_package_custom_templates/templates/_callable_multiline.html create mode 100644 testing/test_package_custom_templates/templates/_categorization.html create mode 100644 testing/test_package_custom_templates/templates/_class.html create mode 100644 testing/test_package_custom_templates/templates/_constant.html create mode 100644 testing/test_package_custom_templates/templates/_extension.html create mode 100644 testing/test_package_custom_templates/templates/_features.html create mode 100644 testing/test_package_custom_templates/templates/_library.html create mode 100644 testing/test_package_custom_templates/templates/_mixin.html create mode 100644 testing/test_package_custom_templates/templates/_name_summary.html create mode 100644 testing/test_package_custom_templates/templates/_packages.html create mode 100644 testing/test_package_custom_templates/templates/_property.html create mode 100644 testing/test_package_custom_templates/templates/_search_sidebar.html create mode 100644 testing/test_package_custom_templates/templates/_sidebar_for_category.html create mode 100644 testing/test_package_custom_templates/templates/_sidebar_for_class.html create mode 100644 testing/test_package_custom_templates/templates/_sidebar_for_container.html create mode 100644 testing/test_package_custom_templates/templates/_sidebar_for_enum.html create mode 100644 testing/test_package_custom_templates/templates/_sidebar_for_extension.html create mode 100644 testing/test_package_custom_templates/templates/_sidebar_for_library.html create mode 100644 testing/test_package_custom_templates/templates/_source_code.html create mode 100644 testing/test_package_custom_templates/templates/_source_link.html diff --git a/lib/src/generator/generator_frontend.dart b/lib/src/generator/generator_frontend.dart index 48e8b27653..7ca0af9ebb 100644 --- a/lib/src/generator/generator_frontend.dart +++ b/lib/src/generator/generator_frontend.dart @@ -76,7 +76,8 @@ class GeneratorFrontEnd implements Generator { writer, packageGraph, lib, clazz, constant); } - for (var property in filterNonDocumented(clazz.staticFields)) { + for (var property + in filterNonDocumented(clazz.variableStaticFields)) { if (!property.isCanonical) continue; indexAccumulator.add(property); @@ -135,14 +136,14 @@ class GeneratorFrontEnd implements Generator { writer, packageGraph, lib, extension, method); } - for (var operator in filterNonDocumented(extension.instanceOperators)) { + for (var operator + in filterNonDocumented(extension.instanceOperators)) { indexAccumulator.add(operator); _generatorBackend.generateMethod( writer, packageGraph, lib, extension, operator); } - for (var property - in filterNonDocumented(extension.instanceFields)) { + for (var property in filterNonDocumented(extension.instanceFields)) { indexAccumulator.add(property); _generatorBackend.generateProperty( writer, packageGraph, lib, extension, property); @@ -168,7 +169,8 @@ class GeneratorFrontEnd implements Generator { writer, packageGraph, lib, mixin, constant); } - for (var property in filterNonDocumented(mixin.staticFields)) { + for (var property + in filterNonDocumented(mixin.variableStaticFields)) { if (!property.isCanonical) continue; indexAccumulator.add(property); diff --git a/lib/src/markdown_processor.dart b/lib/src/markdown_processor.dart index 977782eda5..278e14c521 100644 --- a/lib/src/markdown_processor.dart +++ b/lib/src/markdown_processor.dart @@ -551,7 +551,8 @@ class _MarkdownCommentReference { for (final modelElement in packageGraph.findRefElementCache[maybeEnumName]) { if (modelElement is Enum) { - if (modelElement.constantFields.any((e) => e.name == maybeEnumMember)) { + if (modelElement.constantFields + .any((e) => e.name == maybeEnumMember)) { results.add(modelElement); break; } diff --git a/lib/src/model/class.dart b/lib/src/model/class.dart index 35ff57ea77..c33957387f 100644 --- a/lib/src/model/class.dart +++ b/lib/src/model/class.dart @@ -10,7 +10,6 @@ import 'package:dartdoc/src/model/model.dart'; import 'package:dartdoc/src/model_utils.dart' as model_utils; import 'package:quiver/iterables.dart' as quiver; - /// A [Container] defined with a `class` declaration in Dart. /// /// Members follow similar naming rules to [Container], with the following @@ -26,7 +25,6 @@ class Class extends Container List _interfaces; List _inheritedOperators; List _inheritedMethods; - List _inheritedFields; Class(ClassElement element, Library library, PackageGraph packageGraph) : super(element, library, packageGraph) { @@ -62,14 +60,13 @@ class Class extends Container Iterable get instanceMethods => quiver.concat([super.instanceMethods, inheritedMethods]); - bool get publicInstanceMethodsInherited => + bool get publicInheritedInstanceMethods => instanceMethods.every((f) => f.isInherited); @override Iterable get instanceOperators => quiver.concat([super.instanceOperators, inheritedOperators]); - List _allModelElements; @override List get allModelElements { @@ -91,8 +88,8 @@ class Class extends Container } Iterable get constructors => element.constructors.map((e) { - return ModelElement.from(e, library, packageGraph) as Constructor; - }); + return ModelElement.from(e, library, packageGraph) as Constructor; + }); Iterable get publicConstructors => model_utils.filterNonPublic(constructors); @@ -118,7 +115,8 @@ class Class extends Container bool get hasPublicConstructors => publicConstructorsSorted.isNotEmpty; List _publicConstructorsSorted; - List get publicConstructorsSorted => _publicConstructorsSorted ??= publicConstructors.toList()..sort(byName); + List get publicConstructorsSorted => + _publicConstructorsSorted ??= publicConstructors.toList()..sort(byName); bool get hasPublicImplementors => publicImplementors.isNotEmpty; @@ -198,14 +196,13 @@ class Class extends Container return _inheritedOperators; } - Iterable get publicInstanceOperatorsInherited => + Iterable get publicInheritedInstanceOperators => model_utils.filterNonPublic(inheritedOperators); - Iterable get fieldsInherited => - _inheritedFields ??= allFields.where((f) => f.isInherited); + Iterable get inheritedFields => allFields.where((f) => f.isInherited); - Iterable get publicFieldsInherited => - model_utils.filterNonPublic(fieldsInherited); + Iterable get publicInheritedFields => + model_utils.filterNonPublic(inheritedFields); List get interfaces => _interfaces; @@ -344,8 +341,6 @@ class Class extends Container // to the [FieldElement]. Compose our [Field] class by hand by looking up // inherited accessors that may be related. for (var f in element.fields) { - if (name == 'Animal') - print('hmm'); var getterElement = f.getter; if (getterElement == null && accessorMap.containsKey(f.name)) { getterElement = accessorMap[f.name] @@ -356,7 +351,8 @@ class Class extends Container setterElement = accessorMap[f.name] .firstWhere((e) => e.isSetter, orElse: () => null); } - _addSingleField(getterElement, setterElement, inheritedAccessorElements, f); + _addSingleField( + getterElement, setterElement, inheritedAccessorElements, f); accessorMap.remove(f.name); } @@ -368,9 +364,9 @@ class Class extends Container elements.firstWhere((e) => e.isGetter, orElse: () => null); var setterElement = elements.firstWhere((e) => e.isSetter, orElse: () => null); - _addSingleField(getterElement, setterElement, inheritedAccessorElements); + _addSingleField( + getterElement, setterElement, inheritedAccessorElements); } - } return _allFields; } @@ -410,8 +406,9 @@ class Class extends Container // different places in the inheritance chain, there are two FieldElements // for this single Field we're trying to compose. Pick the one closest // to this class on the inheritance chain. - if (setter.enclosingElement is Class && (setter.enclosingElement as Class) - .isInheritingFrom(getter.enclosingElement)) { + if (setter.enclosingElement is Class && + (setter.enclosingElement as Class) + .isInheritingFrom(getter.enclosingElement)) { f = setterElement.variable; } else { f = getterElement.variable; @@ -437,13 +434,11 @@ class Class extends Container List _declaredMethods; @override - Iterable get declaredMethods => _declaredMethods ??= - element.methods.map((e) { + Iterable get declaredMethods => + _declaredMethods ??= element.methods.map((e) { return ModelElement.from(e, library, packageGraph) as Method; }).toList(growable: false); - - List _typeParameters; // a stronger hash? @override @@ -457,10 +452,10 @@ class Class extends Container Iterable _instanceFields; @override - Iterable get instanceFields => _instanceFields ??= allFields - .where((f) => !f.isStatic); + Iterable get instanceFields => + _instanceFields ??= allFields.where((f) => !f.isStatic); - bool get publicInstanceFieldsInherited => + bool get publicInheritedInstanceFields => publicInstanceFields.every((f) => f.isInherited); @override diff --git a/lib/src/model/container.dart b/lib/src/model/container.dart index 8fbf6e5e57..51522386af 100644 --- a/lib/src/model/container.dart +++ b/lib/src/model/container.dart @@ -14,11 +14,10 @@ import 'package:quiver/iterables.dart' as quiver; /// Member naming in [Container] follows these general rules: /// /// **instance** : Members named 'instance' contain the children of this -/// container that can be referenced from within the container without a prefix -/// and are not statics. +/// container that can be referenced from within the container without a prefix. /// Usually overridden in subclasses with calls to super. /// **constant** : Members named 'constant' contain children declared constant. -/// **variable** : Members names 'variable' contain children not declared constant. +/// **variable** : The opposite of constant. For the templating system. /// **static** : Members named 'static' are related to static children of this /// container. /// **public** : Filtered versions of the getters showing only public items. @@ -37,14 +36,14 @@ abstract class Container extends ModelElement { @mustCallSuper Iterable get allModelElements => quiver.concat([ - instanceMethods, - instanceFields, - instanceOperators, - instanceAccessors, - staticFields, - staticAccessors, - staticMethods, - ]); + instanceMethods, + instanceFields, + instanceOperators, + instanceAccessors, + staticFields, + staticAccessors, + staticMethods, + ]); /// All methods, including operators and statics, declared as part of this /// [Container]. [declaredMethods] must be the union of [instanceMethods], @@ -52,53 +51,51 @@ abstract class Container extends ModelElement { /// Iterable get declaredMethods; - /// All methods declared as part of this [Container] that are [staticMethods] - /// or [operators]. - /// - /// Subclasses may extend this with inheritance or extensions. Iterable get instanceMethods => declaredMethods - .where((m) => !m.isStatic && !m.isOperator) - .toList(growable: false); - - @Deprecated('Use instanceMethods instead') - Iterable get allInstanceMethods => instanceMethods; + .where((m) => !m.isStatic && !m.isOperator) + .toList(growable: false); @nonVirtual bool get hasPublicInstanceMethods => model_utils.filterNonPublic(instanceMethods).isNotEmpty; - - Iterable get publicInstanceMethods => model_utils.filterNonPublic(instanceMethods); + Iterable get publicInstanceMethods => + model_utils.filterNonPublic(instanceMethods); List _publicInstanceMethodsSorted; - List get publicInstanceMethodsSorted => _publicInstanceMethodsSorted ?? publicInstanceMethods.toList()..sort(byName); + List get publicInstanceMethodsSorted => + _publicInstanceMethodsSorted ?? publicInstanceMethods.toList() + ..sort(byName); Iterable _declaredOperators; @nonVirtual Iterable get declaredOperators { - _declaredOperators ??= declaredMethods - .whereType() - .toList(growable: false); + _declaredOperators ??= + declaredMethods.whereType().toList(growable: false); return _declaredOperators; } Iterable get instanceOperators => declaredOperators; @nonVirtual - bool get hasPublicInstanceOperators => publicInstanceOperatorsSorted.isNotEmpty; + bool get hasPublicInstanceOperators => + publicInstanceOperatorsSorted.isNotEmpty; @nonVirtual Iterable get publicInstanceOperators => model_utils.filterNonPublic(instanceOperators); List _publicInstanceOperatorsSorted; - List get publicInstanceOperatorsSorted => _publicInstanceOperatorsSorted ??= publicInstanceOperators.toList()..sort(byName); + List get publicInstanceOperatorsSorted => + _publicInstanceOperatorsSorted ??= publicInstanceOperators.toList() + ..sort(byName); /// Fields fully declared in this [Container]. Iterable get declaredFields; /// All fields accessible in this instance that are not static. - Iterable get instanceFields => declaredFields.where((f) => !f.isStatic); + Iterable get instanceFields => + declaredFields.where((f) => !f.isStatic); bool get hasInstanceFields => instanceFields.isNotEmpty; @@ -109,33 +106,40 @@ abstract class Container extends ModelElement { @nonVirtual bool get hasPublicInstanceFields => publicInstanceFields.isNotEmpty; - List _publicInstanceFieldsSorted; - List get publicInstanceFieldsSorted => _publicInstanceFieldsSorted ??= publicInstanceFields.toList()..sort(byName); + List get publicInstanceFieldsSorted => _publicInstanceFieldsSorted ??= + publicInstanceFields.toList()..sort(byName); Iterable get constantFields => declaredFields.where((f) => f.isConst); - Iterable get publicConstantFields => model_utils.filterNonPublic(constantFields); + Iterable get publicConstantFields => + model_utils.filterNonPublic(constantFields); bool get hasPublicConstantFields => publicConstantFieldsSorted.isNotEmpty; List _publicConstantFieldsSorted; - List get publicConstantFieldsSorted => _publicConstantFieldsSorted ??= publicConstantFields.toList()..sort(byName); + List get publicConstantFieldsSorted => _publicConstantFieldsSorted ??= + publicConstantFields.toList()..sort(byName); - Iterable get instanceAccessors => instanceFields.expand((f) => f.allAccessors); + Iterable get instanceAccessors => + instanceFields.expand((f) => f.allAccessors); - Iterable get constantAccessors => constantFields.expand((f) => f.allAccessors); + Iterable get constantAccessors => + constantFields.expand((f) => f.allAccessors); - Iterable get staticAccessors => staticFields.expand((f) => f.allAccessors); + Iterable get staticAccessors => + staticFields.expand((f) => f.allAccessors); /// This container might be canonical for elements it does not contain. /// See [Inheritable.canonicalEnclosingContainer]. bool containsElement(Element element) => allElements.contains(element); Set _allElements; - Set get allElements => _allElements ??= allModelElements.map((e) => e.element).toSet(); + Set get allElements => + _allElements ??= allModelElements.map((e) => e.element).toSet(); Map> _membersByName; + /// Given a ModelElement that is a member of some other class, return /// a member of this class that has the same name and return type. /// @@ -156,7 +160,7 @@ abstract class Container extends ModelElement { .where((e) => e.runtimeType == example.runtimeType); if (example.runtimeType == Accessor) { possibleMembers = possibleMembers.where( - (e) => (example as Accessor).isGetter == (e as Accessor).isGetter); + (e) => (example as Accessor).isGetter == (e as Accessor).isGetter); } member = possibleMembers.first; assert(possibleMembers.length == 1); @@ -164,6 +168,7 @@ abstract class Container extends ModelElement { } Map> _allModelElementsByNamePart; + /// Helper for `_MarkdownCommentReference._getResultsForClass`. Map> get allModelElementsByNamePart { if (_allModelElementsByNamePart == null) { @@ -183,19 +188,35 @@ abstract class Container extends ModelElement { model_utils.filterNonPublic(staticFields); List _publicStaticFieldsSorted; - List get publicStaticFieldsSorted => _publicStaticFieldsSorted ??= publicStaticFields.toList()..sort(byName); + List get publicStaticFieldsSorted => + _publicStaticFieldsSorted ??= publicStaticFields.toList()..sort(byName); - Iterable _staticFields; - Iterable get staticFields => _staticFields ??= declaredFields - .where((f) => f.isStatic); + Iterable get staticFields => declaredFields.where((f) => f.isStatic); - Iterable _staticMethods; - Iterable get staticMethods => _staticMethods ??= - instanceMethods.where((m) => m.isStatic); + Iterable get variableStaticFields => + staticFields.where((f) => !f.isConst); + + bool get hasPublicVariableStaticFields => + publicVariableStaticFieldsSorted.isEmpty; + + Iterable get publicVariableStaticFields => + model_utils.filterNonPublic(variableStaticFields); + + List _publicVariableStaticFieldsSorted; + List get publicVariableStaticFieldsSorted => + _publicVariableStaticFieldsSorted ??= publicVariableStaticFields.toList() + ..sort(byName); + + Iterable get staticMethods => + declaredMethods.where((m) => m.isStatic); bool get hasPublicStaticMethods => - model_utils.filterNonPublic(staticMethods).isNotEmpty; + model_utils.filterNonPublic(publicStaticMethodsSorted).isNotEmpty; Iterable get publicStaticMethods => model_utils.filterNonPublic(staticMethods); + + List _publicStaticMethodsSorted; + List get publicStaticMethodsSorted => + _publicStaticMethodsSorted ??= publicStaticMethods.toList()..sort(byName); } diff --git a/lib/src/model/extension_target.dart b/lib/src/model/extension_target.dart index 72e4704792..19f5cc11e1 100644 --- a/lib/src/model/extension_target.dart +++ b/lib/src/model/extension_target.dart @@ -27,5 +27,6 @@ mixin ExtensionTarget on ModelElement { return _potentiallyApplicableExtensions; } - List get potentiallyApplicableExtensionsSorted => potentiallyApplicableExtensions.toList()..sort(byName); + List get potentiallyApplicableExtensionsSorted => + potentiallyApplicableExtensions.toList()..sort(byName); } diff --git a/lib/src/model/library.dart b/lib/src/model/library.dart index e3882921b7..767598ee23 100644 --- a/lib/src/model/library.dart +++ b/lib/src/model/library.dart @@ -418,8 +418,7 @@ class Library extends ModelElement with Categorization, TopLevelContainer { return _nameFromPath; } - /// The real package, as opposed to the package we are documenting it with, - /// [PackageGraph.name] + /// The name of the package we were defined in. String get packageName => packageMeta?.name ?? ''; /// The real packageMeta, as opposed to the package we are documenting with. diff --git a/lib/templates/html/_sidebar_for_class.html b/lib/templates/html/_sidebar_for_class.html index 36e554f21b..2f0390ad64 100644 --- a/lib/templates/html/_sidebar_for_class.html +++ b/lib/templates/html/_sidebar_for_class.html @@ -9,7 +9,7 @@ {{/hasPublicConstructors}} {{#hasPublicInstanceFields}} -
  • +
  • Properties
  • {{#publicInstanceFieldsSorted}} @@ -18,14 +18,14 @@ {{/hasPublicInstanceFields}} {{#hasPublicInstanceMethods}} -
  • Methods
  • +
  • Methods
  • {{#publicInstanceMethodsSorted}} {{{ linkedName }}} {{/publicInstanceMethodsSorted}} {{/hasPublicInstanceMethods}} {{#hasPublicInstanceOperators}} -
  • Operators
  • +
  • Operators
  • {{#publicInstanceOperatorsSorted}} {{{ linkedName }}} {{/publicInstanceOperatorsSorted}} @@ -33,9 +33,9 @@ {{#hasPublicStaticFields}}
  • Static properties
  • - {{#publicStaticPropertiesSorted}} + {{#publicVariableStaticFieldsSorted}}
  • {{{ linkedName }}}
  • - {{/publicStaticPropertiesSorted}} + {{/publicVariableStaticFieldsSorted}} {{/hasPublicStaticFields}} {{#hasPublicStaticMethods}} diff --git a/lib/templates/html/_sidebar_for_container.html b/lib/templates/html/_sidebar_for_container.html index dfec338486..7c2d08ed8e 100644 --- a/lib/templates/html/_sidebar_for_container.html +++ b/lib/templates/html/_sidebar_for_container.html @@ -10,7 +10,7 @@ {{/hasPublicConstructors}} {{#hasPublicInstanceFields}} -
  • +
  • Properties
  • {{#publicInstanceFieldsSorted}} @@ -19,14 +19,14 @@ {{/hasPublicInstanceFields}} {{#hasPublicInstanceMethods}} -
  • Methods
  • +
  • Methods
  • {{#publicInstanceMethodsSorted}} {{{ linkedName }}} {{/publicInstanceMethodsSorted}} {{/hasPublicInstanceMethods}} {{#hasPublicInstanceOperators}} -
  • Operators
  • +
  • Operators
  • {{#publicInstanceOperatorsSorted}} {{{ linkedName }}} {{/publicInstanceOperatorsSorted}} @@ -34,9 +34,9 @@ {{#hasPublicStaticFields}}
  • Static properties
  • - {{#publicStaticFieldsSorted}} + {{#publicVariableStaticFieldsSorted}}
  • {{{ linkedName }}}
  • - {{/publicStaticFieldsSorted}} + {{/publicVariableStaticFieldsSorted}} {{/hasPublicStaticFields}} {{#hasPublicStaticMethods}} @@ -79,9 +79,9 @@ {{#hasPublicStaticFields}}
  • Static properties
  • - {{#publicStaticFieldsSorted}} + {{#publicVariableStaticFieldsSorted}}
  • {{{ linkedName }}}
  • - {{/publicStaticFieldsSorted}} + {{/publicVariableStaticFieldsSorted}} {{/hasPublicStaticFields}} {{#hasPublicStaticMethods}} diff --git a/lib/templates/html/_sidebar_for_enum.html b/lib/templates/html/_sidebar_for_enum.html index 2ae665f43f..fba2a778ed 100644 --- a/lib/templates/html/_sidebar_for_enum.html +++ b/lib/templates/html/_sidebar_for_enum.html @@ -15,7 +15,7 @@ {{/hasPublicConstructors}} {{#hasPublicInstanceFields}} -
  • +
  • Properties
  • {{#publicInstanceFieldsSorted}} @@ -24,14 +24,14 @@ {{/hasPublicInstanceFields}} {{#hasPublicInstanceMethods}} -
  • Methods
  • +
  • Methods
  • {{#publicInstanceMethodsSorted}} {{{ linkedName }}} {{/publicInstanceMethodsSorted}} {{/hasPublicInstanceMethods}} {{#hasPublicInstanceOperators}} -
  • Operators
  • +
  • Operators
  • {{#publicInstanceOperatorsSorted}} {{{ linkedName }}} {{/publicInstanceOperatorsSorted}} @@ -39,9 +39,9 @@ {{#hasPublicStaticFields}}
  • Static properties
  • - {{#publicStaticFieldsSorted}} + {{#publicVariableStaticFieldsSorted}}
  • {{{ linkedName }}}
  • - {{/publicStaticFieldsSorted}} + {{/publicVariableStaticFieldsSorted}} {{/hasPublicStaticFields}} {{#hasPublicStaticMethods}} diff --git a/lib/templates/html/_sidebar_for_extension.html b/lib/templates/html/_sidebar_for_extension.html index e50dc73fca..9c499eac07 100644 --- a/lib/templates/html/_sidebar_for_extension.html +++ b/lib/templates/html/_sidebar_for_extension.html @@ -25,9 +25,9 @@ {{#hasPublicStaticFields}}
  • Static properties
  • - {{#publicStaticFieldsSorted}} + {{#publicVariableStaticFieldsSorted}}
  • {{{ linkedName }}}
  • - {{/publicStaticFieldsSorted}} + {{/publicVariableStaticFieldsSorted}} {{/hasPublicStaticFields}} {{#hasPublicStaticMethods}} diff --git a/lib/templates/html/class.html b/lib/templates/html/class.html index 02f2a7a733..fee27d2992 100644 --- a/lib/templates/html/class.html +++ b/lib/templates/html/class.html @@ -102,7 +102,7 @@

    Constructors

    {{/hasPublicConstructors}} {{#hasPublicInstanceFields}} -
    +

    Properties

    @@ -114,7 +114,7 @@

    Properties

    {{/hasPublicInstanceFields}} {{#hasPublicInstanceMethods}} -
    +

    Methods

    {{#publicInstanceMethodsSorted}} @@ -125,7 +125,7 @@

    Methods

    {{/hasPublicInstanceMethods}} {{#hasPublicInstanceOperators}} -
    +

    Operators

    {{#publicInstanceOperatorsSorted}} @@ -140,9 +140,9 @@

    Operators

    Static Properties

    - {{#publicStaticFieldsSorted}} + {{#publicVariableStaticFieldsSorted}} {{>property}} - {{/publicStaticFieldsSorted}} + {{/publicVariableStaticFieldsSorted}}
    {{/hasPublicStaticFields}} diff --git a/lib/templates/html/enum.html b/lib/templates/html/enum.html index b1e3ce267e..aaf93d15b1 100644 --- a/lib/templates/html/enum.html +++ b/lib/templates/html/enum.html @@ -105,7 +105,7 @@

    Constructors

    {{/hasPublicConstructors}} {{#hasPublicInstanceFields}} -
    +

    Properties

    @@ -117,7 +117,7 @@

    Properties

    {{/hasPublicInstanceFields}} {{#hasPublicInstanceMethods}} -
    +

    Methods

    {{#publicInstanceMethodsSorted}} @@ -128,7 +128,7 @@

    Methods

    {{/hasPublicInstanceMethods}} {{#hasPublicInstanceOperators}} -
    +

    Operators

    {{#publicInstanceOperatorsSorted}} @@ -143,9 +143,9 @@

    Operators

    Static Properties

    - {{#publicStaticFieldsSorted}} + {{#publicVariableStaticFieldsSorted}} {{>property}} - {{/publicStaticFieldsSorted}} + {{/publicVariableStaticFieldsSorted}}
    {{/hasPublicStaticFields}} diff --git a/lib/templates/html/extension.html b/lib/templates/html/extension.html index 99316b06b6..d168f60074 100644 --- a/lib/templates/html/extension.html +++ b/lib/templates/html/extension.html @@ -65,9 +65,9 @@

    Operators

    Static Properties

    - {{#publicStaticFieldsSorted}} + {{#publicVariableStaticFieldsSorted}} {{>property}} - {{/publicStaticFieldsSorted}} + {{/publicVariableStaticFieldsSorted}}
    {{/hasPublicStaticFields}} diff --git a/lib/templates/html/mixin.html b/lib/templates/html/mixin.html index 61917470e7..c3d177b2fb 100644 --- a/lib/templates/html/mixin.html +++ b/lib/templates/html/mixin.html @@ -102,7 +102,7 @@

    Constructors

    {{/hasPublicConstructors}} {{#hasPublicInstanceFields}} -
    +

    Properties

    @@ -114,7 +114,7 @@

    Properties

    {{/hasPublicInstanceFields}} {{#hasPublicInstanceMethods}} -
    +

    Methods

    {{#publicInstanceMethods}} @@ -125,7 +125,7 @@

    Methods

    {{/hasPublicInstanceMethods}} {{#hasPublicInstanceOperators}} -
    +

    Operators

    {{#publicInstanceOperatorsSorted}} diff --git a/test/dartdoc_test.dart b/test/dartdoc_test.dart index 256fdf4e25..9a5724c6a5 100644 --- a/test/dartdoc_test.dart +++ b/test/dartdoc_test.dart @@ -377,6 +377,10 @@ void main() { var p = results.packageGraph; expect(p.defaultPackage.name, 'test_package_custom_templates'); expect(p.localPublicLibraries, hasLength(1)); + + var index = File(path.join(tempDir.path, 'index.html')); + expect(index.readAsStringSync(), + contains('Welcome my friends to a custom template')); }); test('generate docs with missing required template fails', () async { diff --git a/test/model_test.dart b/test/model_test.dart index 8b45af3742..7352b37d12 100644 --- a/test/model_test.dart +++ b/test/model_test.dart @@ -699,14 +699,13 @@ void main() { setUpAll(() { dog = exLibrary.classes.firstWhere((c) => c.name == 'Dog'); - withMacro = - dog.instanceMethods.firstWhere((m) => m.name == 'withMacro'); + withMacro = dog.instanceMethods.firstWhere((m) => m.name == 'withMacro'); withMacro2 = dog.instanceMethods.firstWhere((m) => m.name == 'withMacro2'); - withPrivateMacro = dog.instanceMethods - .firstWhere((m) => m.name == 'withPrivateMacro'); - withUndefinedMacro = dog.instanceMethods - .firstWhere((m) => m.name == 'withUndefinedMacro'); + withPrivateMacro = + dog.instanceMethods.firstWhere((m) => m.name == 'withPrivateMacro'); + withUndefinedMacro = + dog.instanceMethods.firstWhere((m) => m.name == 'withUndefinedMacro'); MacrosFromAccessors = fakeLibrary.enums.firstWhere((e) => e.name == 'MacrosFromAccessors'); macroReferencedHere = MacrosFromAccessors.publicConstantFields @@ -754,8 +753,8 @@ void main() { .firstWhere((m) => m.name == 'withYouTubeWatchUrl'); withYouTubeInOneLineDoc = dog.instanceMethods .firstWhere((m) => m.name == 'withYouTubeInOneLineDoc'); - withYouTubeInline = dog.instanceMethods - .firstWhere((m) => m.name == 'withYouTubeInline'); + withYouTubeInline = + dog.instanceMethods.firstWhere((m) => m.name == 'withYouTubeInline'); }); test( @@ -802,15 +801,15 @@ void main() { setUpAll(() { enumWithAnimation = exLibrary.enums.firstWhere((c) => c.name == 'EnumWithAnimation'); - enumValue1 = - enumWithAnimation.constantFields.firstWhere((m) => m.name == 'value1'); - enumValue2 = - enumWithAnimation.constantFields.firstWhere((m) => m.name == 'value2'); + enumValue1 = enumWithAnimation.constantFields + .firstWhere((m) => m.name == 'value1'); + enumValue2 = enumWithAnimation.constantFields + .firstWhere((m) => m.name == 'value2'); dog = exLibrary.classes.firstWhere((c) => c.name == 'Dog'); withAnimation = dog.instanceMethods.firstWhere((m) => m.name == 'withAnimation'); - withNamedAnimation = dog.instanceMethods - .firstWhere((m) => m.name == 'withNamedAnimation'); + withNamedAnimation = + dog.instanceMethods.firstWhere((m) => m.name == 'withNamedAnimation'); withQuoteNamedAnimation = dog.instanceMethods .firstWhere((m) => m.name == 'withQuotedNamedAnimation'); withDeprecatedAnimation = dog.instanceMethods @@ -1238,8 +1237,7 @@ void main() { test('oneLine doc references in inherited methods should not have brackets', () { - var add = - specialList.instanceMethods.firstWhere((m) => m.name == 'add'); + var add = specialList.instanceMethods.firstWhere((m) => m.name == 'add'); expect( add.oneLineDoc, equals( @@ -1249,8 +1247,7 @@ void main() { test( 'full documentation references from inherited methods should not have brackets', () { - var add = - specialList.instanceMethods.firstWhere((m) => m.name == 'add'); + var add = specialList.instanceMethods.firstWhere((m) => m.name == 'add'); expect( add.documentationAsHtml, startsWith( @@ -1411,8 +1408,8 @@ void main() { .firstWhere((l) => l.name == 'gadget_extender') .allClasses .firstWhere((c) => c.name == 'GadgetExtender'); - var gadgetGetter = - GadgetExtender.instanceFields.firstWhere((f) => f.name == 'gadgetGetter'); + var gadgetGetter = GadgetExtender.instanceFields + .firstWhere((f) => f.name == 'gadgetGetter'); expect(gadgetGetter.isCanonical, isTrue); }); @@ -1604,9 +1601,7 @@ void main() { }); test('a class with only inherited properties has some properties', () { - expect(CatString.hasInstanceFields, isFalse); - expect(CatString.instanceFields, isEmpty); - expect(CatString.hasPublicInstanceFields, isTrue); + expect(CatString.hasInstanceFields, isTrue); expect(CatString.instanceFields, isNotEmpty); }); @@ -1661,7 +1656,7 @@ void main() { }); test('get static fields', () { - expect(Apple.publicStaticFields, hasLength(1)); + expect(Apple.publicVariableStaticFields, hasLength(1)); }); test('constructors have source', () { @@ -1675,16 +1670,18 @@ void main() { }); test('get instance fields', () { - expect(Apple.publicInstanceFields, hasLength(3)); + expect(Apple.publicInstanceFields.where((f) => !f.isInherited), + hasLength(3)); expect(Apple.publicInstanceFields.first.kind, equals('property')); }); test('get inherited properties, including properties of Object', () { - expect(B.publicFieldsInherited, hasLength(4)); + expect(B.publicInheritedFields, hasLength(4)); }); test('get methods', () { - expect(Dog.publicInstanceMethods, hasLength(22)); + expect(Dog.publicInstanceMethods.where((m) => !m.isInherited), + hasLength(21)); }); test('get operators', () { @@ -1698,11 +1695,10 @@ void main() { }); test('all instance methods', () { - expect(B.publicInstanceMethods, isNotEmpty); - expect( - B.publicInstanceMethods.length, - equals(B.publicInstanceMethods.length + - B.publicInheritedMethods.length)); + var methods = B.publicInstanceMethods.where((m) => !m.isInherited); + expect(methods, isNotEmpty); + expect(B.publicInstanceMethods.length, + equals(methods.length + B.publicInheritedMethods.length)); }); test('inherited methods exist', () { @@ -1733,7 +1729,8 @@ void main() { }); test('F has a single instance method', () { - expect(F.publicInstanceMethods, hasLength(1)); + expect( + F.publicInstanceMethods.where((m) => !m.isInherited), hasLength(1)); expect( F.publicInstanceMethods.first.name, equals('methodWithGenericParam')); }); @@ -1769,14 +1766,14 @@ void main() { ])); }); - test('F has zero instance properties', () { - expect(F.publicInstanceFields, hasLength(0)); + test('F has zero declared instance properties', () { + expect(F.publicInstanceFields.where((f) => !f.isInherited), hasLength(0)); }); test('F has a few inherited properties', () { - expect(F.publicFieldsInherited, hasLength(10)); + expect(F.publicInheritedFields, hasLength(10)); expect( - F.publicFieldsInherited.map((ip) => ip.name), + F.publicInheritedFields.map((ip) => ip.name), containsAll([ 'aFinalField', 'aGetterReturningRandomThings', @@ -1792,14 +1789,17 @@ void main() { }); test('SpecialList has zero instance methods', () { - expect(SpecialList.publicInstanceMethods, hasLength(0)); + expect(SpecialList.publicInstanceMethods.where((m) => !m.isInherited), + hasLength(0)); }); test('SpecialList has many inherited methods', () { expect(SpecialList.publicInheritedMethods, hasLength(49)); - expect(SpecialList.publicInheritedMethods.first.name, equals('add')); - expect(SpecialList.publicInheritedMethods.toList()[1].name, - equals('addAll')); + var methods = SpecialList.publicInstanceMethodsSorted + .where((m) => m.isInherited) + .toList(); + expect(methods.first.name, equals('add')); + expect(methods[1].name, equals('addAll')); }); test('ExtendingClass is in the right library', () { @@ -2110,7 +2110,8 @@ void main() { }); test('has a (synthetic) values constant', () { - var valuesField = animal.constantFields.firstWhere((f) => f.name == 'values'); + var valuesField = + animal.constantFields.firstWhere((f) => f.name == 'values'); expect(valuesField, isNotNull); expect(valuesField.constantValue, equals(EnumFieldRendererHtml().renderValue(valuesField))); @@ -2128,7 +2129,9 @@ void main() { test('constants have correct indicies', () { String valueByName(var name) { - return animal.constantFields.firstWhere((f) => f.name == name).constantValue; + return animal.constantFields + .firstWhere((f) => f.name == name) + .constantValue; } expect(valueByName('CAT'), equals('const Animal(0)')); @@ -2137,13 +2140,16 @@ void main() { }); test('has a single `index` property', () { - expect(animal.instanceFields, hasLength(1)); - expect(animal.instanceFields.first, isNotNull); - expect(animal.instanceFields.first.name, equals('index')); + var instanceFields = animal.instanceFields.where((f) => !f.isInherited); + expect(instanceFields, hasLength(1)); + expect(instanceFields.first, isNotNull); + expect(instanceFields.first.name, equals('index')); }); test('has a single `index` property that is not linked', () { - expect(animal.instanceFields.first.linkedName, equals('index')); + expect( + animal.instanceFields.where((f) => !f.isInherited).first.linkedName, + equals('index')); }); }); @@ -2337,7 +2343,7 @@ String topLevelFunction(int param1, bool param2, Cool coolBeans, }); test('parameterized type from inherited field is correctly displayed', () { - var aInheritedField = TemplatedInterface.fieldsInherited + var aInheritedField = TemplatedInterface.inheritedFields .singleWhere((f) => f.name == 'aInheritedField'); expect(aInheritedField.linkedReturnType, 'AnotherParameterizedClass<List<int>>'); @@ -2356,7 +2362,7 @@ String topLevelFunction(int param1, bool param2, Cool coolBeans, test( 'parameterized type for return value from inherited explicit getter is correctly displayed', () { - Accessor aInheritedGetter = TemplatedInterface.fieldsInherited + Accessor aInheritedGetter = TemplatedInterface.inheritedFields .singleWhere((f) => f.name == 'aInheritedGetter') .getter; expect(aInheritedGetter.linkedReturnType, @@ -2366,7 +2372,7 @@ String topLevelFunction(int param1, bool param2, Cool coolBeans, test( 'parameterized type for return value from inherited explicit setter is correctly displayed', () { - Accessor aInheritedSetter = TemplatedInterface.fieldsInherited + Accessor aInheritedSetter = TemplatedInterface.inheritedFields .singleWhere((f) => f.name == 'aInheritedSetter') .setter; expect(aInheritedSetter.allParameters.first.modelType.linkedName, @@ -2398,8 +2404,7 @@ String topLevelFunction(int param1, bool param2, Cool coolBeans, test( 'parameterized type for return value containing a parameterized typedef is correctly displayed', () { - var aTypedefReturningMethodInterface = TemplatedInterface - .instanceMethods + var aTypedefReturningMethodInterface = TemplatedInterface.instanceMethods .singleWhere((m) => m.name == 'aTypedefReturningMethodInterface'); expect(aTypedefReturningMethodInterface.linkedReturnType, 'ParameterizedTypedef<List<String>>'); @@ -2408,8 +2413,7 @@ String topLevelFunction(int param1, bool param2, Cool coolBeans, test( 'parameterized type for return value containing a parameterized typedef from inherited method is correctly displayed', () { - var aInheritedTypedefReturningMethod = TemplatedInterface - .instanceMethods + var aInheritedTypedefReturningMethod = TemplatedInterface.instanceMethods .singleWhere((m) => m.name == 'aInheritedTypedefReturningMethod'); expect(aInheritedTypedefReturningMethod.linkedReturnType, 'ParameterizedTypedef<List<int>>'); @@ -2508,8 +2512,8 @@ String topLevelFunction(int param1, bool param2, Cool coolBeans, }); test('returns correct overriddenDepth', () { - final bAbstractMethod = classB.instanceMethods - .firstWhere((m) => m.name == 'abstractMethod'); + final bAbstractMethod = + classB.instanceMethods.firstWhere((m) => m.name == 'abstractMethod'); expect(abstractMethod.overriddenDepth, equals(0)); expect(bAbstractMethod.overriddenDepth, equals(1)); }); @@ -2674,8 +2678,8 @@ String topLevelFunction(int param1, bool param2, Cool coolBeans, setUpAll(() { c = exLibrary.classes.firstWhere((c) => c.name == 'Apple'); - f1 = c.staticFields.first; // n - f2 = c.instanceFields.first; + f1 = c.publicVariableStaticFieldsSorted.first; // n + f2 = c.publicInstanceFields.first; constField = c.constantFields.first; // string LongFirstLine = fakeLibrary.classes.firstWhere((c) => c.name == 'LongFirstLine'); @@ -2697,8 +2701,7 @@ String topLevelFunction(int param1, bool param2, Cool coolBeans, finalProperty = UnusualProperties.allModelElements .firstWhere((e) => e.name == 'finalProperty'); - isEmpty = - CatString.instanceFields.firstWhere((p) => p.name == 'isEmpty'); + isEmpty = CatString.instanceFields.firstWhere((p) => p.name == 'isEmpty'); dynamicGetter = LongFirstLine.instanceFields .firstWhere((p) => p.name == 'dynamicGetter'); onlySetter = LongFirstLine.instanceFields @@ -2712,10 +2715,8 @@ String topLevelFunction(int param1, bool param2, Cool coolBeans, var appleClass = exLibrary.allClasses.firstWhere((c) => c.name == 'Apple'); - sFromApple = - appleClass.instanceFields.firstWhere((p) => p.name == 's'); - mFromApple = - appleClass.instanceFields.singleWhere((p) => p.name == 'm'); + sFromApple = appleClass.instanceFields.firstWhere((p) => p.name == 's'); + mFromApple = appleClass.instanceFields.singleWhere((p) => p.name == 'm'); mInB = exLibrary.allClasses .firstWhere((c) => c.name == 'B') @@ -2996,9 +2997,7 @@ String topLevelFunction(int param1, bool param2, Cool coolBeans, var withGenericSub = exLibrary.classes.firstWhere((c) => c.name == 'WithGenericSub'); expect( - withGenericSub.fieldsInherited - .where((p) => p.name == 'prop') - .length, + withGenericSub.inheritedFields.where((p) => p.name == 'prop').length, equals(1)); }); }); @@ -3043,8 +3042,8 @@ String topLevelFunction(int param1, bool param2, Cool coolBeans, 'has correct linked return type if the return type is a parameterized typedef', () { var apple = exLibrary.classes.firstWhere((c) => c.name == 'Apple'); - final fieldWithTypedef = apple.instanceFields - .firstWhere((m) => m.name == 'fieldWithTypedef'); + final fieldWithTypedef = + apple.instanceFields.firstWhere((m) => m.name == 'fieldWithTypedef'); expect( fieldWithTypedef.linkedReturnType, equals( diff --git a/testing/test_package/lib/example.dart b/testing/test_package/lib/example.dart index 8d36ff43b3..bf656c76fe 100644 --- a/testing/test_package/lib/example.dart +++ b/testing/test_package/lib/example.dart @@ -302,6 +302,7 @@ class Dog implements Cat, E { int deprecatedField; final int aFinalField; + static const String aStaticConstField = "A Constant Dog"; /// Verify link substitution in constants (#1535) diff --git a/testing/test_package_custom_templates/templates/404error.html b/testing/test_package_custom_templates/templates/404error.html index c88dea0115..968f479a12 100644 --- a/testing/test_package_custom_templates/templates/404error.html +++ b/testing/test_package_custom_templates/templates/404error.html @@ -1,7 +1,27 @@ {{>head}} -
    -

    Oops, seems there's a problem...

    + + +
    +

    404: Something's gone wrong :-(

    + +
    +

    You've tried to visit a page that doesn't exist. Luckily this site + has other pages.

    +

    If you were looking for something specific, try searching: +

    +

    + +
    +
    + + {{>footer}} diff --git a/testing/test_package_custom_templates/templates/_accessor_getter.html b/testing/test_package_custom_templates/templates/_accessor_getter.html new file mode 100644 index 0000000000..4bc9e08e2d --- /dev/null +++ b/testing/test_package_custom_templates/templates/_accessor_getter.html @@ -0,0 +1,13 @@ +{{#getter}} +
    + +
    + {{{ linkedReturnType }}} + {{>name_summary}} + {{>features}} +
    + +{{>documentation}} +{{>source_code}} +
    +{{/getter}} diff --git a/testing/test_package_custom_templates/templates/_accessor_setter.html b/testing/test_package_custom_templates/templates/_accessor_setter.html new file mode 100644 index 0000000000..7e0bd49bb5 --- /dev/null +++ b/testing/test_package_custom_templates/templates/_accessor_setter.html @@ -0,0 +1,13 @@ +{{#setter}} +
    + +
    + void + {{>name_summary}}({{{ linkedParamsNoMetadata }}}) + {{>features}} +
    + +{{>documentation}} +{{>source_code}} +
    +{{/setter}} diff --git a/testing/test_package_custom_templates/templates/_callable.html b/testing/test_package_custom_templates/templates/_callable.html new file mode 100644 index 0000000000..7fb911b573 --- /dev/null +++ b/testing/test_package_custom_templates/templates/_callable.html @@ -0,0 +1,10 @@ +
    + {{{linkedName}}}{{{linkedGenericParameters}}}({{{ linkedParamsNoMetadata }}}) + → {{{ linkedReturnType }}} + + {{>categorization}} +
    + + {{{ oneLineDoc }}} {{{ extendedDocLink }}} + {{>features}} + diff --git a/testing/test_package_custom_templates/templates/_callable_multiline.html b/testing/test_package_custom_templates/templates/_callable_multiline.html new file mode 100644 index 0000000000..4d0bce92a5 --- /dev/null +++ b/testing/test_package_custom_templates/templates/_callable_multiline.html @@ -0,0 +1,11 @@ +{{#hasAnnotations}} +
    +
      + {{#annotations}} +
    1. {{{.}}}
    2. + {{/annotations}} +
    +
    +{{/hasAnnotations}} +{{{ linkedReturnType }}} +{{>name_summary}}{{{genericParameters}}}({{#hasParameters}}{{{linkedParamsLines}}}{{/hasParameters}}) diff --git a/testing/test_package_custom_templates/templates/_categorization.html b/testing/test_package_custom_templates/templates/_categorization.html new file mode 100644 index 0000000000..0ba248b129 --- /dev/null +++ b/testing/test_package_custom_templates/templates/_categorization.html @@ -0,0 +1,5 @@ +{{#hasCategoryNames}} + {{#displayedCategories}} + {{{categoryLabel}}} + {{/displayedCategories}} +{{/hasCategoryNames}} diff --git a/testing/test_package_custom_templates/templates/_class.html b/testing/test_package_custom_templates/templates/_class.html new file mode 100644 index 0000000000..08ffcf2436 --- /dev/null +++ b/testing/test_package_custom_templates/templates/_class.html @@ -0,0 +1,6 @@ +
    + {{{linkedName}}}{{{linkedGenericParameters}}} {{>categorization}} +
    +
    + {{{ oneLineDoc }}} {{{ extendedDocLink }}} +
    diff --git a/testing/test_package_custom_templates/templates/_constant.html b/testing/test_package_custom_templates/templates/_constant.html new file mode 100644 index 0000000000..72d367c667 --- /dev/null +++ b/testing/test_package_custom_templates/templates/_constant.html @@ -0,0 +1,12 @@ +
    + {{{ linkedName }}} + → const {{{ linkedReturnType }}} + {{>categorization}} +
    +
    + {{{ oneLineDoc }}} {{{ extendedDocLink }}} + {{>features}} +
    + {{{ constantValueTruncated }}} +
    +
    diff --git a/testing/test_package_custom_templates/templates/_documentation.html b/testing/test_package_custom_templates/templates/_documentation.html index 7b62be4eae..3202564879 100644 --- a/testing/test_package_custom_templates/templates/_documentation.html +++ b/testing/test_package_custom_templates/templates/_documentation.html @@ -1,5 +1,5 @@ {{#hasDocumentation}} -
    +
    {{{ documentationAsHtml }}}
    {{/hasDocumentation}} diff --git a/testing/test_package_custom_templates/templates/_extension.html b/testing/test_package_custom_templates/templates/_extension.html new file mode 100644 index 0000000000..33754284c7 --- /dev/null +++ b/testing/test_package_custom_templates/templates/_extension.html @@ -0,0 +1,7 @@ +
    + {{{linkedName}}} {{>categorization}} +
    +
    + {{{ oneLineDoc }}} {{{ extendedDocLink }}} +
    + diff --git a/testing/test_package_custom_templates/templates/_features.html b/testing/test_package_custom_templates/templates/_features.html new file mode 100644 index 0000000000..507bd0d8a7 --- /dev/null +++ b/testing/test_package_custom_templates/templates/_features.html @@ -0,0 +1 @@ +{{ #featuresAsString.isNotEmpty }}
    {{{featuresAsString}}}
    {{ /featuresAsString.isNotEmpty }} diff --git a/testing/test_package_custom_templates/templates/_footer.html b/testing/test_package_custom_templates/templates/_footer.html index c424ba4e2c..d23b072dc0 100644 --- a/testing/test_package_custom_templates/templates/_footer.html +++ b/testing/test_package_custom_templates/templates/_footer.html @@ -1,14 +1,25 @@
    -

    (FOOT)

    -

    - {{packageGraph.defaultPackage.name}} {{packageGraph.defaultPackage.version}} -

    + + {{packageGraph.defaultPackage.name}} + {{#packageGraph.hasFooterVersion}} + {{packageGraph.defaultPackage.version}} + {{/packageGraph.hasFooterVersion}} + {{! footer-text placeholder }}
    +{{! TODO(jdkoren): unwrap ^useBaseHref sections when the option is removed.}} + + + + + + {{! footer placeholder }} + + diff --git a/testing/test_package_custom_templates/templates/_head.html b/testing/test_package_custom_templates/templates/_head.html index 264cc9d32c..20682fa81a 100644 --- a/testing/test_package_custom_templates/templates/_head.html +++ b/testing/test_package_custom_templates/templates/_head.html @@ -1,14 +1,61 @@ + + + + {{#includeVersion}} + + {{/includeVersion}} + {{ title }} + {{ #relCanonicalPrefix }} + + {{ /relCanonicalPrefix}} + + {{#useBaseHref}}{{! TODO(jdkoren): remove when the useBaseHref option is removed.}} + {{#htmlBase}} + + + {{/htmlBase}} + {{/useBaseHref}} + + {{! TODO(jdkoren): unwrap ^useBaseHref sections when the option is removed.}} + + + + + + {{! header placeholder }} - +{{! We don't use , but we do lookup the htmlBase from javascript. }} + + +
    -
    {{self.name}}
    + + +
    {{self.name}}
    +
    diff --git a/testing/test_package_custom_templates/templates/_library.html b/testing/test_package_custom_templates/templates/_library.html new file mode 100644 index 0000000000..5263ab2d5e --- /dev/null +++ b/testing/test_package_custom_templates/templates/_library.html @@ -0,0 +1,6 @@ +
    + {{{ linkedName }}} {{>categorization}} +
    +
    + {{#isDocumented}}{{{ oneLineDoc }}} {{{ extendedDocLink }}}{{/isDocumented}} +
    diff --git a/testing/test_package_custom_templates/templates/_mixin.html b/testing/test_package_custom_templates/templates/_mixin.html new file mode 100644 index 0000000000..08ffcf2436 --- /dev/null +++ b/testing/test_package_custom_templates/templates/_mixin.html @@ -0,0 +1,6 @@ +
    + {{{linkedName}}}{{{linkedGenericParameters}}} {{>categorization}} +
    +
    + {{{ oneLineDoc }}} {{{ extendedDocLink }}} +
    diff --git a/testing/test_package_custom_templates/templates/_name_summary.html b/testing/test_package_custom_templates/templates/_name_summary.html new file mode 100644 index 0000000000..73fca35cbb --- /dev/null +++ b/testing/test_package_custom_templates/templates/_name_summary.html @@ -0,0 +1 @@ +{{#isConst}}const {{/isConst}}{{name}} diff --git a/testing/test_package_custom_templates/templates/_packages.html b/testing/test_package_custom_templates/templates/_packages.html new file mode 100644 index 0000000000..f7ae798cfa --- /dev/null +++ b/testing/test_package_custom_templates/templates/_packages.html @@ -0,0 +1,25 @@ +
      + {{#packageGraph.localPackages}} + {{#isFirstPackage}} + {{#hasDocumentedCategories}} +
    1. Topics
    2. + {{#documentedCategories}} +
    3. {{{linkedName}}}
    4. + {{/documentedCategories}} + {{/hasDocumentedCategories}} +
    5. Libraries
    6. + {{/isFirstPackage}} + {{^isFirstPackage}} +
    7. {{name}}
    8. + {{/isFirstPackage}} + {{#defaultCategory.publicLibraries}} +
    9. {{{linkedName}}}
    10. + {{/defaultCategory.publicLibraries}} + {{#categoriesWithPublicLibraries}} +
    11. {{name}}
    12. + {{#publicLibraries}} +
    13. {{{linkedName}}}
    14. + {{/publicLibraries}} + {{/categoriesWithPublicLibraries}} + {{/packageGraph.localPackages}} +
    diff --git a/testing/test_package_custom_templates/templates/_property.html b/testing/test_package_custom_templates/templates/_property.html new file mode 100644 index 0000000000..09f61f67e0 --- /dev/null +++ b/testing/test_package_custom_templates/templates/_property.html @@ -0,0 +1,8 @@ +
    + {{{linkedName}}} + {{{ arrow }}} {{{ linkedReturnType }}} {{>categorization}} +
    + + {{{ oneLineDoc }}} {{{ extendedDocLink }}} + {{>features}} + diff --git a/testing/test_package_custom_templates/templates/_search_sidebar.html b/testing/test_package_custom_templates/templates/_search_sidebar.html new file mode 100644 index 0000000000..4fb95ee8e5 --- /dev/null +++ b/testing/test_package_custom_templates/templates/_search_sidebar.html @@ -0,0 +1,21 @@ +
    + +
    + + + diff --git a/testing/test_package_custom_templates/templates/_sidebar_for_category.html b/testing/test_package_custom_templates/templates/_sidebar_for_category.html new file mode 100644 index 0000000000..eb639481e3 --- /dev/null +++ b/testing/test_package_custom_templates/templates/_sidebar_for_category.html @@ -0,0 +1,64 @@ +
      + {{#self.hasPublicLibraries}} +
    1. Libraries
    2. + {{#self.publicLibraries}} +
    3. {{{ linkedName }}}
    4. + {{/self.publicLibraries}} + {{/self.hasPublicLibraries}} + + {{#self.hasPublicMixins}} +
    5. Mixins
    6. + {{#self.publicMixins}} +
    7. {{{ linkedName }}}
    8. + {{/self.publicMixins}} + {{/self.hasPublicMixins}} + + {{#self.hasPublicClasses}} +
    9. Classes
    10. + {{#self.publicClasses}} +
    11. {{{ linkedName }}}
    12. + {{/self.publicClasses}} + {{/self.hasPublicClasses}} + + {{#self.hasPublicConstants}} +
    13. Constants
    14. + {{#self.publicConstants}} +
    15. {{{ linkedName }}}
    16. + {{/self.publicConstants}} + {{/self.hasPublicConstants}} + + {{#self.hasPublicProperties}} +
    17. Properties
    18. + {{#self.publicProperties}} +
    19. {{{ linkedName }}}
    20. + {{/self.publicProperties}} + {{/self.hasPublicProperties}} + + {{#self.hasPublicFunctions}} +
    21. Functions
    22. + {{#self.publicFunctions}} +
    23. {{{ linkedName }}}
    24. + {{/self.publicFunctions}} + {{/self.hasPublicFunctions}} + + {{#self.hasPublicEnums}} +
    25. Enums
    26. + {{#self.publicEnums}} +
    27. {{{ linkedName }}}
    28. + {{/self.publicEnums}} + {{/self.hasPublicEnums}} + + {{#self.hasPublicTypedefs}} +
    29. Typedefs
    30. + {{#self.publicTypedefs}} +
    31. {{{ linkedName }}}
    32. + {{/self.publicTypedefs}} + {{/self.hasPublicTypedefs}} + + {{#self.hasPublicExceptions}} +
    33. Exceptions
    34. + {{#self.publicExceptions}} +
    35. {{{ linkedName }}}
    36. + {{/self.publicExceptions}} + {{/self.hasPublicExceptions}} +
    diff --git a/testing/test_package_custom_templates/templates/_sidebar_for_class.html b/testing/test_package_custom_templates/templates/_sidebar_for_class.html new file mode 100644 index 0000000000..2f0390ad64 --- /dev/null +++ b/testing/test_package_custom_templates/templates/_sidebar_for_class.html @@ -0,0 +1,56 @@ +
      + {{#clazz}} + + {{#hasPublicConstructors}} +
    1. Constructors
    2. + {{#publicConstructorsSorted}} +
    3. {{shortName}}
    4. + {{/publicConstructorsSorted}} + {{/hasPublicConstructors}} + + {{#hasPublicInstanceFields}} +
    5. + Properties +
    6. + {{#publicInstanceFieldsSorted}} + {{{ linkedName }}} + {{/publicInstanceFieldsSorted}} + {{/hasPublicInstanceFields}} + + {{#hasPublicInstanceMethods}} +
    7. Methods
    8. + {{#publicInstanceMethodsSorted}} + {{{ linkedName }}} + {{/publicInstanceMethodsSorted}} + {{/hasPublicInstanceMethods}} + + {{#hasPublicInstanceOperators}} +
    9. Operators
    10. + {{#publicInstanceOperatorsSorted}} + {{{ linkedName }}} + {{/publicInstanceOperatorsSorted}} + {{/hasPublicInstanceOperators}} + + {{#hasPublicStaticFields}} +
    11. Static properties
    12. + {{#publicVariableStaticFieldsSorted}} +
    13. {{{ linkedName }}}
    14. + {{/publicVariableStaticFieldsSorted}} + {{/hasPublicStaticFields}} + + {{#hasPublicStaticMethods}} +
    15. Static methods
    16. + {{#publicStaticMethodsSorted}} +
    17. {{{ linkedName }}}
    18. + {{/publicStaticMethodsSorted}} + {{/hasPublicStaticMethods}} + + {{#hasPublicConstantFields}} +
    19. Constants
    20. + {{#publicConstantFieldsSorted}} +
    21. {{{linkedName}}}
    22. + {{/publicConstantFieldsSorted}} + {{/hasPublicConstantFields}} + + {{/clazz}} +
    diff --git a/testing/test_package_custom_templates/templates/_sidebar_for_container.html b/testing/test_package_custom_templates/templates/_sidebar_for_container.html new file mode 100644 index 0000000000..7c2d08ed8e --- /dev/null +++ b/testing/test_package_custom_templates/templates/_sidebar_for_container.html @@ -0,0 +1,103 @@ +
      + {{#container}} + + {{#isClass}} + {{#hasPublicConstructors}} +
    1. Constructors
    2. + {{#publicConstructorsSorted}} +
    3. {{shortName}}
    4. + {{/publicConstructorsSorted}} + {{/hasPublicConstructors}} + + {{#hasPublicInstanceFields}} +
    5. + Properties +
    6. + {{#publicInstanceFieldsSorted}} + {{{ linkedName }}} + {{/publicInstanceFieldsSorted}} + {{/hasPublicInstanceFields}} + + {{#hasPublicInstanceMethods}} +
    7. Methods
    8. + {{#publicInstanceMethodsSorted}} + {{{ linkedName }}} + {{/publicInstanceMethodsSorted}} + {{/hasPublicInstanceMethods}} + + {{#hasPublicInstanceOperators}} +
    9. Operators
    10. + {{#publicInstanceOperatorsSorted}} + {{{ linkedName }}} + {{/publicInstanceOperatorsSorted}} + {{/hasPublicInstanceOperators}} + + {{#hasPublicStaticFields}} +
    11. Static properties
    12. + {{#publicVariableStaticFieldsSorted}} +
    13. {{{ linkedName }}}
    14. + {{/publicVariableStaticFieldsSorted}} + {{/hasPublicStaticFields}} + + {{#hasPublicStaticMethods}} +
    15. Static methods
    16. + {{#publicStaticMethodsSorted}} +
    17. {{{ linkedName }}}
    18. + {{/publicStaticMethodsSorted}} + {{/hasPublicStaticMethods}} + + {{#hasPublicConstantFields}} +
    19. Constants
    20. + {{#publicConstantFieldsSorted}} +
    21. {{{linkedName}}}
    22. + {{/publicConstantFieldsSorted}} + {{/hasPublicConstantFields}} + {{/isClass}} + + {{#isExtension}} + {{#hasPublicInstanceFields}} +
    23. Properties +
    24. + {{#publicInstanceFieldsSorted}} +
    25. {{{ linkedName }}}
    26. + {{/publicInstanceFieldsSorted}} + {{/hasPublicInstanceFields}} + + {{#hasPublicInstanceMethods}} +
    27. Methods
    28. + {{#publicInstanceMethodsSorted}} +
    29. {{{ linkedName }}}
    30. + {{/publicInstanceMethodsSorted}} + {{/hasPublicInstanceMethods}} + + {{#hasPublicInstanceOperators}} +
    31. Operators
    32. + {{#publicInstanceOperatorsSorted}} +
    33. {{{ linkedName }}}
    34. + {{/publicInstanceOperatorsSorted}} + {{/hasPublicInstanceOperators}} + + {{#hasPublicStaticFields}} +
    35. Static properties
    36. + {{#publicVariableStaticFieldsSorted}} +
    37. {{{ linkedName }}}
    38. + {{/publicVariableStaticFieldsSorted}} + {{/hasPublicStaticFields}} + + {{#hasPublicStaticMethods}} +
    39. Static methods
    40. + {{#publicStaticMethodsSorted}} +
    41. {{{ linkedName }}}
    42. + {{/publicStaticMethodsSorted}} + {{/hasPublicStaticMethods}} + + {{#hasPublicConstantFields}} +
    43. Constants
    44. + {{#publicConstantFieldsSorted}} +
    45. {{{linkedName}}}
    46. + {{/publicConstantFieldsSorted}} + {{/hasPublicConstantFields}} + {{/isExtension}} + + {{/container}} +
    diff --git a/testing/test_package_custom_templates/templates/_sidebar_for_enum.html b/testing/test_package_custom_templates/templates/_sidebar_for_enum.html new file mode 100644 index 0000000000..fba2a778ed --- /dev/null +++ b/testing/test_package_custom_templates/templates/_sidebar_for_enum.html @@ -0,0 +1,54 @@ +
      + {{#eNum}} + {{#hasPublicConstantFields}} +
    1. Constants
    2. + {{#publicConstantFieldsSorted}} +
    3. {{{linkedName}}}
    4. + {{/publicConstantFieldsSorted}} + {{/hasPublicConstantFields}} + + {{#hasPublicConstructors}} +
    5. Constructors
    6. + {{#publicConstructorsSorted}} +
    7. {{shortName}}
    8. + {{/publicConstructorsSorted}} + {{/hasPublicConstructors}} + + {{#hasPublicInstanceFields}} +
    9. + Properties +
    10. + {{#publicInstanceFieldsSorted}} + {{{ linkedName }}} + {{/publicInstanceFieldsSorted}} + {{/hasPublicInstanceFields}} + + {{#hasPublicInstanceMethods}} +
    11. Methods
    12. + {{#publicInstanceMethodsSorted}} + {{{ linkedName }}} + {{/publicInstanceMethodsSorted}} + {{/hasPublicInstanceMethods}} + + {{#hasPublicInstanceOperators}} +
    13. Operators
    14. + {{#publicInstanceOperatorsSorted}} + {{{ linkedName }}} + {{/publicInstanceOperatorsSorted}} + {{/hasPublicInstanceOperators}} + + {{#hasPublicStaticFields}} +
    15. Static properties
    16. + {{#publicVariableStaticFieldsSorted}} +
    17. {{{ linkedName }}}
    18. + {{/publicVariableStaticFieldsSorted}} + {{/hasPublicStaticFields}} + + {{#hasPublicStaticMethods}} +
    19. Static methods
    20. + {{#publicStaticMethodsSorted}} +
    21. {{{ linkedName }}}
    22. + {{/publicStaticMethodsSorted}} + {{/hasPublicStaticMethods}} + {{/eNum}} +
    diff --git a/testing/test_package_custom_templates/templates/_sidebar_for_extension.html b/testing/test_package_custom_templates/templates/_sidebar_for_extension.html new file mode 100644 index 0000000000..9c499eac07 --- /dev/null +++ b/testing/test_package_custom_templates/templates/_sidebar_for_extension.html @@ -0,0 +1,48 @@ +
      + {{#extension}} + + {{#hasPublicInstanceFields}} +
    1. Properties +
    2. + {{#publicInstanceFieldsSorted}} +
    3. {{{ linkedName }}}
    4. + {{/publicInstanceFieldsSorted}} + {{/hasPublicInstanceFields}} + + {{#hasPublicInstanceMethods}} +
    5. Methods
    6. + {{#publicInstanceMethodsSorted}} +
    7. {{{ linkedName }}}
    8. + {{/publicInstanceMethodsSorted}} + {{/hasPublicInstanceMethods}} + + {{#hasPublicInstanceOperators}} +
    9. Operators
    10. + {{#publicInstanceOperatorsSorted}} +
    11. {{{ linkedName }}}
    12. + {{/publicInstanceOperatorsSorted}} + {{/hasPublicInstanceOperators}} + + {{#hasPublicStaticFields}} +
    13. Static properties
    14. + {{#publicVariableStaticFieldsSorted}} +
    15. {{{ linkedName }}}
    16. + {{/publicVariableStaticFieldsSorted}} + {{/hasPublicStaticFields}} + + {{#hasPublicStaticMethods}} +
    17. Static methods
    18. + {{#publicStaticMethodsSorted}} +
    19. {{{ linkedName }}}
    20. + {{/publicStaticMethodsSorted}} + {{/hasPublicStaticMethods}} + + {{#hasPublicConstantFields}} +
    21. Constants
    22. + {{#publicConstantFieldsSorted}} +
    23. {{{linkedName}}}
    24. + {{/publicConstantFieldsSorted}} + {{/hasPublicConstantFields}} + + {{/extension}} +
    diff --git a/testing/test_package_custom_templates/templates/_sidebar_for_library.html b/testing/test_package_custom_templates/templates/_sidebar_for_library.html new file mode 100644 index 0000000000..726b30951c --- /dev/null +++ b/testing/test_package_custom_templates/templates/_sidebar_for_library.html @@ -0,0 +1,66 @@ +
      + {{#library}} + {{#hasPublicClasses}} +
    1. Classes
    2. + {{#publicClasses}} +
    3. {{{ linkedName }}}
    4. + {{/publicClasses}} + {{/hasPublicClasses}} + + {{#hasPublicExtensions}} +
    5. Extensions
    6. + {{#publicExtensions}} +
    7. {{{ linkedName }}}
    8. + {{/publicExtensions}} + {{/hasPublicExtensions}} + + {{#hasPublicMixins}} +
    9. Mixins
    10. + {{#publicMixins}} +
    11. {{{ linkedName }}}
    12. + {{/publicMixins}} + {{/hasPublicMixins}} + + {{#hasPublicConstants}} +
    13. Constants
    14. + {{#publicConstants}} +
    15. {{{ linkedName }}}
    16. + {{/publicConstants}} + {{/hasPublicConstants}} + + {{#hasPublicProperties}} +
    17. Properties
    18. + {{#publicProperties}} +
    19. {{{ linkedName }}}
    20. + {{/publicProperties}} + {{/hasPublicProperties}} + + {{#hasPublicFunctions}} +
    21. Functions
    22. + {{#publicFunctions}} +
    23. {{{ linkedName }}}
    24. + {{/publicFunctions}} + {{/hasPublicFunctions}} + + {{#hasPublicEnums}} +
    25. Enums
    26. + {{#publicEnums}} +
    27. {{{ linkedName }}}
    28. + {{/publicEnums}} + {{/hasPublicEnums}} + + {{#hasPublicTypedefs}} +
    29. Typedefs
    30. + {{#publicTypedefs}} +
    31. {{{ linkedName }}}
    32. + {{/publicTypedefs}} + {{/hasPublicTypedefs}} + + {{#hasPublicExceptions}} +
    33. Exceptions
    34. + {{#publicExceptions}} +
    35. {{{ linkedName }}}
    36. + {{/publicExceptions}} + {{/hasPublicExceptions}} + {{/library}} +
    diff --git a/testing/test_package_custom_templates/templates/_source_code.html b/testing/test_package_custom_templates/templates/_source_code.html new file mode 100644 index 0000000000..27ec420cef --- /dev/null +++ b/testing/test_package_custom_templates/templates/_source_code.html @@ -0,0 +1,5 @@ +{{#hasSourceCode}} +
    +

    Implementation

    +
    {{{ sourceCode }}}
    +
    {{/hasSourceCode}} diff --git a/testing/test_package_custom_templates/templates/_source_link.html b/testing/test_package_custom_templates/templates/_source_link.html new file mode 100644 index 0000000000..0c80cf9058 --- /dev/null +++ b/testing/test_package_custom_templates/templates/_source_link.html @@ -0,0 +1,3 @@ +{{#hasSourceHref}} + +{{/hasSourceHref}} diff --git a/testing/test_package_custom_templates/templates/category.html b/testing/test_package_custom_templates/templates/category.html index 51f097d8a1..a671a2a9d5 100644 --- a/testing/test_package_custom_templates/templates/category.html +++ b/testing/test_package_custom_templates/templates/category.html @@ -1,9 +1,128 @@ {{>head}} -
    - {{#self}} -

    {{name}} {{kind}}

    - {{/self}} -
    + +
    + {{#self}} +

    {{name}} {{kind}}

    + {{>documentation}} + + {{#hasPublicLibraries}} +
    +

    Libraries

    + +
    + {{#publicLibraries}} + {{>library}} + {{/publicLibraries}} +
    +
    + {{/hasPublicLibraries}} + + {{#hasPublicClasses}} +
    +

    Classes

    + +
    + {{#publicClasses}} + {{>class}} + {{/publicClasses}} +
    +
    + {{/hasPublicClasses}} + + {{#hasPublicMixins}} +
    +

    Mixins

    + +
    + {{#publicMixins}} + {{>mixin}} + {{/publicMixins}} +
    +
    + {{/hasPublicMixins}} + + {{#hasPublicConstants}} +
    +

    Constants

    + +
    + {{#publicConstants}} + {{>constant}} + {{/publicConstants}} +
    +
    + {{/hasPublicConstants}} + + {{#hasPublicProperties}} +
    +

    Properties

    + +
    + {{#publicProperties}} + {{>property}} + {{/publicProperties}} +
    +
    + {{/hasPublicProperties}} + + {{#hasPublicFunctions}} +
    +

    Functions

    + +
    + {{#publicFunctions}} + {{>callable}} + {{/publicFunctions}} +
    +
    + {{/hasPublicFunctions}} + + {{#hasPublicEnums}} +
    +

    Enums

    + +
    + {{#publicEnums}} + {{>class}} + {{/publicEnums}} +
    +
    + {{/hasPublicEnums}} + + {{#hasPublicTypedefs}} +
    +

    Typedefs

    + +
    + {{#publicTypedefs}} + {{>callable}} + {{/publicTypedefs}} +
    +
    + {{/hasPublicTypedefs}} + + {{#hasPublicExceptions}} +
    +

    Exceptions / Errors

    + +
    + {{#publicExceptions}} + {{>class}} + {{/publicExceptions}} +
    +
    + {{/hasPublicExceptions}} + {{/self}} + +
    + {{>footer}} diff --git a/testing/test_package_custom_templates/templates/class.html b/testing/test_package_custom_templates/templates/class.html index 5dc009393c..fee27d2992 100644 --- a/testing/test_package_custom_templates/templates/class.html +++ b/testing/test_package_custom_templates/templates/class.html @@ -1,42 +1,180 @@ {{>head}} -
    + + +
    {{#self}} -

    {{{nameWithGenerics}}} {{kind}}

    +
    {{>source_link}}

    {{{nameWithGenerics}}} {{kind}} {{>categorization}}

    {{/self}} {{#clazz}} {{>documentation}} - {{#hasPublicConstructors}} + {{#hasModifiers}}
    +
    + {{#hasPublicSuperChainReversed}} +
    Inheritance
    +
      +
    • {{{linkedObjectType}}}
    • + {{#publicSuperChainReversed}} +
    • {{{linkedName}}}
    • + {{/publicSuperChainReversed}} +
    • {{{name}}}
    • +
    + {{/hasPublicSuperChainReversed}} + + {{#hasPublicInterfaces}} +
    Implemented types
    +
    +
      + {{#publicInterfaces}} +
    • {{{linkedName}}}
    • + {{/publicInterfaces}} +
    +
    + {{/hasPublicInterfaces}} + + {{#hasPublicMixins}} +
    Mixed in types
    +
      + {{#publicMixins}} +
    • {{{linkedName}}}
    • + {{/publicMixins}} +
    + {{/hasPublicMixins}} + + {{#hasPublicImplementors}} +
    Implementers
    +
      + {{#publicImplementors}} +
    • {{{linkedName}}}
    • + {{/publicImplementors}} +
    + {{/hasPublicImplementors}} + + {{#hasPotentiallyApplicableExtensions}} +
    Available Extensions
    +
      + {{#potentiallyApplicableExtensionsSorted}} +
    • {{{linkedName}}}
    • + {{/potentiallyApplicableExtensionsSorted}} +
    + {{/hasPotentiallyApplicableExtensions}} + + {{#hasAnnotations}} +
    Annotations
    +
      + {{#annotations}} +
    • {{{.}}}
    • + {{/annotations}} +
    + {{/hasAnnotations}} +
    +
    + {{/hasModifiers}} + + {{#hasPublicConstructors}} +

    Constructors

    -
    - {{#publicConstructors}} -
    - {{{linkedName}}}({{{ linkedParams }}}) +
    + {{#publicConstructorsSorted}} +
    + {{{linkedName}}}({{{ linkedParams }}})
    {{{ oneLineDoc }}} {{{ extendedDocLink }}} + {{#isConst}} +
    const
    + {{/isConst}} + {{#isFactory}} +
    factory
    + {{/isFactory}}
    - {{/publicConstructors}} + {{/publicConstructorsSorted}}
    {{/hasPublicConstructors}} - {{#hasPublicMethods}} -
    + {{#hasPublicInstanceFields}} +
    +

    Properties

    + +
    + {{#publicInstanceFieldsSorted}} + {{>property}} + {{/publicInstanceFieldsSorted}} +
    +
    + {{/hasPublicInstanceFields}} + + {{#hasPublicInstanceMethods}} +

    Methods

    -
    - {{#allPublicInstanceMethods}} - {{{ oneLineDoc }}} {{{ extendedDocLink }}} - {{/allPublicInstanceMethods}} +
    + {{#publicInstanceMethodsSorted}} + {{>callable}} + {{/publicInstanceMethodsSorted}}
    - {{/hasPublicMethods}} + {{/hasPublicInstanceMethods}} + + {{#hasPublicInstanceOperators}} +
    +

    Operators

    +
    + {{#publicInstanceOperatorsSorted}} + {{>callable}} + {{/publicInstanceOperatorsSorted}} +
    +
    + {{/hasPublicInstanceOperators}} + + {{#hasPublicStaticFields}} +
    +

    Static Properties

    +
    + {{#publicVariableStaticFieldsSorted}} + {{>property}} + {{/publicVariableStaticFieldsSorted}} +
    +
    + {{/hasPublicStaticFields}} + + {{#hasPublicStaticMethods}} +
    +

    Static Methods

    +
    + {{#publicStaticMethodsSorted}} + {{>callable}} + {{/publicStaticMethodsSorted}} +
    +
    + {{/hasPublicStaticMethods}} + + {{#hasPublicConstantFields}} +
    +

    Constants

    + +
    + {{#publicConstantFieldsSorted}} + {{>constant}} + {{/publicConstantFieldsSorted}} +
    +
    + {{/hasPublicConstantFields}} {{/clazz}} -
    + +
    + + {{>footer}} diff --git a/testing/test_package_custom_templates/templates/constant.html b/testing/test_package_custom_templates/templates/constant.html index 5f5d8fe0c5..5248e7db86 100644 --- a/testing/test_package_custom_templates/templates/constant.html +++ b/testing/test_package_custom_templates/templates/constant.html @@ -1,13 +1,33 @@ {{>head}} -
    + + +
    {{#self}} -

    {{{name}}} {{kind}}

    +
    {{>source_link}}

    {{{name}}} {{kind}}

    {{/self}} +
    + {{#property}} + {{{ linkedReturnType }}} + {{>name_summary}} + = + {{{ constantValue }}} + {{/property}} +
    + {{#property}} {{>documentation}} + {{>source_code}} {{/property}} -
    + +
    + + {{>footer}} diff --git a/testing/test_package_custom_templates/templates/constructor.html b/testing/test_package_custom_templates/templates/constructor.html index 6c8ad54dde..3fc1a9f116 100644 --- a/testing/test_package_custom_templates/templates/constructor.html +++ b/testing/test_package_custom_templates/templates/constructor.html @@ -1,13 +1,39 @@ {{>head}} -
    + + +
    {{#self}} -

    {{{nameWithGenerics}}} {{kind}}

    +
    {{>source_link}}

    {{{nameWithGenerics}}} {{kind}}

    {{/self}} {{#constructor}} +
    + {{#hasAnnotations}} +
    +
      + {{#annotations}} +
    1. {{{.}}}
    2. + {{/annotations}} +
    +
    + {{/hasAnnotations}} + {{#isConst}}const{{/isConst}} + {{{nameWithGenerics}}}({{#hasParameters}}{{{linkedParamsLines}}}{{/hasParameters}}) +
    + {{>documentation}} + + {{>source_code}} + {{/constructor}} -
    +
    + + {{>footer}} diff --git a/testing/test_package_custom_templates/templates/enum.html b/testing/test_package_custom_templates/templates/enum.html index ff59427245..aaf93d15b1 100644 --- a/testing/test_package_custom_templates/templates/enum.html +++ b/testing/test_package_custom_templates/templates/enum.html @@ -1,13 +1,170 @@ {{>head}} -
    + + +
    {{#self}} -

    {{{name}}} {{kind}}

    +
    {{>source_link}}

    {{{name}}} {{kind}} {{>categorization}}

    {{/self}} {{#eNum}} {{>documentation}} + + {{#hasModifiers}} +
    +
    + {{#hasPublicSuperChainReversed}} +
    Inheritance
    +
      +
    • {{{linkedObjectType}}}
    • + {{#publicSuperChainReversed}} +
    • {{{linkedName}}}
    • + {{/publicSuperChainReversed}} +
    • {{{name}}}
    • +
    + {{/hasPublicSuperChainReversed}} + + {{#hasPublicInterfaces}} +
    Implemented types
    +
    +
      + {{#publicInterfaces}} +
    • {{{linkedName}}}
    • + {{/publicInterfaces}} +
    +
    + {{/hasPublicInterfaces}} + + {{#hasPublicMixins}} +
    Mixed in types
    +
      + {{#publicMixins}} +
    • {{{linkedName}}}
    • + {{/publicMixins}} +
    + {{/hasPublicMixins}} + + {{#hasPublicImplementors}} +
    Implementers
    +
      + {{#publicImplementors}} +
    • {{{linkedName}}}
    • + {{/publicImplementors}} +
    + {{/hasPublicImplementors}} + + {{#hasAnnotations}} +
    Annotations
    +
      + {{#annotations}} +
    • {{{.}}}
    • + {{/annotations}} +
    + {{/hasAnnotations}} +
    +
    + {{/hasModifiers}} + + {{#hasPublicConstantFields}} +
    +

    Constants

    + +
    + {{#publicConstantFieldsSorted}} + {{>constant}} + {{/publicConstantFieldsSorted}} +
    +
    + {{/hasPublicConstantFields}} + + {{#hasPublicConstructors}} +
    +

    Constructors

    + +
    + {{#publicConstructorsSorted}} +
    + {{{linkedName}}}({{{ linkedParams }}}) +
    +
    + {{{ oneLineDoc }}} {{{ extendedDocLink }}} + {{#isConst}} +
    const
    + {{/isConst}} + {{#isFactory}} +
    factory
    + {{/isFactory}} +
    + {{/publicConstructorsSorted}} +
    +
    + {{/hasPublicConstructors}} + + {{#hasPublicInstanceFields}} +
    +

    Properties

    + +
    + {{#publicInstanceFieldsSorted}} + {{>property}} + {{/publicInstanceFieldsSorted}} +
    +
    + {{/hasPublicInstanceFields}} + + {{#hasPublicInstanceMethods}} +
    +

    Methods

    +
    + {{#publicInstanceMethodsSorted}} + {{>callable}} + {{/publicInstanceMethodsSorted}} +
    +
    + {{/hasPublicInstanceMethods}} + + {{#hasPublicInstanceOperators}} +
    +

    Operators

    +
    + {{#publicInstanceOperatorsSorted}} + {{>callable}} + {{/publicInstanceOperatorsSorted}} +
    +
    + {{/hasPublicInstanceOperators}} + + {{#hasPublicStaticFields}} +
    +

    Static Properties

    + +
    + {{#publicVariableStaticFieldsSorted}} + {{>property}} + {{/publicVariableStaticFieldsSorted}} +
    +
    + {{/hasPublicStaticFields}} + + {{#hasPublicStaticMethods}} +
    +

    Static Methods

    +
    + {{#publicStaticMethodsSorted}} + {{>callable}} + {{/publicStaticMethodsSorted}} +
    +
    + {{/hasPublicStaticMethods}} {{/eNum}} -
    +
    + + {{>footer}} diff --git a/testing/test_package_custom_templates/templates/extension.html b/testing/test_package_custom_templates/templates/extension.html index 9fdee1c40e..d168f60074 100644 --- a/testing/test_package_custom_templates/templates/extension.html +++ b/testing/test_package_custom_templates/templates/extension.html @@ -13,85 +13,87 @@
    {{parent.name}} {{parent.kind}}
    {{#extension}} {{>documentation}} - -
    on
    -
    -
      +
      +
      +
      on
      +
      +
        {{#extendedType}}
      • {{{linkedName}}}
      • {{/extendedType}} -
      -
      - +
    +
    +
    +
    - {{#hasPublicProperties}} + {{#hasPublicInstanceFields}}

    Properties

    - {{#allPublicInstanceProperties}} + {{#publicInstanceFieldsSorted}} {{>property}} - {{/allPublicInstanceProperties}} + {{/publicInstanceFieldsSorted}}
    - {{/hasPublicProperties}} + {{/hasPublicInstanceFields}} - {{#hasPublicMethods}} + {{#hasPublicInstanceMethods}}

    Methods

    - {{#allPublicInstanceMethods}} + {{#publicInstanceMethodsSorted}} {{>callable}} - {{/allPublicInstanceMethods}} + {{/publicInstanceMethodsSorted}}
    - {{/hasPublicMethods}} + {{/hasPublicInstanceMethods}} - {{#hasPublicOperators}} + {{#hasPublicInstanceOperators}}

    Operators

    - {{#allPublicOperators}} + {{#publicInstanceOperatorsSorted}} {{>callable}} - {{/allPublicOperators}} + {{/publicInstanceOperatorsSorted}}
    - {{/hasPublicOperators}} + {{/hasPublicInstanceOperators}} - {{#hasPublicStaticProperties}} + {{#hasPublicStaticFields}}

    Static Properties

    - {{#publicStaticProperties}} + {{#publicVariableStaticFieldsSorted}} {{>property}} - {{/publicStaticProperties}} + {{/publicVariableStaticFieldsSorted}}
    - {{/hasPublicStaticProperties}} + {{/hasPublicStaticFields}} {{#hasPublicStaticMethods}}

    Static Methods

    - {{#publicStaticMethods}} + {{#publicStaticMethodsSorted}} {{>callable}} - {{/publicStaticMethods}} + {{/publicStaticMethodsSorted}}
    {{/hasPublicStaticMethods}} - {{#hasPublicConstants}} + {{#hasPublicConstantFields}}

    Constants

    - {{#publicConstants}} + {{#publicConstantFieldsSorted}} {{>constant}} - {{/publicConstants}} + {{/publicConstantFieldsSorted}}
    - {{/hasPublicConstants}} + {{/hasPublicConstantFields}} {{/extension}} diff --git a/testing/test_package_custom_templates/templates/function.html b/testing/test_package_custom_templates/templates/function.html index 5f486cea89..a8d9c85c8b 100644 --- a/testing/test_package_custom_templates/templates/function.html +++ b/testing/test_package_custom_templates/templates/function.html @@ -1,13 +1,28 @@ {{>head}} -
    + + +
    {{#self}} -

    {{{nameWithGenerics}}} {{kind}}

    +
    {{>source_link}}

    {{{nameWithGenerics}}} {{kind}} {{>categorization}}

    {{/self}} {{#function}} +
    + {{>callable_multiline}} +
    {{>documentation}} + + {{>source_code}} + {{/function}} -
    +
    + + {{>footer}} diff --git a/testing/test_package_custom_templates/templates/index.html b/testing/test_package_custom_templates/templates/index.html index 1125df5449..1fd451eaac 100644 --- a/testing/test_package_custom_templates/templates/index.html +++ b/testing/test_package_custom_templates/templates/index.html @@ -1,17 +1,22 @@ {{>head}} -
    -
    {{self.name}} {{self.kind}}
    + -
    +Welcome my friends to a custom template + + +
    {{#packageGraph.defaultPackage}} {{>documentation}} {{/packageGraph.defaultPackage}} {{#packageGraph}} {{#localPackages}} -
    +
    {{#isFirstPackage}}

    Libraries

    {{/isFirstPackage}} @@ -20,17 +25,12 @@

    {{name}}

    {{/isFirstPackage}}
    {{#defaultCategory.publicLibraries}} - {{{ oneLineDoc }}} {{{ extendedDocLink }}} + {{>library}} {{/defaultCategory.publicLibraries}} {{#categoriesWithPublicLibraries}}

    {{name}}

    {{#publicLibraries}} -
    - {{{ linkedName }}} -
    -
    - {{#isDocumented}}{{{ oneLineDoc }}} {{{ extendedDocLink }}}{{/isDocumented}} -
    + {{>library}} {{/publicLibraries}} {{/categoriesWithPublicLibraries}}
    @@ -38,6 +38,9 @@

    {{name}}

    {{/localPackages}} {{/packageGraph}} +
    + + {{>footer}} diff --git a/testing/test_package_custom_templates/templates/library.html b/testing/test_package_custom_templates/templates/library.html index 85fb066c18..6e08376e7b 100644 --- a/testing/test_package_custom_templates/templates/library.html +++ b/testing/test_package_custom_templates/templates/library.html @@ -1,8 +1,14 @@ {{>head}} -
    + + +
    {{#self}} -

    {{{name}}} {{kind}}

    +
    {{>source_link}}

    {{{name}}} {{kind}} {{>categorization}}

    {{/self}} {{#library}} @@ -10,35 +16,118 @@ {{/library}} {{#library.hasPublicClasses}} -
    +

    Classes

    {{#library.publicClasses}} -
    - {{{linkedName}}}{{{linkedGenericParameters}}} -
    -
    - {{{ oneLineDoc }}} {{{ extendedDocLink }}} -
    + {{>class}} {{/library.publicClasses}}
    -
    +
    {{/library.hasPublicClasses}} + {{#library.hasPublicMixins}} +
    +

    Mixins

    + +
    + {{#library.publicMixins}} + {{>mixin}} + {{/library.publicMixins}} +
    +
    + {{/library.hasPublicMixins}} + + {{#library.hasPublicExtensions}} +
    +

    Extensions

    + +
    + {{#library.publicExtensions}} + {{>extension}} + {{/library.publicExtensions}} +
    +
    + {{/library.hasPublicExtensions}} + + {{#library.hasPublicConstants}} +
    +

    Constants

    + +
    + {{#library.publicConstants}} + {{>constant}} + {{/library.publicConstants}} +
    +
    + {{/library.hasPublicConstants}} + + {{#library.hasPublicProperties}} +
    +

    Properties

    + +
    + {{#library.publicProperties}} + {{>property}} + {{/library.publicProperties}} +
    +
    + {{/library.hasPublicProperties}} + {{#library.hasPublicFunctions}} -
    +

    Functions

    -
    +
    {{#library.publicFunctions}} - {{{linkedName}}}{{{linkedGenericParameters}}} - {{{ oneLineDoc }}} {{{ extendedDocLink }}} + {{>callable}} {{/library.publicFunctions}}
    -
    +
    {{/library.hasPublicFunctions}} - + {{#library.hasPublicEnums}} +
    +

    Enums

    + +
    + {{#library.publicEnums}} + {{>class}} + {{/library.publicEnums}} +
    +
    + {{/library.hasPublicEnums}} + + {{#library.hasPublicTypedefs}} +
    +

    Typedefs

    + +
    + {{#library.publicTypedefs}} + {{>callable}} + {{/library.publicTypedefs}} +
    +
    + {{/library.hasPublicTypedefs}} + + {{#library.hasPublicExceptions}} +
    +

    Exceptions / Errors

    + +
    + {{#library.publicExceptions}} + {{>class}} + {{/library.publicExceptions}} +
    +
    + {{/library.hasPublicExceptions}} + + + + {{>footer}} diff --git a/testing/test_package_custom_templates/templates/method.html b/testing/test_package_custom_templates/templates/method.html index 249912d9f0..d88bc73ac4 100644 --- a/testing/test_package_custom_templates/templates/method.html +++ b/testing/test_package_custom_templates/templates/method.html @@ -1,13 +1,29 @@ {{>head}} -
    + + +
    {{#self}} -

    {{{nameWithGenerics}}} {{kind}}

    +
    {{>source_link}}

    {{{nameWithGenerics}}} {{kind}}

    {{/self}} {{#method}} +
    + {{>callable_multiline}} + {{>features}} +
    {{>documentation}} + + {{>source_code}} + {{/method}} -
    +
    + + {{>footer}} diff --git a/testing/test_package_custom_templates/templates/mixin.html b/testing/test_package_custom_templates/templates/mixin.html index cbe91a65bf..c3d177b2fb 100644 --- a/testing/test_package_custom_templates/templates/mixin.html +++ b/testing/test_package_custom_templates/templates/mixin.html @@ -1,13 +1,179 @@ {{>head}} -
    + + +
    {{#self}} -

    {{{nameWithGenerics}}} {{kind}}

    +
    {{>source_link}}

    {{{nameWithGenerics}}} {{kind}} {{>categorization}}

    {{/self}} {{#mixin}} {{>documentation}} + + {{#hasModifiers}} +
    +
    + {{#hasPublicSuperclassConstraints}} +
    Superclass Constraints
    +
      + {{#publicSuperclassConstraints}} +
    • {{{linkedName}}}
    • + {{/publicSuperclassConstraints}} +
    + {{/hasPublicSuperclassConstraints}} + + {{#hasPublicSuperChainReversed}} +
    Inheritance
    +
      +
    • {{{linkedObjectType}}}
    • + {{#publicSuperChainReversed}} +
    • {{{linkedName}}}
    • + {{/publicSuperChainReversed}} +
    • {{{name}}}
    • +
    + {{/hasPublicSuperChainReversed}} + + {{#hasPublicInterfaces}} +
    Implements
    +
    +
      + {{#publicInterfaces}} +
    • {{{linkedName}}}
    • + {{/publicInterfaces}} +
    +
    + {{/hasPublicInterfaces}} + + {{#hasPublicMixins}} +
    Mixes-in
    +
      + {{#publicMixins}} +
    • {{{linkedName}}}
    • + {{/publicMixins}} +
    + {{/hasPublicMixins}} + + {{#hasPublicImplementors}} +
    Implemented by
    +
      + {{#publicImplementors}} +
    • {{{linkedName}}}
    • + {{/publicImplementors}} +
    + {{/hasPublicImplementors}} + + {{#hasAnnotations}} +
    Annotations
    +
      + {{#annotations}} +
    • {{{.}}}
    • + {{/annotations}} +
    + {{/hasAnnotations}} +
    +
    + {{/hasModifiers}} + + {{#hasPublicConstructors}} +
    +

    Constructors

    + +
    + {{#publicConstructors}} +
    + {{{linkedName}}}({{{ linkedParams }}}) +
    +
    + {{{ oneLineDoc }}} {{{ extendedDocLink }}} + {{#isConst}} +
    const
    + {{/isConst}} + {{#isFactory}} +
    factory
    + {{/isFactory}} +
    + {{/publicConstructors}} +
    +
    + {{/hasPublicConstructors}} + + {{#hasPublicInstanceFields}} +
    +

    Properties

    + +
    + {{#publicInstanceFields}} + {{>property}} + {{/publicInstanceFields}} +
    +
    + {{/hasPublicInstanceFields}} + + {{#hasPublicInstanceMethods}} +
    +

    Methods

    +
    + {{#publicInstanceMethods}} + {{>callable}} + {{/publicInstanceMethods}} +
    +
    + {{/hasPublicInstanceMethods}} + + {{#hasPublicInstanceOperators}} +
    +

    Operators

    +
    + {{#publicInstanceOperatorsSorted}} + {{>callable}} + {{/publicInstanceOperatorsSorted}} +
    +
    + {{/hasPublicInstanceOperators}} + + {{#hasPublicStaticFields}} +
    +

    Static Properties

    + +
    + {{#publicStaticProperties}} + {{>property}} + {{/publicStaticProperties}} +
    +
    + {{/hasPublicStaticFields}} + + {{#hasPublicStaticMethods}} +
    +

    Static Methods

    +
    + {{#publicStaticMethods}} + {{>callable}} + {{/publicStaticMethods}} +
    +
    + {{/hasPublicStaticMethods}} + + {{#hasPublicConstantFields}} +
    +

    Constants

    + +
    + {{#publicConstantFieldsSorted}} + {{>constant}} + {{/publicConstantFieldsSorted}} +
    +
    + {{/hasPublicConstantFields}} {{/mixin}} -
    +
    + + {{>footer}} diff --git a/testing/test_package_custom_templates/templates/property.html b/testing/test_package_custom_templates/templates/property.html index bce5e5f1a5..1372a373f8 100644 --- a/testing/test_package_custom_templates/templates/property.html +++ b/testing/test_package_custom_templates/templates/property.html @@ -1,25 +1,40 @@ {{>head}} -
    + + +
    {{#self}} -

    {{name}} {{kind}}

    +
    {{>source_link}}

    {{name}} {{kind}}

    {{/self}} {{#self}} {{#hasNoGetterSetter}} +
    + {{{ linkedReturnType }}} + {{>name_summary}} + {{>features}} +
    {{>documentation}} + {{>source_code}} {{/hasNoGetterSetter}} {{#hasGetterOrSetter}} {{#hasGetter}} -
    Has getter
    + {{>accessor_getter}} {{/hasGetter}} {{#hasSetter}} -
    Has setter
    + {{>accessor_setter}} {{/hasSetter}} {{/hasGetterOrSetter}} {{/self}} -
    +
    + + {{>footer}} diff --git a/testing/test_package_custom_templates/templates/top_level_constant.html b/testing/test_package_custom_templates/templates/top_level_constant.html index 1ed7a02b5a..ccd3f66b2c 100644 --- a/testing/test_package_custom_templates/templates/top_level_constant.html +++ b/testing/test_package_custom_templates/templates/top_level_constant.html @@ -1,15 +1,28 @@ {{>head}} -
    + + +
    {{#self}} -

    {{{name}}} {{kind}}

    +
    {{>source_link}}

    {{{name}}} {{kind}} {{>categorization}}

    -
    - = {{{ constantValue }}} -
    +
    + {{>name_summary}} + = + {{{ constantValue }}} + {{>features}} +
    {{>documentation}} + {{>source_code}} {{/self}} -
    +
    + + {{>footer}} diff --git a/testing/test_package_custom_templates/templates/top_level_property.html b/testing/test_package_custom_templates/templates/top_level_property.html index 5bc442bf71..00bbf31845 100644 --- a/testing/test_package_custom_templates/templates/top_level_property.html +++ b/testing/test_package_custom_templates/templates/top_level_property.html @@ -1,21 +1,36 @@ {{>head}} -
    + + +
    {{#self}} -

    {{{name}}} {{kind}}

    +
    {{>source_link}}

    {{{name}}} {{kind}} {{>categorization}}

    {{#hasNoGetterSetter}} +
    + {{{ linkedReturnType }}} + {{>name_summary}} + {{>features}} +
    {{>documentation}} + {{>source_code}} {{/hasNoGetterSetter}} {{#hasExplicitGetter}} -
    Has getter
    + {{>accessor_getter}} {{/hasExplicitGetter}} {{#hasExplicitSetter}} -
    Has setter
    + {{>accessor_setter}} {{/hasExplicitSetter}} {{/self}} -
    +
    + + {{>footer}} diff --git a/testing/test_package_custom_templates/templates/typedef.html b/testing/test_package_custom_templates/templates/typedef.html index 01d4c29ba7..2fcbe008a8 100644 --- a/testing/test_package_custom_templates/templates/typedef.html +++ b/testing/test_package_custom_templates/templates/typedef.html @@ -1,14 +1,30 @@ {{>head}} -
    + + +
    {{#self}} -

    {{{nameWithGenerics}}} {{kind}}

    +
    {{>source_link}}

    {{{nameWithGenerics}}} {{kind}} {{>categorization}}

    {{/self}} +
    + {{#typeDef}} + {{>callable_multiline}} + {{/typeDef}} +
    + {{#typeDef}} {{>documentation}} + {{>source_code}} {{/typeDef}} -
    +
    + + {{>footer}} From 6e46e32d3e59d24f2be9be2637fd677ef7f81b66 Mon Sep 17 00:00:00 2001 From: Janice Collins Date: Fri, 8 May 2020 15:54:19 -0700 Subject: [PATCH 3/6] Fix a missing variable static fields change in mixin template --- lib/templates/html/mixin.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/templates/html/mixin.html b/lib/templates/html/mixin.html index c3d177b2fb..3e615aab0b 100644 --- a/lib/templates/html/mixin.html +++ b/lib/templates/html/mixin.html @@ -140,9 +140,9 @@

    Operators

    Static Properties

    - {{#publicStaticProperties}} + {{#publicVariableStaticFieldsSorted}} {{>property}} - {{/publicStaticProperties}} + {{/publicVariableStaticFieldsSorted}}
    {{/hasPublicStaticFields}} From 7c789b42f9eb3a0ccbd19b5c8ed7697df2158e8a Mon Sep 17 00:00:00 2001 From: Janice Collins Date: Fri, 8 May 2020 16:15:32 -0700 Subject: [PATCH 4/6] Fix some remaining templating bugs --- lib/src/model/container.dart | 5 +---- lib/templates/html/_sidebar_for_class.html | 4 ++-- lib/templates/html/_sidebar_for_container.html | 8 ++++---- lib/templates/html/_sidebar_for_enum.html | 4 ++-- lib/templates/html/_sidebar_for_extension.html | 4 ++-- lib/templates/html/class.html | 4 ++-- lib/templates/html/enum.html | 4 ++-- lib/templates/html/extension.html | 4 ++-- lib/templates/html/mixin.html | 4 ++-- 9 files changed, 19 insertions(+), 22 deletions(-) diff --git a/lib/src/model/container.dart b/lib/src/model/container.dart index 51522386af..0f2589a6f3 100644 --- a/lib/src/model/container.dart +++ b/lib/src/model/container.dart @@ -124,9 +124,6 @@ abstract class Container extends ModelElement { Iterable get instanceAccessors => instanceFields.expand((f) => f.allAccessors); - Iterable get constantAccessors => - constantFields.expand((f) => f.allAccessors); - Iterable get staticAccessors => staticFields.expand((f) => f.allAccessors); @@ -197,7 +194,7 @@ abstract class Container extends ModelElement { staticFields.where((f) => !f.isConst); bool get hasPublicVariableStaticFields => - publicVariableStaticFieldsSorted.isEmpty; + publicVariableStaticFieldsSorted.isNotEmpty; Iterable get publicVariableStaticFields => model_utils.filterNonPublic(variableStaticFields); diff --git a/lib/templates/html/_sidebar_for_class.html b/lib/templates/html/_sidebar_for_class.html index 2f0390ad64..868c28efe7 100644 --- a/lib/templates/html/_sidebar_for_class.html +++ b/lib/templates/html/_sidebar_for_class.html @@ -31,12 +31,12 @@ {{/publicInstanceOperatorsSorted}} {{/hasPublicInstanceOperators}} - {{#hasPublicStaticFields}} + {{#hasPublicVariableStaticFields}}
  • Static properties
  • {{#publicVariableStaticFieldsSorted}}
  • {{{ linkedName }}}
  • {{/publicVariableStaticFieldsSorted}} - {{/hasPublicStaticFields}} + {{/hasPublicVariableStaticFields}} {{#hasPublicStaticMethods}}
  • Static methods
  • diff --git a/lib/templates/html/_sidebar_for_container.html b/lib/templates/html/_sidebar_for_container.html index 7c2d08ed8e..7f53b73296 100644 --- a/lib/templates/html/_sidebar_for_container.html +++ b/lib/templates/html/_sidebar_for_container.html @@ -32,12 +32,12 @@ {{/publicInstanceOperatorsSorted}} {{/hasPublicInstanceOperators}} - {{#hasPublicStaticFields}} + {{#hasPublicVariableStaticFields}}
  • Static properties
  • {{#publicVariableStaticFieldsSorted}}
  • {{{ linkedName }}}
  • {{/publicVariableStaticFieldsSorted}} - {{/hasPublicStaticFields}} + {{/hasPublicVariableStaticFields}} {{#hasPublicStaticMethods}}
  • Static methods
  • @@ -77,12 +77,12 @@ {{/publicInstanceOperatorsSorted}} {{/hasPublicInstanceOperators}} - {{#hasPublicStaticFields}} + {{#hasPublicVariableStaticFields}}
  • Static properties
  • {{#publicVariableStaticFieldsSorted}}
  • {{{ linkedName }}}
  • {{/publicVariableStaticFieldsSorted}} - {{/hasPublicStaticFields}} + {{/hasPublicVariableStaticFields}} {{#hasPublicStaticMethods}}
  • Static methods
  • diff --git a/lib/templates/html/_sidebar_for_enum.html b/lib/templates/html/_sidebar_for_enum.html index fba2a778ed..48fcb936ba 100644 --- a/lib/templates/html/_sidebar_for_enum.html +++ b/lib/templates/html/_sidebar_for_enum.html @@ -37,12 +37,12 @@ {{/publicInstanceOperatorsSorted}} {{/hasPublicInstanceOperators}} - {{#hasPublicStaticFields}} + {{#hasPublicVariableStaticFields}}
  • Static properties
  • {{#publicVariableStaticFieldsSorted}}
  • {{{ linkedName }}}
  • {{/publicVariableStaticFieldsSorted}} - {{/hasPublicStaticFields}} + {{/hasPublicVariableStaticFields}} {{#hasPublicStaticMethods}}
  • Static methods
  • diff --git a/lib/templates/html/_sidebar_for_extension.html b/lib/templates/html/_sidebar_for_extension.html index 9c499eac07..ba8859cb72 100644 --- a/lib/templates/html/_sidebar_for_extension.html +++ b/lib/templates/html/_sidebar_for_extension.html @@ -23,12 +23,12 @@ {{/publicInstanceOperatorsSorted}} {{/hasPublicInstanceOperators}} - {{#hasPublicStaticFields}} + {{#hasPublicVariableStaticFields}}
  • Static properties
  • {{#publicVariableStaticFieldsSorted}}
  • {{{ linkedName }}}
  • {{/publicVariableStaticFieldsSorted}} - {{/hasPublicStaticFields}} + {{/hasPublicVariableStaticFields}} {{#hasPublicStaticMethods}}
  • Static methods
  • diff --git a/lib/templates/html/class.html b/lib/templates/html/class.html index fee27d2992..2fd0090f79 100644 --- a/lib/templates/html/class.html +++ b/lib/templates/html/class.html @@ -135,7 +135,7 @@

    Operators

    {{/hasPublicInstanceOperators}} - {{#hasPublicStaticFields}} + {{#hasPublicVariableStaticFields}}

    Static Properties

    @@ -145,7 +145,7 @@

    Static Properties

    {{/publicVariableStaticFieldsSorted}}
    - {{/hasPublicStaticFields}} + {{/hasPublicVariableStaticFields}} {{#hasPublicStaticMethods}}
    diff --git a/lib/templates/html/enum.html b/lib/templates/html/enum.html index aaf93d15b1..f42561c123 100644 --- a/lib/templates/html/enum.html +++ b/lib/templates/html/enum.html @@ -138,7 +138,7 @@

    Operators

    {{/hasPublicInstanceOperators}} - {{#hasPublicStaticFields}} + {{#hasPublicVariableStaticFields}}

    Static Properties

    @@ -148,7 +148,7 @@

    Static Properties

    {{/publicVariableStaticFieldsSorted}}
    - {{/hasPublicStaticFields}} + {{/hasPublicVariableStaticFields}} {{#hasPublicStaticMethods}}
    diff --git a/lib/templates/html/extension.html b/lib/templates/html/extension.html index d168f60074..7434dbf0c3 100644 --- a/lib/templates/html/extension.html +++ b/lib/templates/html/extension.html @@ -60,7 +60,7 @@

    Operators

    {{/hasPublicInstanceOperators}} - {{#hasPublicStaticFields}} + {{#hasPublicVariableStaticFields}}

    Static Properties

    @@ -70,7 +70,7 @@

    Static Properties

    {{/publicVariableStaticFieldsSorted}}
    - {{/hasPublicStaticFields}} + {{/hasPublicVariableStaticFields}} {{#hasPublicStaticMethods}}
    diff --git a/lib/templates/html/mixin.html b/lib/templates/html/mixin.html index 3e615aab0b..d7500f5114 100644 --- a/lib/templates/html/mixin.html +++ b/lib/templates/html/mixin.html @@ -135,7 +135,7 @@

    Operators

    {{/hasPublicInstanceOperators}} - {{#hasPublicStaticFields}} + {{#hasPublicVariableStaticFields}}

    Static Properties

    @@ -145,7 +145,7 @@

    Static Properties

    {{/publicVariableStaticFieldsSorted}}
    - {{/hasPublicStaticFields}} + {{/hasPublicVariableStaticFields}} {{#hasPublicStaticMethods}}
    From 02b8138318b428a1963ebf8999c8d15ba09dd4f8 Mon Sep 17 00:00:00 2001 From: Janice Collins Date: Mon, 11 May 2020 14:48:45 -0700 Subject: [PATCH 5/6] Review comments --- lib/src/model/class.dart | 4 ++-- lib/src/model/container.dart | 14 ++++++++------ lib/src/model/inheritable.dart | 3 ++- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/lib/src/model/class.dart b/lib/src/model/class.dart index c33957387f..df39fcad70 100644 --- a/lib/src/model/class.dart +++ b/lib/src/model/class.dart @@ -432,12 +432,12 @@ class Class extends Container _allFields.add(field); } - List _declaredMethods; + Iterable _declaredMethods; @override Iterable get declaredMethods => _declaredMethods ??= element.methods.map((e) { return ModelElement.from(e, library, packageGraph) as Method; - }).toList(growable: false); + }); List _typeParameters; // a stronger hash? diff --git a/lib/src/model/container.dart b/lib/src/model/container.dart index 0f2589a6f3..cea2609dd0 100644 --- a/lib/src/model/container.dart +++ b/lib/src/model/container.dart @@ -48,7 +48,6 @@ abstract class Container extends ModelElement { /// All methods, including operators and statics, declared as part of this /// [Container]. [declaredMethods] must be the union of [instanceMethods], /// [staticMethods], and [instanceOperators]. - /// Iterable get declaredMethods; Iterable get instanceMethods => declaredMethods @@ -138,11 +137,11 @@ abstract class Container extends ModelElement { Map> _membersByName; /// Given a ModelElement that is a member of some other class, return - /// a member of this class that has the same name and return type. + /// the member of this class that has the same name and runtime type. /// /// This enables object substitution for canonicalization, such as Interceptor /// for Object. - ModelElement memberByExample(ModelElement example) { + T memberByExample(T example) { if (_membersByName == null) { _membersByName = {}; for (var me in allModelElements) { @@ -153,11 +152,14 @@ abstract class Container extends ModelElement { } } ModelElement member; + // [T] is insufficiently specific to disambiguate between different + // subtypes of [Inheritable] or other mixins/implementations of + // [ModelElement] via [Iterable.whereType]. var possibleMembers = _membersByName[example.name] .where((e) => e.runtimeType == example.runtimeType); - if (example.runtimeType == Accessor) { - possibleMembers = possibleMembers.where( - (e) => (example as Accessor).isGetter == (e as Accessor).isGetter); + if (example is Accessor) { + possibleMembers = possibleMembers + .where((e) => example.isGetter == (e as Accessor).isGetter); } member = possibleMembers.first; assert(possibleMembers.length == 1); diff --git a/lib/src/model/inheritable.dart b/lib/src/model/inheritable.dart index 05ac1d5bc2..e741cd7e38 100644 --- a/lib/src/model/inheritable.dart +++ b/lib/src/model/inheritable.dart @@ -75,7 +75,8 @@ mixin Inheritable on ContainerMember { c != definingEnclosingContainer) || (packageGraph.inheritThrough.contains(c) && c == definingEnclosingContainer)) { - return (previousNonSkippable.memberByExample(this) as Inheritable) + return previousNonSkippable + .memberByExample(this) .canonicalEnclosingContainer; } Class canonicalC = From 4bbbe4963a5b9e0620fd5108fbe561937a793b59 Mon Sep 17 00:00:00 2001 From: Janice Collins Date: Mon, 11 May 2020 16:49:53 -0700 Subject: [PATCH 6/6] Update markdown templates per #2206 --- lib/templates/md/class.md | 48 +++++++++++++++++------------------ lib/templates/md/enum.md | 48 +++++++++++++++++------------------ lib/templates/md/extension.md | 44 ++++++++++++++++---------------- lib/templates/md/mixin.md | 48 +++++++++++++++++------------------ test/dartdoc_test.dart | 6 +++++ 5 files changed, 100 insertions(+), 94 deletions(-) diff --git a/lib/templates/md/class.md b/lib/templates/md/class.md index d9cb249c69..e98847fb06 100644 --- a/lib/templates/md/class.md +++ b/lib/templates/md/class.md @@ -65,68 +65,68 @@ {{#hasPublicConstructors}} ## Constructors -{{#publicConstructors}} +{{#publicConstructorsSorted}} {{{linkedName}}} ({{{ linkedParams }}}) {{{ oneLineDoc }}} {{{ extendedDocLink }}} {{!two spaces intentional}} {{#isConst}}_const_{{/isConst}} {{#isFactory}}_factory_{{/isFactory}} -{{/publicConstructors}} +{{/publicConstructorsSorted}} {{/hasPublicConstructors}} -{{#hasPublicProperties}} +{{#hasPublicInstanceFields}} ## Properties -{{#allPublicInstanceProperties}} +{{#publicInstanceFieldsSorted}} {{>property}} -{{/allPublicInstanceProperties}} -{{/hasPublicProperties}} +{{/publicInstanceFieldsSorted}} +{{/hasPublicInstanceFields}} -{{#hasPublicMethods}} +{{#hasPublicInstanceMethods}} ## Methods -{{#allPublicInstanceMethods}} +{{#publicInstanceMethodsSorted}} {{>callable}} -{{/allPublicInstanceMethods}} -{{/hasPublicMethods}} +{{/publicInstanceMethodsSorted}} +{{/hasPublicInstanceMethods}} -{{#hasPublicOperators}} +{{#hasPublicInstanceOperators}} ## Operators -{{#allPublicOperators}} +{{#publicInstanceOperatorsSorted}} {{>callable}} -{{/allPublicOperators}} -{{/hasPublicOperators}} +{{/publicInstanceOperatorsSorted}} +{{/hasPublicInstanceOperators}} -{{#hasPublicStaticProperties}} +{{#hasPublicVariableStaticFields}} ## Static Properties -{{#publicStaticProperties}} +{{#publicVariableStaticFieldsSorted}} {{>property}} -{{/publicStaticProperties}} -{{/hasPublicStaticProperties}} +{{/publicVariableStaticFieldsSorted}} +{{/hasPublicVariableStaticFields}} {{#hasPublicStaticMethods}} ## Static Methods -{{#publicStaticMethods}} +{{#publicStaticMethodsSorted}} {{>callable}} -{{/publicStaticMethods}} +{{/publicStaticMethodsSorted}} {{/hasPublicStaticMethods}} -{{#hasPublicConstants}} +{{#hasPublicConstantFields}} ## Constants -{{#publicConstants}} +{{#publicConstantFieldsSorted}} {{>constant}} -{{/publicConstants}} -{{/hasPublicConstants}} +{{/publicConstantFieldsSorted}} +{{/hasPublicConstantFields}} {{/clazz}} {{>footer}} diff --git a/lib/templates/md/enum.md b/lib/templates/md/enum.md index 727e6be62a..ce48fa30a4 100644 --- a/lib/templates/md/enum.md +++ b/lib/templates/md/enum.md @@ -54,70 +54,70 @@ {{/hasAnnotations}} {{/hasModifiers}} -{{#hasPublicConstants}} +{{#hasPublicConstantFields}} ## Constants -{{#publicConstants}} +{{#publicConstantFieldsSorted}} {{>constant}} -{{/publicConstants}} -{{/hasPublicConstants}} +{{/publicConstantFieldsSorted}} +{{/hasPublicConstantFields}} {{#hasPublicConstructors}} ## Constructors -{{#publicConstructors}} +{{#publicConstructorsSorted}} {{{linkedName}}}({{{ linkedParams }}}) {{{ oneLineDoc }}} {{{ extendedDocLink }}} {{!two spaces intentional}} {{#isConst}}_const_{{/isConst}} {{#isFactory}}_factory_{{/isFactory}} -{{/publicConstructors}} +{{/publicConstructorsSorted}} {{/hasPublicConstructors}} -{{#hasPublicProperties}} +{{#hasPublicInstanceFields}} ## Properties -{{#allPublicInstanceProperties}} +{{#publicInstanceFieldsSorted}} {{>property}} -{{/allPublicInstanceProperties}} -{{/hasPublicProperties}} +{{/publicInstanceFieldsSorted}} +{{/hasPublicInstanceFields}} -{{#hasPublicMethods}} +{{#hasPublicInstanceMethods}} ## Methods -{{#allPublicInstanceMethods}} +{{#publicInstanceMethodsSorted}} {{>callable}} -{{/allPublicInstanceMethods}} -{{/hasPublicMethods}} +{{/publicInstanceMethodsSorted}} +{{/hasPublicInstanceMethods}} -{{#hasPublicOperators}} +{{#hasPublicInstanceOperators}} ## Operators -{{#allPublicOperators}} +{{#publicInstanceOperatorsSorted}} {{>callable}} -{{/allPublicOperators}} -{{/hasPublicOperators}} +{{/publicInstanceOperatorsSorted}} +{{/hasPublicInstanceOperators}} -{{#hasPublicStaticProperties}} +{{#hasPublicVariableStaticFields}} ## Static Properties -{{#publicStaticProperties}} +{{#publicVariableStaticFieldsSorted}} {{>property}} -{{/publicStaticProperties}} -{{/hasPublicStaticProperties}} +{{/publicVariableStaticFieldsSorted}} +{{/hasPublicVariableStaticFields}} {{#hasPublicStaticMethods}} ## Static Methods -{{#publicStaticMethods}} +{{#publicStaticMethodsSorted}} {{>callable}} -{{/publicStaticMethods}} +{{/publicStaticMethodsSorted}} {{/hasPublicStaticMethods}} {{/eNum}} diff --git a/lib/templates/md/extension.md b/lib/templates/md/extension.md index aa7c992440..be62c54e0d 100644 --- a/lib/templates/md/extension.md +++ b/lib/templates/md/extension.md @@ -12,59 +12,59 @@ on {{#extendedType}}{{{linkedName}}}{{/extendedType}} {{#extension}} {{>documentation}} -{{#hasPublicProperties}} +{{#hasPublicInstanceFields}} ## Properties -{{#allPublicInstanceProperties}} +{{#publicInstanceFieldsSorted}} {{>property}} -{{/allPublicInstanceProperties}} -{{/hasPublicProperties}} +{{/publicInstanceFieldsSorted}} +{{/hasPublicInstanceFields}} -{{#hasPublicMethods}} +{{#hasPublicInstanceMethods}} ## Methods -{{#allPublicInstanceMethods}} +{{#publicInstanceMethodsSorted}} {{>callable}} -{{/allPublicInstanceMethods}} -{{/hasPublicMethods}} +{{/publicInstanceMethodsSorted}} +{{/hasPublicInstanceMethods}} -{{#hasPublicOperators}} +{{#hasPublicInstanceOperators}} ## Operators -{{#allPublicOperators}} +{{#publicInstanceOperatorsSorted}} {{>callable}} -{{/allPublicOperators}} -{{/hasPublicOperators}} +{{/publicInstanceOperatorsSorted}} +{{/hasPublicInstanceOperators}} -{{#hasPublicStaticProperties}} +{{#hasPublicVariableStaticFields}} ## Static Properties -{{#publicStaticProperties}} +{{#publicVariableStaticFieldsSorted}} {{>property}} -{{/publicStaticProperties}} -{{/hasPublicStaticProperties}} +{{/publicVariableStaticFieldsSorted}} +{{/hasPublicVariableStaticFields}} {{#hasPublicStaticMethods}} ## Static Methods -{{#publicStaticMethods}} +{{#publicStaticMethodsSorted}} {{>callable}} -{{/publicStaticMethods}} +{{/publicStaticMethodsSorted}} {{/hasPublicStaticMethods}} -{{#hasPublicConstants}} +{{#hasPublicConstantFields}} ## Constants -{{#publicConstants}} +{{#publicConstantFieldsSorted}} {{>constant}} -{{/publicConstants}} -{{/hasPublicConstants}} +{{/publicConstantFieldsSorted}} +{{/hasPublicConstantFields}} {{/extension}} {{>footer}} diff --git a/lib/templates/md/mixin.md b/lib/templates/md/mixin.md index 8060f5e0bc..e81cdbccfd 100644 --- a/lib/templates/md/mixin.md +++ b/lib/templates/md/mixin.md @@ -65,68 +65,68 @@ {{#hasPublicConstructors}} ## Constructors -{{#publicConstructors}} +{{#publicConstructorsSorted}} {{{linkedName}}}({{{ linkedParams }}}) {{{ oneLineDoc }}} {{{ extendedDocLink }}} {{!two spaces intentional}} {{#isConst}}_const_{{/isConst}} {{#isFactory}}_factory_{{/isFactory}} -{{/publicConstructors}} +{{/publicConstructorsSorted}} {{/hasPublicConstructors}} -{{#hasPublicProperties}} +{{#hasPublicInstanceFields}} ## Properties -{{#allPublicInstanceProperties}} +{{#publicInstanceFieldsSorted}} {{>property}} -{{/allPublicInstanceProperties}} -{{/hasPublicProperties}} +{{/publicInstanceFieldsSorted}} +{{/hasPublicInstanceFields}} -{{#hasPublicMethods}} +{{#hasPublicInstanceMethods}} ## Methods -{{#allPublicInstanceMethods}} +{{#publicInstanceMethodsSorted}} {{>callable}} -{{/allPublicInstanceMethods}} -{{/hasPublicMethods}} +{{/publicInstanceMethodsSorted}} +{{/hasPublicInstanceMethods}} -{{#hasPublicOperators}} +{{#hasPublicInstanceOperators}} ## Operators -{{#allPublicOperators}} +{{#publicInstanceOperatorsSorted}} {{>callable}} -{{/allPublicOperators}} -{{/hasPublicOperators}} +{{/publicInstanceOperatorsSorted}} +{{/hasPublicInstanceOperators}} -{{#hasPublicStaticProperties}} +{{#hasPublicVariableStaticFields}} ## Static Properties -{{#publicStaticProperties}} +{{#publicVariableStaticFieldsSorted}} {{>property}} -{{/publicStaticProperties}} -{{/hasPublicStaticProperties}} +{{/publicVariableStaticFieldsSorted}} +{{/hasPublicVariableStaticFields}} {{#hasPublicStaticMethods}} ## Static Methods -{{#publicStaticMethods}} +{{#publicStaticMethodsSorted}} {{>callable}} -{{/publicStaticMethods}} +{{/publicStaticMethodsSorted}} {{/hasPublicStaticMethods}} -{{#hasPublicConstants}} +{{#hasPublicConstantFields}} ## Constants -{{#publicConstants}} +{{#publicConstantFieldsSorted}} {{>constant}} -{{/publicConstants}} -{{/hasPublicConstants}} +{{/publicConstantFieldsSorted}} +{{/hasPublicConstantFields}} {{/mixin}} {{>footer}} diff --git a/test/dartdoc_test.dart b/test/dartdoc_test.dart index 9a5724c6a5..d1d7ee9c3a 100644 --- a/test/dartdoc_test.dart +++ b/test/dartdoc_test.dart @@ -407,6 +407,12 @@ void main() { } }); + test('generating markdown docs does not crash', () async { + var dartdoc = + await buildDartdoc(['--format', 'md'], testPackageDir, tempDir); + await dartdoc.generateDocsBase(); + }); + test('rel canonical prefix does not include base href', () async { // ignore: omit_local_variable_types final String prefix = 'foo.bar/baz';