@@ -147,7 +147,7 @@ class DartDoc extends PackageBuilder {
147
147
}
148
148
}
149
149
150
- Package package ;
150
+ PackageGraph packageGraph ;
151
151
152
152
/// Generate DartDoc documentation.
153
153
///
@@ -157,23 +157,23 @@ class DartDoc extends PackageBuilder {
157
157
Future <DartDocResults > generateDocs () async {
158
158
Stopwatch _stopwatch = new Stopwatch ()..start ();
159
159
double seconds;
160
- package = await buildPackage ();
160
+ packageGraph = await buildPackageGraph ();
161
161
seconds = _stopwatch.elapsedMilliseconds / 1000.0 ;
162
162
logInfo (
163
- "Initialized dartdoc with ${package .libraries .length } librar${package .libraries .length == 1 ? 'y' : 'ies' } "
163
+ "Initialized dartdoc with ${packageGraph .libraries .length } librar${packageGraph .libraries .length == 1 ? 'y' : 'ies' } "
164
164
"in ${seconds .toStringAsFixed (1 )} seconds" );
165
165
_stopwatch.reset ();
166
166
167
167
// Create the out directory.
168
168
if (! outputDir.existsSync ()) outputDir.createSync (recursive: true );
169
169
170
170
for (var generator in generators) {
171
- await generator.generate (package , outputDir.path);
171
+ await generator.generate (packageGraph , outputDir.path);
172
172
writtenFiles.addAll (generator.writtenFiles.map (path.normalize));
173
173
}
174
- if (config.validateLinks) validateLinks (package , outputDir.path);
175
- int warnings = package .packageWarningCounter.warningCount;
176
- int errors = package .packageWarningCounter.errorCount;
174
+ if (config.validateLinks) validateLinks (packageGraph , outputDir.path);
175
+ int warnings = packageGraph .packageWarningCounter.warningCount;
176
+ int errors = packageGraph .packageWarningCounter.errorCount;
177
177
if (warnings == 0 && errors == 0 ) {
178
178
logInfo ("no issues found" );
179
179
} else {
@@ -183,23 +183,24 @@ class DartDoc extends PackageBuilder {
183
183
184
184
seconds = _stopwatch.elapsedMilliseconds / 1000.0 ;
185
185
logInfo (
186
- "Documented ${package .publicLibraries .length } public librar${package .publicLibraries .length == 1 ? 'y' : 'ies' } "
186
+ "Documented ${packageGraph .publicLibraries .length } public librar${packageGraph .publicLibraries .length == 1 ? 'y' : 'ies' } "
187
187
"in ${seconds .toStringAsFixed (1 )} seconds" );
188
188
189
- if (package .publicLibraries.isEmpty) {
189
+ if (packageGraph .publicLibraries.isEmpty) {
190
190
throw new DartDocFailure (
191
191
"dartdoc could not find any libraries to document. Run `pub get` and try again." );
192
192
}
193
193
194
- if (package .packageWarningCounter.errorCount > 0 ) {
194
+ if (packageGraph .packageWarningCounter.errorCount > 0 ) {
195
195
throw new DartDocFailure ("dartdoc encountered errors while processing" );
196
196
}
197
197
198
- return new DartDocResults (packageMeta, package , outputDir);
198
+ return new DartDocResults (packageMeta, packageGraph , outputDir);
199
199
}
200
200
201
201
/// Warn on file paths.
202
- void _warn (Package package, PackageWarning kind, String warnOn, String origin,
202
+ void _warn (PackageGraph packageGraph, PackageWarning kind, String warnOn,
203
+ String origin,
203
204
{String referredFrom}) {
204
205
// Ordinarily this would go in [Package.warn], but we don't actually know what
205
206
// ModelElement to warn on yet.
@@ -235,14 +236,15 @@ class DartDoc extends PackageBuilder {
235
236
}
236
237
237
238
if (referredFromElements.isEmpty && referredFrom == 'index.html' )
238
- referredFromElements.add (package );
239
+ referredFromElements.add (packageGraph );
239
240
String message = warnOn;
240
241
if (referredFrom == 'index.json' ) message = '$warnOn (from index.json)' ;
241
- package .warnOnElement (warnOnElement, kind,
242
+ packageGraph .warnOnElement (warnOnElement, kind,
242
243
message: message, referredFrom: referredFromElements);
243
244
}
244
245
245
- void _doOrphanCheck (Package package, String origin, Set <String > visited) {
246
+ void _doOrphanCheck (
247
+ PackageGraph packageGraph, String origin, Set <String > visited) {
246
248
String normalOrigin = path.normalize (origin);
247
249
String staticAssets = path.joinAll ([normalOrigin, 'static-assets' , '' ]);
248
250
String indexJson = path.joinAll ([normalOrigin, 'index.json' ]);
@@ -264,15 +266,16 @@ class DartDoc extends PackageBuilder {
264
266
if (visited.contains (fullPath)) continue ;
265
267
if (! writtenFiles.contains (fullPath)) {
266
268
// This isn't a file we wrote (this time); don't claim we did.
267
- _warn (package , PackageWarning .unknownFile, fullPath, normalOrigin);
269
+ _warn (packageGraph , PackageWarning .unknownFile, fullPath, normalOrigin);
268
270
} else {
269
- _warn (package, PackageWarning .orphanedFile, fullPath, normalOrigin);
271
+ _warn (
272
+ packageGraph, PackageWarning .orphanedFile, fullPath, normalOrigin);
270
273
}
271
274
_onCheckProgress.add (fullPath);
272
275
}
273
276
274
277
if (! foundIndexJson) {
275
- _warn (package , PackageWarning .brokenLink, indexJson, normalOrigin);
278
+ _warn (packageGraph , PackageWarning .brokenLink, indexJson, normalOrigin);
276
279
_onCheckProgress.add (indexJson);
277
280
}
278
281
}
@@ -300,7 +303,7 @@ class DartDoc extends PackageBuilder {
300
303
}
301
304
302
305
void _doSearchIndexCheck (
303
- Package package , String origin, Set <String > visited) {
306
+ PackageGraph packageGraph , String origin, Set <String > visited) {
304
307
String fullPath = path.joinAll ([origin, 'index.json' ]);
305
308
String indexPath = path.joinAll ([origin, 'index.html' ]);
306
309
File file = new File ("$fullPath " );
@@ -319,7 +322,7 @@ class DartDoc extends PackageBuilder {
319
322
if (entry.containsKey ('href' )) {
320
323
String entryPath = path.joinAll ([origin, entry['href' ]]);
321
324
if (! visited.contains (entryPath)) {
322
- _warn (package , PackageWarning .brokenLink, entryPath,
325
+ _warn (packageGraph , PackageWarning .brokenLink, entryPath,
323
326
path.normalize (origin),
324
327
referredFrom: fullPath);
325
328
}
@@ -329,14 +332,14 @@ class DartDoc extends PackageBuilder {
329
332
// Missing from search index
330
333
Set <String > missing_from_search = visited.difference (found);
331
334
for (String s in missing_from_search) {
332
- _warn (package , PackageWarning .missingFromSearchIndex, s,
335
+ _warn (packageGraph , PackageWarning .missingFromSearchIndex, s,
333
336
path.normalize (origin),
334
337
referredFrom: fullPath);
335
338
}
336
339
}
337
340
338
- void _doCheck (
339
- Package package, String origin, Set < String > visited, String pathToCheck,
341
+ void _doCheck (PackageGraph packageGraph, String origin, Set < String > visited,
342
+ String pathToCheck,
340
343
[String source, String fullPath]) {
341
344
if (fullPath == null ) {
342
345
fullPath = path.joinAll ([origin, pathToCheck]);
@@ -345,7 +348,7 @@ class DartDoc extends PackageBuilder {
345
348
346
349
Tuple2 stringLinksAndHref = _getStringLinksAndHref (fullPath);
347
350
if (stringLinksAndHref == null ) {
348
- _warn (package , PackageWarning .brokenLink, pathToCheck,
351
+ _warn (packageGraph , PackageWarning .brokenLink, pathToCheck,
349
352
path.normalize (origin),
350
353
referredFrom: source);
351
354
_onCheckProgress.add (pathToCheck);
@@ -387,7 +390,7 @@ class DartDoc extends PackageBuilder {
387
390
}
388
391
}
389
392
for (Tuple2 visitPaths in toVisit) {
390
- _doCheck (package , origin, visited, visitPaths.item1, pathToCheck,
393
+ _doCheck (packageGraph , origin, visited, visitPaths.item1, pathToCheck,
391
394
visitPaths.item2);
392
395
}
393
396
_onCheckProgress.add (pathToCheck);
@@ -397,16 +400,16 @@ class DartDoc extends PackageBuilder {
397
400
398
401
/// Don't call this method more than once, and only after you've
399
402
/// generated all docs for the Package.
400
- void validateLinks (Package package , String origin) {
403
+ void validateLinks (PackageGraph packageGraph , String origin) {
401
404
assert (_hrefs == null );
402
- _hrefs = package .allHrefs;
405
+ _hrefs = packageGraph .allHrefs;
403
406
404
407
final Set <String > visited = new Set ();
405
408
final String start = 'index.html' ;
406
409
logInfo ('Validating docs...' );
407
- _doCheck (package , origin, visited, start);
408
- _doOrphanCheck (package , origin, visited);
409
- _doSearchIndexCheck (package , origin, visited);
410
+ _doCheck (packageGraph , origin, visited, start);
411
+ _doOrphanCheck (packageGraph , origin, visited);
412
+ _doSearchIndexCheck (packageGraph , origin, visited);
410
413
}
411
414
}
412
415
@@ -424,10 +427,10 @@ class DartDocFailure {
424
427
/// The results of a [DartDoc.generateDocs] call.
425
428
class DartDocResults {
426
429
final PackageMeta packageMeta;
427
- final Package package ;
430
+ final PackageGraph packageGraph ;
428
431
final Directory outDir;
429
432
430
- DartDocResults (this .packageMeta, this .package , this .outDir);
433
+ DartDocResults (this .packageMeta, this .packageGraph , this .outDir);
431
434
}
432
435
433
436
class _Error implements Comparable <_Error > {
0 commit comments