Skip to content

Commit 339efa3

Browse files
authored
Remove @image directive. (#3568)
* Remove @image directive. * Change README to have quotes. * Remove quotes.
1 parent 85cfcc0 commit 339efa3

File tree

5 files changed

+5
-53
lines changed

5 files changed

+5
-53
lines changed

README.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -215,16 +215,14 @@ 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`, and `@image` are understood and saved into this json.
219-
Future versions of dartdoc may make direct use of the image tags.
218+
`@category`, and `@subCategory` are understood and saved into this json.
220219

221220
As an example, if we document the class Icon in flutter using the following:
222221

223222
```dart
224223
/// {@category Basics}
225-
/// {@category Assets, Images, and Icons}
224+
/// {@category Assets and Icons}
226225
/// {@subCategory Information displays}
227-
/// {@image <image alt='' src='/images/catalog-widget-placeholder.png'>}
228226
class Icon extends StatelessWidget {}
229227
```
230228

@@ -237,13 +235,12 @@ that will result in the following json:
237235
"href": "widgets/Icon-class.html",
238236
"type": "class",
239237
"categories": [
240-
"Assets, Images, and Icons",
238+
"Assets and Icons",
241239
"Basics"
242240
],
243241
"subcategories": [
244242
"Information displays"
245243
],
246-
"image": "<image alt='' src='/images/catalog-widget-placeholder.png'>"
247244
}
248245
```
249246

lib/src/generator/generator_utils.dart

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

lib/src/generator/templates.runtime_renderers.dart

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -966,41 +966,13 @@ class _Renderer_Categorization extends RendererBase<Categorization> {
966966
self.renderSimpleVariable(c, remainingNames, 'bool'),
967967
getBool: (CT_ c) => c.hasCategoryNames == true,
968968
),
969-
'hasImage': Property(
970-
getValue: (CT_ c) => c.hasImage,
971-
renderVariable: (CT_ c, Property<CT_> self,
972-
List<String> remainingNames) =>
973-
self.renderSimpleVariable(c, remainingNames, 'bool'),
974-
getBool: (CT_ c) => c.hasImage == true,
975-
),
976969
'hasSubCategoryNames': Property(
977970
getValue: (CT_ c) => c.hasSubCategoryNames,
978971
renderVariable: (CT_ c, Property<CT_> self,
979972
List<String> remainingNames) =>
980973
self.renderSimpleVariable(c, remainingNames, 'bool'),
981974
getBool: (CT_ c) => c.hasSubCategoryNames == true,
982975
),
983-
'image': Property(
984-
getValue: (CT_ c) => c.image,
985-
renderVariable:
986-
(CT_ c, Property<CT_> self, List<String> remainingNames) {
987-
if (remainingNames.isEmpty) {
988-
return self.getValue(c).toString();
989-
}
990-
var name = remainingNames.first;
991-
var nextProperty =
992-
_Renderer_String.propertyMap().getValue(name);
993-
return nextProperty.renderVariable(
994-
self.getValue(c) as String,
995-
nextProperty,
996-
[...remainingNames.skip(1)]);
997-
},
998-
isNullValue: (CT_ c) => c.image == null,
999-
renderValue: (CT_ c, RendererBase<CT_> r,
1000-
List<MustachioNode> ast, StringSink sink) {
1001-
_render_String(c.image!, ast, r.template, sink, parent: r);
1002-
},
1003-
),
1004976
'subCategoryNames': Property(
1005977
getValue: (CT_ c) => c.subCategoryNames,
1006978
renderVariable: (CT_ c, Property<CT_> self,

lib/src/model/directives/categorization.dart

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@ import 'package:collection/collection.dart';
66
import 'package:dartdoc/src/model/model.dart';
77
import 'package:meta/meta.dart';
88

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

1312
/// Mixin parsing the `@category` directive for ModelElements.
1413
mixin Categorization on DocumentationComment implements Indexable {
@@ -31,15 +30,12 @@ mixin Categorization on DocumentationComment implements Indexable {
3130
categorySet.add(match[2]!.trim());
3231
case 'subCategory':
3332
subCategorySet.add(match[2]!.trim());
34-
case 'image':
35-
_image = match[2]!.trim();
3633
}
3734
return '';
3835
});
3936

4037
_categoryNames = categorySet.toList(growable: false)..sort();
4138
_subCategoryNames = subCategorySet.toList(growable: false)..sort();
42-
_image ??= '';
4339
return rawDocs;
4440
}
4541

@@ -65,17 +61,6 @@ mixin Categorization on DocumentationComment implements Indexable {
6561
return _categoryNames;
6662
}
6763

68-
bool get hasImage => image!.isNotEmpty;
69-
String? _image;
70-
71-
/// Either a URI to a defined image,
72-
/// or 'null' if one was not declared.
73-
String? get image {
74-
// TODO(jcollins-g): avoid side-effect dependency
75-
if (_image == null) documentationLocal;
76-
return _image;
77-
}
78-
7964
@visibleForTesting
8065
List<Category> get categories => [
8166
...?categoryNames?.map((n) => package.nameToCategory[n]).whereNotNull()

lib/src/model/documentation_comment.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,6 @@ mixin DocumentationComment
158158
'canonicalFor',
159159
'category',
160160
'hideConstantImplementations',
161-
'image',
162161
'subCategory',
163162

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

0 commit comments

Comments
 (0)