File tree 3 files changed +13
-18
lines changed
3 files changed +13
-18
lines changed Original file line number Diff line number Diff line change @@ -42,23 +42,14 @@ abstract class Categorization implements ModelElement {
42
42
return '' ;
43
43
});
44
44
45
- if (_categorySet.isEmpty) {
46
- // All objects are in the default category if not specified.
47
- _categorySet.add (null );
48
- }
49
- if (_subCategorySet.isEmpty) {
50
- // All objects are in the default subcategory if not specified.
51
- _subCategorySet.add (null );
52
- }
53
45
_categoryNames = _categorySet.toList ()..sort ();
54
46
_subCategoryNames = _subCategorySet.toList ()..sort ();
55
47
_image ?? = '' ;
56
48
_samples ?? = '' ;
57
49
return rawDocs;
58
50
}
59
51
60
- bool get hasSubCategoryNames =>
61
- subCategoryNames.length > 1 || subCategoryNames.first != null ;
52
+ bool get hasSubCategoryNames => subCategoryNames.isNotEmpty;
62
53
List <String > _subCategoryNames;
63
54
64
55
/// Either a set of strings containing all declared subcategories for this symbol,
@@ -70,8 +61,7 @@ abstract class Categorization implements ModelElement {
70
61
}
71
62
72
63
@override
73
- bool get hasCategoryNames =>
74
- categoryNames.length > 1 || categoryNames.first != null ;
64
+ bool get hasCategoryNames => categoryNames.isNotEmpty;
75
65
List <String > _categoryNames;
76
66
77
67
/// Either a set of strings containing all declared categories for this symbol,
Original file line number Diff line number Diff line change @@ -270,8 +270,13 @@ class Package extends LibraryContainer
270
270
_nameToCategory[null ] = Category (null , this , config);
271
271
for (Categorization c in libraries.expand (
272
272
(l) => l.allCanonicalModelElements.whereType <Categorization >())) {
273
- for (String category in c.categoryNames) {
274
- categoryFor (category).addItem (c);
273
+ if (c.hasCategoryNames) {
274
+ for (String category in c.categoryNames) {
275
+ categoryFor (category).addItem (c);
276
+ }
277
+ } else {
278
+ // Add to the default category.
279
+ categoryFor (null ).addItem (c);
275
280
}
276
281
}
277
282
}
Original file line number Diff line number Diff line change @@ -89,11 +89,11 @@ void main() {
89
89
});
90
90
91
91
test ('includeExternal and showUndocumentedCategories' , () async {
92
- Class Something = p.allCanonicalModelElements
92
+ Class withUndocumentedCategory = p.allCanonicalModelElements
93
93
.whereType <Class >()
94
- .firstWhere ((ModelElement c) => c.name == 'Something ' );
95
- expect (Something .isPublic, isTrue);
96
- expect (Something .displayedCategories, isNotEmpty);
94
+ .firstWhere ((ModelElement c) => c.name == 'UseAnExampleHere ' );
95
+ expect (withUndocumentedCategory .isPublic, isTrue);
96
+ expect (withUndocumentedCategory .displayedCategories, isNotEmpty);
97
97
});
98
98
});
99
99
You can’t perform that action at this time.
0 commit comments