@@ -12,8 +12,6 @@ import '../model.dart';
1212import 'html_generator_instance.dart' ;
1313import 'templates.dart' ;
1414
15- String dartdocVersion = 'unknown' ;
16-
1715typedef String Renderer (String input);
1816
1917// Generation order for libraries:
@@ -35,13 +33,8 @@ typedef String Renderer(String input);
3533// methods
3634
3735class HtmlGenerator extends Generator {
38- final String _url;
39- final String _relCanonicalPrefix;
4036 final Templates _templates;
41- final String _toolVersion;
42- final String faviconPath;
43- final bool useCategories;
44- final bool prettyIndexJson;
37+ final HtmlGeneratorOptions _options;
4538
4639 final StreamController <File > _onFileCreated =
4740 new StreamController (sync : true );
@@ -51,38 +44,40 @@ class HtmlGenerator extends Generator {
5144
5245 /// [url] - optional URL for where the docs will be hosted.
5346 static Future <HtmlGenerator > create (
54- {String url ,
47+ {HtmlGeneratorOptions options ,
5548 List <String > headers,
56- List <String > footers,
57- String relCanonicalPrefix,
58- String toolVersion,
59- String faviconPath,
60- bool useCategories: false ,
61- bool prettyIndexJson: false }) async {
49+ List <String > footers}) async {
6250 var templates =
6351 await Templates .create (headerPaths: headers, footerPaths: footers);
6452
65- if (toolVersion == null ) {
66- toolVersion = 'unknown' ;
67- }
68-
69- return new HtmlGenerator ._(url, relCanonicalPrefix, templates, toolVersion,
70- faviconPath: faviconPath,
71- useCategories: useCategories,
72- prettyIndexJson: prettyIndexJson);
53+ return new HtmlGenerator ._(
54+ options ?? new HtmlGeneratorOptions (), templates);
7355 }
7456
75- HtmlGenerator ._(
76- this ._url, this ._relCanonicalPrefix, this ._templates, this ._toolVersion,
77- {this .faviconPath, this .useCategories, this .prettyIndexJson: false });
57+ HtmlGenerator ._(this ._options, this ._templates);
7858
7959 @override
8060 Future generate (Package package, Directory out) {
81- return new HtmlGeneratorInstance (_toolVersion, _url, _templates, package,
82- out, _onFileCreated, _relCanonicalPrefix,
83- faviconPath: faviconPath,
84- useCategories: useCategories,
85- prettyIndexJson: prettyIndexJson)
61+ return new HtmlGeneratorInstance (
62+ _options, _templates, package, out, _onFileCreated)
8663 .generate ();
8764 }
8865}
66+
67+ class HtmlGeneratorOptions {
68+ final String url;
69+ final String relCanonicalPrefix;
70+ final String faviconPath;
71+ final String toolVersion;
72+ final bool useCategories;
73+ final bool prettyIndexJson;
74+
75+ HtmlGeneratorOptions (
76+ {this .url,
77+ this .relCanonicalPrefix,
78+ this .faviconPath,
79+ String toolVersion,
80+ this .useCategories: false ,
81+ this .prettyIndexJson: false })
82+ : this .toolVersion = toolVersion ?? 'unknown' ;
83+ }
0 commit comments