@@ -21,52 +21,52 @@ import 'templates.dart';
2121
2222class HtmlGeneratorInstance implements HtmlOptions {
2323 final HtmlGeneratorOptions _options;
24-
25- String get url => _options.url;
2624 final Templates _templates;
27- final Package package ;
28- final Directory out ;
29- final List <ModelElement > documentedElements = < ModelElement > [];
25+ final Package _package ;
26+ final String _outputDirectoryPath ;
27+ final List <ModelElement > _documentedElements = < ModelElement > [];
3028 final StreamController <File > _onFileCreated;
29+
3130 @override
3231 String get relCanonicalPrefix => _options.relCanonicalPrefix;
32+
3333 @override
3434 String get toolVersion => _options.toolVersion;
35- String get faviconPath => _options.faviconPath;
36- bool get useCategories => _options.useCategories ;
37- bool get prettyIndexJson => _options.prettyIndexJson ;
35+
36+ String get _faviconPath => _options.faviconPath ;
37+ bool get _useCategories => _options.useCategories ;
3838
3939 // Protect against bugs in canonicalization by tracking what files we
4040 // write.
4141 final Set <String > writtenFiles = new Set <String >();
4242
43- HtmlGeneratorInstance (this ._options, this ._templates, this .package, this .out ,
44- this ._onFileCreated);
43+ HtmlGeneratorInstance (this ._options, this ._templates, this ._package ,
44+ this ._outputDirectoryPath, this . _onFileCreated);
4545
4646 Future generate () async {
47- if (! out.existsSync ()) out.createSync ();
48-
49- if (package != null ) {
47+ if (_package != null ) {
5048 _generateDocs ();
5149 _generateSearchIndex ();
5250 }
5351
5452 await _copyResources ();
55- if (faviconPath != null ) {
56- var bytes = new File (faviconPath ).readAsBytesSync ();
53+ if (_faviconPath != null ) {
54+ var bytes = new File (_faviconPath ).readAsBytesSync ();
5755 // Allow overwrite of favicon.
58- String filename = path.join (out.path, 'static-assets' , 'favicon.png' );
56+ String filename =
57+ path.join (_outputDirectoryPath, 'static-assets' , 'favicon.png' );
5958 writtenFiles.remove (filename);
60- _writeFile (path. join (out.path, 'static-assets' , 'favicon.png' ) , bytes);
59+ _writeFile (filename , bytes);
6160 }
6261 }
6362
6463 void _generateSearchIndex () {
65- var encoder =
66- prettyIndexJson ? new JsonEncoder .withIndent (' ' ) : new JsonEncoder ();
64+ var encoder = _options.prettyIndexJson
65+ ? new JsonEncoder .withIndent (' ' )
66+ : new JsonEncoder ();
6767
6868 final List <Map > indexItems =
69- documentedElements .where ((e) => e.isCanonical).map ((ModelElement e) {
69+ _documentedElements .where ((e) => e.isCanonical).map ((ModelElement e) {
7070 Map data = {
7171 'name' : e.name,
7272 'qualifiedName' : e.name,
@@ -95,91 +95,91 @@ class HtmlGeneratorInstance implements HtmlOptions {
9595 });
9696
9797 String json = encoder.convert (indexItems);
98- _writeFile (path.join (out.path , 'index.json' ), '${json }\n ' );
98+ _writeFile (path.join (_outputDirectoryPath , 'index.json' ), '${json }\n ' );
9999 }
100100
101101 void _generateDocs () {
102- if (package == null ) return ;
102+ if (_package == null ) return ;
103103
104104 generatePackage ();
105105
106- for (var lib in filterNonDocumented (package .libraries)) {
106+ for (var lib in filterNonDocumented (_package .libraries)) {
107107 // if (lib.name != 'extract_messages') continue;
108- generateLibrary (package , lib);
108+ generateLibrary (_package , lib);
109109
110110 for (var clazz in filterNonDocumented (lib.allClasses)) {
111- generateClass (package , lib, clazz);
111+ generateClass (_package , lib, clazz);
112112
113113 for (var constructor in filterNonDocumented (clazz.constructors)) {
114114 if (! constructor.isCanonical) continue ;
115- generateConstructor (package , lib, clazz, constructor);
115+ generateConstructor (_package , lib, clazz, constructor);
116116 }
117117
118118 for (var constant in filterNonDocumented (clazz.constants)) {
119119 if (! constant.isCanonical) continue ;
120- generateConstant (package , lib, clazz, constant);
120+ generateConstant (_package , lib, clazz, constant);
121121 }
122122
123123 for (var property in filterNonDocumented (clazz.staticProperties)) {
124124 if (! property.isCanonical) continue ;
125- generateProperty (package , lib, clazz, property);
125+ generateProperty (_package , lib, clazz, property);
126126 }
127127
128128 for (var property in filterNonDocumented (clazz.propertiesForPages)) {
129129 if (! property.isCanonical) continue ;
130- generateProperty (package , lib, clazz, property);
130+ generateProperty (_package , lib, clazz, property);
131131 }
132132
133133 for (var method in filterNonDocumented (clazz.methodsForPages)) {
134134 if (! method.isCanonical) continue ;
135- generateMethod (package , lib, clazz, method);
135+ generateMethod (_package , lib, clazz, method);
136136 }
137137
138138 for (var operator in filterNonDocumented (clazz.operatorsForPages)) {
139139 if (! operator .isCanonical) continue ;
140- generateMethod (package , lib, clazz, operator );
140+ generateMethod (_package , lib, clazz, operator );
141141 }
142142
143143 for (var method in filterNonDocumented (clazz.staticMethods)) {
144144 if (! method.isCanonical) continue ;
145- generateMethod (package , lib, clazz, method);
145+ generateMethod (_package , lib, clazz, method);
146146 }
147147 }
148148
149149 for (var eNum in filterNonDocumented (lib.enums)) {
150- generateEnum (package , lib, eNum);
150+ generateEnum (_package , lib, eNum);
151151 for (var property in filterNonDocumented (eNum.propertiesForPages)) {
152- generateProperty (package , lib, eNum, property);
152+ generateProperty (_package , lib, eNum, property);
153153 }
154154 for (var operator in filterNonDocumented (eNum.operatorsForPages)) {
155- generateMethod (package , lib, eNum, operator );
155+ generateMethod (_package , lib, eNum, operator );
156156 }
157157 for (var method in filterNonDocumented (eNum.methodsForPages)) {
158- generateMethod (package , lib, eNum, method);
158+ generateMethod (_package , lib, eNum, method);
159159 }
160160 }
161161
162162 for (var constant in filterNonDocumented (lib.constants)) {
163- generateTopLevelConstant (package , lib, constant);
163+ generateTopLevelConstant (_package , lib, constant);
164164 }
165165
166166 for (var property in filterNonDocumented (lib.properties)) {
167- generateTopLevelProperty (package , lib, property);
167+ generateTopLevelProperty (_package , lib, property);
168168 }
169169
170170 for (var function in filterNonDocumented (lib.functions)) {
171- generateFunction (package , lib, function);
171+ generateFunction (_package , lib, function);
172172 }
173173
174174 for (var typeDef in filterNonDocumented (lib.typedefs)) {
175- generateTypeDef (package , lib, typeDef);
175+ generateTypeDef (_package , lib, typeDef);
176176 }
177177 }
178178 }
179179
180180 void generatePackage () {
181- TemplateData data = new PackageTemplateData (this , package, useCategories );
182- logInfo ('documenting ${package .name }' );
181+ TemplateData data = new PackageTemplateData (this , _package, _useCategories );
182+ logInfo ('documenting ${_package .name }' );
183183
184184 _build ('index.html' , _templates.indexTemplate, data);
185185 }
@@ -191,7 +191,7 @@ class HtmlGeneratorInstance implements HtmlOptions {
191191 package.warnOnElement (lib, PackageWarning .noLibraryLevelDocs);
192192 }
193193 TemplateData data =
194- new LibraryTemplateData (this , package, lib, useCategories );
194+ new LibraryTemplateData (this , package, lib, _useCategories );
195195
196196 _build (path.join (lib.dirName, '${lib .fileName }' ),
197197 _templates.libraryTemplate, data);
@@ -285,20 +285,20 @@ class HtmlGeneratorInstance implements HtmlOptions {
285285 'encountered $resourcePath ' );
286286 }
287287 String destFileName = resourcePath.substring (prefix.length);
288- _writeFile (path.join (out.path , 'static-assets' , destFileName),
288+ _writeFile (path.join (_outputDirectoryPath , 'static-assets' , destFileName),
289289 await loader.loadAsBytes (resourcePath));
290290 }
291291 }
292292
293293 void _build (String filename, TemplateRenderer template, TemplateData data) {
294- String fullName = path.join (out.path , filename);
294+ String fullName = path.join (_outputDirectoryPath , filename);
295295
296296 String content = template (data,
297297 assumeNullNonExistingProperty: false , errorOnMissingProperty: true );
298298
299299 _writeFile (fullName, content);
300300 if (data.self is ModelElement ) {
301- documentedElements .add (data.self);
301+ _documentedElements .add (data.self);
302302 }
303303 }
304304
0 commit comments