@@ -131,7 +131,6 @@ class HtmlGenerator extends Generator {
131
131
}
132
132
133
133
class HtmlGeneratorOptions implements HtmlOptions {
134
- final String url;
135
134
final String faviconPath;
136
135
final bool prettyIndexJson;
137
136
final String templatesDir;
@@ -146,8 +145,7 @@ class HtmlGeneratorOptions implements HtmlOptions {
146
145
final bool useBaseHref;
147
146
148
147
HtmlGeneratorOptions (
149
- {this .url,
150
- this .relCanonicalPrefix,
148
+ {this .relCanonicalPrefix,
151
149
this .faviconPath,
152
150
String toolVersion,
153
151
this .prettyIndexJson = false ,
@@ -156,109 +154,23 @@ class HtmlGeneratorOptions implements HtmlOptions {
156
154
: this .toolVersion = toolVersion ?? 'unknown' ;
157
155
}
158
156
159
- Future <List <Generator >> initEmptyGenerators (DartdocOptionContext config) async {
160
- return [EmptyGenerator ()];
161
- }
162
-
163
157
/// Initialize and setup the generators.
164
- Future <List <Generator >> initGenerators (GeneratorContext config ) async {
158
+ Future <List <Generator >> initHtmlGenerators (GeneratorContext context ) async {
165
159
// TODO(jcollins-g): Rationalize based on GeneratorContext all the way down
166
160
// through the generators.
167
161
HtmlGeneratorOptions options = HtmlGeneratorOptions (
168
- url: config.hostedUrl,
169
- relCanonicalPrefix: config.relCanonicalPrefix,
162
+ relCanonicalPrefix: context.relCanonicalPrefix,
170
163
toolVersion: dartdocVersion,
171
- faviconPath: config.favicon,
172
- prettyIndexJson: config.prettyIndexJson,
173
- templatesDir: config.templatesDir,
174
- useBaseHref: config.useBaseHref);
175
-
164
+ faviconPath: context.favicon,
165
+ prettyIndexJson: context.prettyIndexJson,
166
+ templatesDir: context.templatesDir,
167
+ useBaseHref: context.useBaseHref);
176
168
return [
177
169
await HtmlGenerator .create (
178
170
options: options,
179
- headers: config .header,
180
- footers: config .footer,
181
- footerTexts: config .footerTextPaths,
171
+ headers: context .header,
172
+ footers: context .footer,
173
+ footerTexts: context .footerTextPaths,
182
174
)
183
175
];
184
176
}
185
-
186
- Uri _sdkFooterCopyrightUri;
187
- Future <void > _setSdkFooterCopyrightUri () async {
188
- if (_sdkFooterCopyrightUri == null ) {
189
- _sdkFooterCopyrightUri = await Isolate .resolvePackageUri (
190
- Uri .parse ('package:dartdoc/resources/sdk_footer_text.html' ));
191
- }
192
- }
193
-
194
- abstract class GeneratorContext implements DartdocOptionContext {
195
- String get favicon => optionSet['favicon' ].valueAt (context);
196
- List <String > get footer => optionSet['footer' ].valueAt (context);
197
-
198
- /// _footerText is only used to construct synthetic options.
199
- // ignore: unused_element
200
- List <String > get _footerText => optionSet['footerText' ].valueAt (context);
201
- List <String > get footerTextPaths =>
202
- optionSet['footerTextPaths' ].valueAt (context);
203
- List <String > get header => optionSet['header' ].valueAt (context);
204
- String get hostedUrl => optionSet['hostedUrl' ].valueAt (context);
205
- bool get prettyIndexJson => optionSet['prettyIndexJson' ].valueAt (context);
206
- String get relCanonicalPrefix =>
207
- optionSet['relCanonicalPrefix' ].valueAt (context);
208
- }
209
-
210
- Future <List <DartdocOption >> createGeneratorOptions () async {
211
- await _setSdkFooterCopyrightUri ();
212
- return < DartdocOption > [
213
- DartdocOptionArgFile <String >('favicon' , null ,
214
- isFile: true ,
215
- help: 'A path to a favicon for the generated docs.' ,
216
- mustExist: true ),
217
- DartdocOptionArgFile <List <String >>('footer' , [],
218
- isFile: true ,
219
- help: 'paths to footer files containing HTML text.' ,
220
- mustExist: true ,
221
- splitCommas: true ),
222
- DartdocOptionArgFile <List <String >>('footerText' , [],
223
- isFile: true ,
224
- help:
225
- 'paths to footer-text files (optional text next to the package name '
226
- 'and version).' ,
227
- mustExist: true ,
228
- splitCommas: true ),
229
- DartdocOptionSyntheticOnly <List <String >>(
230
- 'footerTextPaths' ,
231
- (DartdocSyntheticOption <List <String >> option, Directory dir) {
232
- final List <String > footerTextPaths = < String > [];
233
- final PackageMeta topLevelPackageMeta =
234
- option.root['topLevelPackageMeta' ].valueAt (dir);
235
- // TODO(jcollins-g): Eliminate special casing for SDK and use config file.
236
- if (topLevelPackageMeta.isSdk == true ) {
237
- footerTextPaths
238
- .add (path.canonicalize (_sdkFooterCopyrightUri.toFilePath ()));
239
- }
240
- footerTextPaths.addAll (option.parent['footerText' ].valueAt (dir));
241
- return footerTextPaths;
242
- },
243
- isFile: true ,
244
- help: 'paths to footer-text-files (adding special case for SDK)' ,
245
- mustExist: true ,
246
- ),
247
- DartdocOptionArgFile <List <String >>('header' , [],
248
- isFile: true ,
249
- help: 'paths to header files containing HTML text.' ,
250
- splitCommas: true ),
251
- DartdocOptionArgOnly <String >('hostedUrl' , null ,
252
- help:
253
- 'URL where the docs will be hosted (used to generate the sitemap).' ),
254
- DartdocOptionArgOnly <bool >('prettyIndexJson' , false ,
255
- help:
256
- "Generates `index.json` with indentation and newlines. The file is larger, but it's also easier to diff." ,
257
- negatable: false ),
258
- DartdocOptionArgOnly <String >('relCanonicalPrefix' , null ,
259
- help:
260
- 'If provided, add a rel="canonical" prefixed with provided value. '
261
- 'Consider using if\n building many versions of the docs for public '
262
- 'SEO; learn more at https://goo.gl/gktN6F.' ),
263
- ];
264
- }
0 commit comments