@@ -12,8 +12,6 @@ import '../model.dart';
12
12
import 'html_generator_instance.dart' ;
13
13
import 'templates.dart' ;
14
14
15
- String dartdocVersion = 'unknown' ;
16
-
17
15
typedef String Renderer (String input);
18
16
19
17
// Generation order for libraries:
@@ -35,13 +33,8 @@ typedef String Renderer(String input);
35
33
// methods
36
34
37
35
class HtmlGenerator extends Generator {
38
- final String _url;
39
- final String _relCanonicalPrefix;
40
36
final Templates _templates;
41
- final String _toolVersion;
42
- final String faviconPath;
43
- final bool useCategories;
44
- final bool prettyIndexJson;
37
+ final HtmlGeneratorOptions _options;
45
38
46
39
final StreamController <File > _onFileCreated =
47
40
new StreamController (sync : true );
@@ -51,38 +44,40 @@ class HtmlGenerator extends Generator {
51
44
52
45
/// [url] - optional URL for where the docs will be hosted.
53
46
static Future <HtmlGenerator > create (
54
- {String url ,
47
+ {HtmlGeneratorOptions options ,
55
48
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 {
62
50
var templates =
63
51
await Templates .create (headerPaths: headers, footerPaths: footers);
64
52
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);
73
55
}
74
56
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);
78
58
79
59
@override
80
60
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)
86
63
.generate ();
87
64
}
88
65
}
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