@@ -56,90 +56,16 @@ class DartdocGeneratorBackendOptions implements TemplateOptions {
56
56
packageOrder = context.packageOrder;
57
57
}
58
58
59
- /// An interface for classes which are responsible for outputing the generated
60
- /// documentation.
61
- abstract interface class GeneratorBackend {
62
- FileWriter get writer;
63
-
64
- /// Emits JSON describing the [categories] defined by the package.
65
- void generateCategoryJson (List <Categorization > categories);
66
-
67
- /// Emits a JSON catalog of [indexedElements] for use with a search index.
68
- void generateSearchIndex (List <Indexable > indexedElements);
69
-
70
- /// Emits documentation content for the [package] .
71
- void generatePackage (PackageGraph packageGraph, Package package);
72
-
73
- /// Emits documentation content for the [category] .
74
- void generateCategory (PackageGraph packageGraph, Category category);
75
-
76
- /// Emits documentation content for the [library] .
77
- void generateLibrary (PackageGraph packageGraph, Library library);
78
-
79
- /// Emits documentation content for the [clazz] .
80
- void generateClass (PackageGraph packageGraph, Library library, Class clazz);
81
-
82
- /// Emits documentation content for the [eNum] .
83
- void generateEnum (PackageGraph packageGraph, Library library, Enum eNum);
84
-
85
- /// Emits documentation content for the [extension] .
86
- void generateExtension (
87
- PackageGraph packageGraph, Library library, Extension extension );
88
-
89
- /// Emits documentation content for the [extensionType] .
90
- void generateExtensionType (
91
- PackageGraph packageGraph, Library library, ExtensionType extensionType);
92
-
93
- /// Emits documentation content for the [mixin] .
94
- void generateMixin (PackageGraph packageGraph, Library library, Mixin mixin );
95
-
96
- /// Emits documentation content for the [constructor] .
97
- void generateConstructor (PackageGraph packageGraph, Library library,
98
- Constructable constructable, Constructor constructor);
99
-
100
- /// Emits documentation content for the [field] .
101
- void generateConstant (
102
- PackageGraph packageGraph, Library library, Container clazz, Field field);
103
-
104
- /// Emits documentation content for the [field] .
105
- void generateProperty (
106
- PackageGraph packageGraph, Library library, Container clazz, Field field);
107
-
108
- /// Emits documentation content for the [method] .
109
- void generateMethod (PackageGraph packageGraph, Library library,
110
- Container clazz, Method method);
111
-
112
- /// Emits documentation content for the [function] .
113
- void generateFunction (
114
- PackageGraph packageGraph, Library library, ModelFunction function);
115
-
116
- /// Emits documentation content for the [constant] .
117
- void generateTopLevelConstant (
118
- PackageGraph packageGraph, Library library, TopLevelVariable constant);
119
-
120
- /// Emits documentation content for the [property] .
121
- void generateTopLevelProperty (
122
- PackageGraph packageGraph, Library library, TopLevelVariable property);
123
-
124
- /// Emits documentation content for the [typedef] .
125
- void generateTypeDef (
126
- PackageGraph packageGraph, Library library, Typedef typedef );
127
-
128
- /// Emits files not specific to a Dart language element (like a favicon, etc).
129
- Future <void > generateAdditionalFiles ();
130
- }
131
-
132
- /// Base [GeneratorBackend] for Dartdoc's supported formats.
133
- abstract class GeneratorBackendBase implements GeneratorBackend {
59
+ /// Outputs generated documentation.
60
+ abstract class GeneratorBackend {
134
61
final DartdocGeneratorBackendOptions options;
135
62
final Templates templates;
136
63
137
- @override
138
64
final FileWriter writer;
139
65
final ResourceProvider resourceProvider;
140
66
final p.Context _pathContext;
141
67
142
- GeneratorBackendBase (
68
+ GeneratorBackend (
143
69
this .options, this .templates, this .writer, this .resourceProvider)
144
70
: _pathContext = resourceProvider.pathContext;
145
71
@@ -164,7 +90,7 @@ abstract class GeneratorBackendBase implements GeneratorBackend {
164
90
element: element is Warnable ? element : null );
165
91
}
166
92
167
- @override
93
+ /// Emits JSON describing the [categories] defined by the package.
168
94
void generateCategoryJson (List <Categorization > categories) {
169
95
var json = '[]' ;
170
96
if (categories.isNotEmpty) {
@@ -178,7 +104,7 @@ abstract class GeneratorBackendBase implements GeneratorBackend {
178
104
writer.write (_pathContext.join ('categories.json' ), '$json \n ' );
179
105
}
180
106
181
- @override
107
+ /// Emits a JSON catalog of [indexedElements] for use with a search index.
182
108
void generateSearchIndex (List <Indexable > indexedElements) {
183
109
var json = generator_util.generateSearchIndexJson (
184
110
indexedElements,
@@ -191,28 +117,23 @@ abstract class GeneratorBackendBase implements GeneratorBackend {
191
117
writer.write (_pathContext.join ('index.json' ), '$json \n ' );
192
118
}
193
119
194
- @override
120
+ /// Emits documentation content for the [category] .
195
121
void generateCategory (PackageGraph packageGraph, Category category) {
196
122
var data = CategoryTemplateData (options, packageGraph, category);
197
123
var content = templates.renderCategory (data);
198
124
write (writer, category.filePath, data, content);
199
125
runtimeStats.incrementAccumulator ('writtenCategoryFileCount' );
200
126
}
201
127
202
- @override
128
+ /// Emits documentation content for the [clazz] .
203
129
void generateClass (PackageGraph packageGraph, Library library, Class clazz) {
204
130
var data = ClassTemplateData (options, packageGraph, library, clazz);
205
131
var content = templates.renderClass (data);
206
132
write (writer, clazz.filePath, data, content);
207
133
runtimeStats.incrementAccumulator ('writtenClassFileCount' );
208
134
}
209
135
210
- @override
211
- void generateConstant (PackageGraph packageGraph, Library library,
212
- Container clazz, Field field) =>
213
- generateProperty (packageGraph, library, clazz, field);
214
-
215
- @override
136
+ /// Emits documentation content for the [constructor] .
216
137
void generateConstructor (PackageGraph packageGraph, Library library,
217
138
Constructable constructable, Constructor constructor) {
218
139
var data = ConstructorTemplateData (
@@ -222,15 +143,15 @@ abstract class GeneratorBackendBase implements GeneratorBackend {
222
143
runtimeStats.incrementAccumulator ('writtenConstructorFileCount' );
223
144
}
224
145
225
- @override
146
+ /// Emits documentation content for the [eNum] .
226
147
void generateEnum (PackageGraph packageGraph, Library library, Enum eNum) {
227
148
var data = EnumTemplateData (options, packageGraph, library, eNum);
228
149
var content = templates.renderEnum (data);
229
150
write (writer, eNum.filePath, data, content);
230
151
runtimeStats.incrementAccumulator ('writtenEnumFileCount' );
231
152
}
232
153
233
- @override
154
+ /// Emits documentation content for the [extension] .
234
155
void generateExtension (
235
156
PackageGraph packageGraph, Library library, Extension extension ) {
236
157
var data = ExtensionTemplateData (options, packageGraph, library, extension );
@@ -239,7 +160,7 @@ abstract class GeneratorBackendBase implements GeneratorBackend {
239
160
runtimeStats.incrementAccumulator ('writtenExtensionFileCount' );
240
161
}
241
162
242
- @override
163
+ /// Emits documentation content for the [extensionType] .
243
164
void generateExtensionType (
244
165
PackageGraph packageGraph, Library library, ExtensionType extensionType) {
245
166
var data = ExtensionTypeTemplateData (
@@ -249,7 +170,7 @@ abstract class GeneratorBackendBase implements GeneratorBackend {
249
170
runtimeStats.incrementAccumulator ('writtenExtensionTypeFileCount' );
250
171
}
251
172
252
- @override
173
+ /// Emits documentation content for the [function] .
253
174
void generateFunction (
254
175
PackageGraph packageGraph, Library library, ModelFunction function) {
255
176
var data = FunctionTemplateData (options, packageGraph, library, function);
@@ -258,15 +179,15 @@ abstract class GeneratorBackendBase implements GeneratorBackend {
258
179
runtimeStats.incrementAccumulator ('writtenFunctionFileCount' );
259
180
}
260
181
261
- @override
182
+ /// Emits documentation content for the [library] .
262
183
void generateLibrary (PackageGraph packageGraph, Library library) {
263
184
var data = LibraryTemplateData (options, packageGraph, library);
264
185
var content = templates.renderLibrary (data);
265
186
write (writer, library.filePath, data, content);
266
187
runtimeStats.incrementAccumulator ('writtenLibraryFileCount' );
267
188
}
268
189
269
- @override
190
+ /// Emits documentation content for the [method] .
270
191
void generateMethod (PackageGraph packageGraph, Library library,
271
192
Container clazz, Method method) {
272
193
var data =
@@ -276,23 +197,23 @@ abstract class GeneratorBackendBase implements GeneratorBackend {
276
197
runtimeStats.incrementAccumulator ('writtenMethodFileCount' );
277
198
}
278
199
279
- @override
200
+ /// Emits documentation content for the [mixin] .
280
201
void generateMixin (PackageGraph packageGraph, Library library, Mixin mixin ) {
281
202
var data = MixinTemplateData (options, packageGraph, library, mixin );
282
203
var content = templates.renderMixin (data);
283
204
write (writer, mixin .filePath, data, content);
284
205
runtimeStats.incrementAccumulator ('writtenMixinFileCount' );
285
206
}
286
207
287
- @override
208
+ /// Emits documentation content for the [package] .
288
209
void generatePackage (PackageGraph packageGraph, Package package) {
289
210
var data = PackageTemplateData (options, packageGraph, package);
290
211
var content = templates.renderIndex (data);
291
212
write (writer, package.filePath, data, content);
292
213
runtimeStats.incrementAccumulator ('writtenPackageFileCount' );
293
214
}
294
215
295
- @override
216
+ /// Emits documentation content for the [field] .
296
217
void generateProperty (PackageGraph packageGraph, Library library,
297
218
Container clazz, Field field) {
298
219
var data =
@@ -302,12 +223,7 @@ abstract class GeneratorBackendBase implements GeneratorBackend {
302
223
runtimeStats.incrementAccumulator ('writtenPropertyFileCount' );
303
224
}
304
225
305
- @override
306
- void generateTopLevelConstant (PackageGraph packageGraph, Library library,
307
- TopLevelVariable constant) =>
308
- generateTopLevelProperty (packageGraph, library, constant);
309
-
310
- @override
226
+ /// Emits documentation content for the [property] .
311
227
void generateTopLevelProperty (
312
228
PackageGraph packageGraph, Library library, TopLevelVariable property) {
313
229
var data =
@@ -317,7 +233,7 @@ abstract class GeneratorBackendBase implements GeneratorBackend {
317
233
runtimeStats.incrementAccumulator ('writtenTopLevelPropertyFileCount' );
318
234
}
319
235
320
- @override
236
+ /// Emits documentation content for the [typedef] .
321
237
void generateTypeDef (
322
238
PackageGraph packageGraph, Library library, Typedef typedef ) {
323
239
var data = TypedefTemplateData (options, packageGraph, library, typedef );
@@ -326,6 +242,6 @@ abstract class GeneratorBackendBase implements GeneratorBackend {
326
242
runtimeStats.incrementAccumulator ('writtenTypedefFileCount' );
327
243
}
328
244
329
- @override
330
- Future <void > generateAdditionalFiles () async {}
245
+ /// Emits files not specific to a Dart language element (like a favicon, etc).
246
+ Future <void > generateAdditionalFiles ();
331
247
}
0 commit comments