Skip to content

Commit 3e3f9d2

Browse files
authored
Remove @samples directive. (#3567)
1 parent 9596415 commit 3e3f9d2

File tree

5 files changed

+4
-49
lines changed

5 files changed

+4
-49
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,8 @@ library my_library;
215215

216216
A file `categories.json` will be generated at the top level of the documentation tree with
217217
information about categories collected from objects in the source tree. The directives
218-
`@category`, `@subCategory`, `@image`, and `@samples` are understood and saved into this json.
219-
Future versions of dartdoc may make direct use of the image and samples tags.
218+
`@category`, `@subCategory`, and `@image` are understood and saved into this json.
219+
Future versions of dartdoc may make direct use of the image tags.
220220

221221
As an example, if we document the class Icon in flutter using the following:
222222

lib/src/generator/generator_utils.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ String generateCategoryJson(Iterable<Categorization> categories, bool pretty) {
2525
if (categorization.hasSubCategoryNames)
2626
'subcategories': categorization.subCategoryNames,
2727
if (categorization.hasImage) 'image': categorization.image,
28-
if (categorization.hasSamples) 'samples': categorization.samples,
2928
}
3029
];
3130

lib/src/generator/templates.runtime_renderers.dart

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -973,13 +973,6 @@ class _Renderer_Categorization extends RendererBase<Categorization> {
973973
self.renderSimpleVariable(c, remainingNames, 'bool'),
974974
getBool: (CT_ c) => c.hasImage == true,
975975
),
976-
'hasSamples': Property(
977-
getValue: (CT_ c) => c.hasSamples,
978-
renderVariable: (CT_ c, Property<CT_> self,
979-
List<String> remainingNames) =>
980-
self.renderSimpleVariable(c, remainingNames, 'bool'),
981-
getBool: (CT_ c) => c.hasSamples == true,
982-
),
983976
'hasSubCategoryNames': Property(
984977
getValue: (CT_ c) => c.hasSubCategoryNames,
985978
renderVariable: (CT_ c, Property<CT_> self,
@@ -1008,28 +1001,6 @@ class _Renderer_Categorization extends RendererBase<Categorization> {
10081001
_render_String(c.image!, ast, r.template, sink, parent: r);
10091002
},
10101003
),
1011-
'samples': Property(
1012-
getValue: (CT_ c) => c.samples,
1013-
renderVariable:
1014-
(CT_ c, Property<CT_> self, List<String> remainingNames) {
1015-
if (remainingNames.isEmpty) {
1016-
return self.getValue(c).toString();
1017-
}
1018-
var name = remainingNames.first;
1019-
var nextProperty =
1020-
_Renderer_String.propertyMap().getValue(name);
1021-
return nextProperty.renderVariable(
1022-
self.getValue(c) as String,
1023-
nextProperty,
1024-
[...remainingNames.skip(1)]);
1025-
},
1026-
isNullValue: (CT_ c) => c.samples == null,
1027-
renderValue: (CT_ c, RendererBase<CT_> r,
1028-
List<MustachioNode> ast, StringSink sink) {
1029-
_render_String(c.samples!, ast, r.template, sink,
1030-
parent: r);
1031-
},
1032-
),
10331004
'subCategoryNames': Property(
10341005
getValue: (CT_ c) => c.subCategoryNames,
10351006
renderVariable: (CT_ c, Property<CT_> self,

lib/src/model/directives/categorization.dart

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import 'package:dartdoc/src/model/model.dart';
77
import 'package:meta/meta.dart';
88

99
final RegExp _categoryRegExp = RegExp(
10-
r'[ ]*{@(category|subCategory|image|samples) (.+?)}[ ]*\n?',
10+
r'[ ]*{@(category|subCategory|image) (.+?)}[ ]*\n?',
1111
multiLine: true);
1212

1313
/// Mixin parsing the `@category` directive for ModelElements.
@@ -33,16 +33,13 @@ mixin Categorization on DocumentationComment implements Indexable {
3333
subCategorySet.add(match[2]!.trim());
3434
case 'image':
3535
_image = match[2]!.trim();
36-
case 'samples':
37-
_samples = match[2]!.trim();
3836
}
3937
return '';
4038
});
4139

4240
_categoryNames = categorySet.toList(growable: false)..sort();
4341
_subCategoryNames = subCategorySet.toList(growable: false)..sort();
4442
_image ??= '';
45-
_samples ??= '';
4643
return rawDocs;
4744
}
4845

@@ -79,17 +76,6 @@ mixin Categorization on DocumentationComment implements Indexable {
7976
return _image;
8077
}
8178

82-
bool get hasSamples => samples?.isNotEmpty ?? false;
83-
String? _samples;
84-
85-
/// Either a URI to documentation with samples,
86-
/// or 'null' if one was not declared.
87-
String? get samples {
88-
// TODO(jcollins-g): avoid side-effect dependency
89-
if (_samples == null) documentationLocal;
90-
return _samples;
91-
}
92-
9379
@visibleForTesting
9480
List<Category> get categories => [
9581
...?categoryNames?.map((n) => package.nameToCategory[n]).whereNotNull()
@@ -102,7 +88,7 @@ mixin Categorization on DocumentationComment implements Indexable {
10288

10389
bool? _hasCategorization;
10490

105-
/// True if categories, subcategories, a documentation icon, or samples were
91+
/// True if categories, subcategories, or a documentation icon were
10692
/// declared.
10793
late final bool hasCategorization = () {
10894
if (_hasCategorization == null) documentationLocal;

lib/src/model/documentation_comment.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,6 @@ mixin DocumentationComment
162162
'category',
163163
'hideConstantImplementations',
164164
'image',
165-
'samples',
166165
'subCategory',
167166

168167
// Common Dart annotations which may decorate named parameters:

0 commit comments

Comments
 (0)