Skip to content

Commit 7bb4e50

Browse files
authored
Adjust interfaces for mustache. (#2373)
* Even though ModelElement has `hasCategoryNames`, the _categorization partial references `displayedCategories`, so it must exist. * _sidebar_for_container references `hasPublicConstructors`, `publicConstructorsSorted`, `publicInheritedInstanceFields`, `publicInheritedInstanceMethods`, `publicInheritedInstanceOperators`. * Category.linkedName is referenced by templates, so it should no longer be deprecated.
1 parent 0524bb6 commit 7bb4e50

File tree

5 files changed

+30
-6
lines changed

5 files changed

+30
-6
lines changed

lib/src/model/categorization.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ abstract class Categorization implements ModelElement {
111111
return _categories;
112112
}
113113

114+
@override
114115
Iterable<Category> get displayedCategories {
115116
if (config.showUndocumentedCategories) return categories;
116117
return categories.where((c) => c.isDocumented);

lib/src/model/category.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,6 @@ class Category extends Nameable
149149

150150
String get categoryLabel => _categoryRenderer.renderCategoryLabel(this);
151151

152-
@Deprecated(
153-
'Public field is unused; will be removed as early as Dartdoc 1.0.0')
154152
String get linkedName => _categoryRenderer.renderLinkedName(this);
155153

156154
int _categoryIndex;

lib/src/model/class.dart

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class Class extends Container
7777
Iterable<Method> get instanceMethods =>
7878
quiver.concat([super.instanceMethods, inheritedMethods]);
7979

80-
// Whether all instance methods are inherited, used in mustache templates.
80+
@override
8181
bool get publicInheritedInstanceMethods =>
8282
instanceMethods.every((f) => f.isInherited);
8383

@@ -131,11 +131,12 @@ class Class extends Container
131131
return kind;
132132
}
133133

134-
// Whether any constructors are public, used in mustache templates.
134+
@override
135135
bool get hasPublicConstructors => publicConstructorsSorted.isNotEmpty;
136136

137137
List<Constructor> _publicConstructorsSorted;
138138

139+
@override
139140
List<Constructor> get publicConstructorsSorted =>
140141
_publicConstructorsSorted ??= publicConstructors.toList()..sort(byName);
141142

@@ -247,6 +248,7 @@ class Class extends Container
247248
return _inheritedOperators;
248249
}
249250

251+
@override
250252
Iterable<Operator> get publicInheritedInstanceOperators =>
251253
model_utils.filterNonPublic(inheritedOperators);
252254

@@ -524,6 +526,7 @@ class Class extends Container
524526
Iterable<Field> get instanceFields =>
525527
_instanceFields ??= allFields.where((f) => !f.isStatic);
526528

529+
@override
527530
bool get publicInheritedInstanceFields =>
528531
publicInstanceFields.every((f) => f.isInherited);
529532

lib/src/model/container.dart

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,25 @@ abstract class Container extends ModelElement with TypeParameters {
5454
.where((m) => !m.isStatic && !m.isOperator)
5555
.toList(growable: false);
5656

57+
/// Whether any constructors are public.
58+
///
59+
/// This is only used in mustache templates.
60+
bool get hasPublicConstructors => false;
61+
62+
Iterable<Constructor> get publicConstructorsSorted => [];
63+
64+
/// Whether all instance fields are inherited.
65+
///
66+
/// This is only used in mustache templates.
67+
bool get publicInheritedInstanceFields => false;
68+
69+
/// Whether all instance methods are inherited.
70+
///
71+
/// This is only used in mustache templates.
72+
bool get publicInheritedInstanceMethods => false;
73+
74+
Iterable<Operator> get publicInheritedInstanceOperators => [];
75+
5776
@nonVirtual
5877
bool get hasPublicInstanceMethods =>
5978
model_utils.filterNonPublic(instanceMethods).isNotEmpty;

lib/src/model/model_element.dart

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -382,10 +382,13 @@ abstract class ModelElement extends Canonicalization
382382
throw 'Unknown type ${e.runtimeType}';
383383
}
384384

385-
/// Stub for mustache4dart, or it will search enclosing elements to find
386-
/// names for members.
385+
// Stub for mustache, which would otherwise search enclosing elements to find
386+
// names for members.
387387
bool get hasCategoryNames => false;
388388

389+
// Stub for mustache.
390+
Iterable<Category> get displayedCategories => [];
391+
389392
Set<Library> get exportedInLibraries {
390393
return library.packageGraph.libraryElementReexportedBy[element.library];
391394
}

0 commit comments

Comments
 (0)