@@ -24,7 +24,7 @@ import 'package:dartdoc/src/version.dart';
24
24
import 'package:dartdoc/src/warnings.dart' ;
25
25
import 'package:html/dom.dart' show Element, Document;
26
26
import 'package:html/parser.dart' show parse;
27
- import 'package:path/path.dart' as pathLib ;
27
+ import 'package:path/path.dart' as path ;
28
28
29
29
export 'package:dartdoc/src/dartdoc_options.dart' ;
30
30
export 'package:dartdoc/src/element_type.dart' ;
@@ -105,10 +105,11 @@ class Dartdoc extends PackageBuilder {
105
105
106
106
for (var generator in generators) {
107
107
await generator.generate (packageGraph, outputDir.path);
108
- writtenFiles.addAll (generator.writtenFiles.map (pathLib .normalize));
108
+ writtenFiles.addAll (generator.writtenFiles.map (path .normalize));
109
109
}
110
- if (config.validateLinks && writtenFiles.isNotEmpty)
110
+ if (config.validateLinks && writtenFiles.isNotEmpty) {
111
111
validateLinks (packageGraph, outputDir.path);
112
+ }
112
113
}
113
114
114
115
int warnings = packageGraph.packageWarningCounter.warningCount;
@@ -159,12 +160,12 @@ class Dartdoc extends PackageBuilder {
159
160
Set <Warnable > warnOnElements;
160
161
161
162
// Make all paths relative to origin.
162
- if (pathLib .isWithin (origin, warnOn)) {
163
- warnOn = pathLib .relative (warnOn, from: origin);
163
+ if (path .isWithin (origin, warnOn)) {
164
+ warnOn = path .relative (warnOn, from: origin);
164
165
}
165
166
if (referredFrom != null ) {
166
- if (pathLib .isWithin (origin, referredFrom)) {
167
- referredFrom = pathLib .relative (referredFrom, from: origin);
167
+ if (path .isWithin (origin, referredFrom)) {
168
+ referredFrom = path .relative (referredFrom, from: origin);
168
169
}
169
170
// Source paths are always relative.
170
171
if (_hrefs[referredFrom] != null ) {
@@ -185,8 +186,9 @@ class Dartdoc extends PackageBuilder {
185
186
}
186
187
}
187
188
188
- if (referredFromElements.isEmpty && referredFrom == 'index.html' )
189
+ if (referredFromElements.isEmpty && referredFrom == 'index.html' ) {
189
190
referredFromElements.add (packageGraph.defaultPackage);
191
+ }
190
192
String message = warnOn;
191
193
if (referredFrom == 'index.json' ) message = '$warnOn (from index.json)' ;
192
194
packageGraph.warnOnElement (warnOnElement, kind,
@@ -195,13 +197,13 @@ class Dartdoc extends PackageBuilder {
195
197
196
198
void _doOrphanCheck (
197
199
PackageGraph packageGraph, String origin, Set <String > visited) {
198
- String normalOrigin = pathLib .normalize (origin);
199
- String staticAssets = pathLib .joinAll ([normalOrigin, 'static-assets' , '' ]);
200
- String indexJson = pathLib .joinAll ([normalOrigin, 'index.json' ]);
200
+ String normalOrigin = path .normalize (origin);
201
+ String staticAssets = path .joinAll ([normalOrigin, 'static-assets' , '' ]);
202
+ String indexJson = path .joinAll ([normalOrigin, 'index.json' ]);
201
203
bool foundIndexJson = false ;
202
204
for (FileSystemEntity f
203
205
in new Directory (normalOrigin).listSync (recursive: true )) {
204
- var fullPath = pathLib .normalize (f.path);
206
+ var fullPath = path .normalize (f.path);
205
207
if (f is Directory ) {
206
208
continue ;
207
209
}
@@ -214,7 +216,7 @@ class Dartdoc extends PackageBuilder {
214
216
continue ;
215
217
}
216
218
if (visited.contains (fullPath)) continue ;
217
- String relativeFullPath = pathLib .relative (fullPath, from: normalOrigin);
219
+ String relativeFullPath = path .relative (fullPath, from: normalOrigin);
218
220
if (! writtenFiles.contains (relativeFullPath)) {
219
221
// This isn't a file we wrote (this time); don't claim we did.
220
222
_warn (packageGraph, PackageWarning .unknownFile, fullPath, normalOrigin);
@@ -259,8 +261,8 @@ class Dartdoc extends PackageBuilder {
259
261
260
262
void _doSearchIndexCheck (
261
263
PackageGraph packageGraph, String origin, Set <String > visited) {
262
- String fullPath = pathLib .joinAll ([origin, 'index.json' ]);
263
- String indexPath = pathLib .joinAll ([origin, 'index.html' ]);
264
+ String fullPath = path .joinAll ([origin, 'index.json' ]);
265
+ String indexPath = path .joinAll ([origin, 'index.html' ]);
264
266
File file = new File ("$fullPath " );
265
267
if (! file.existsSync ()) {
266
268
return null ;
@@ -275,10 +277,10 @@ class Dartdoc extends PackageBuilder {
275
277
found.add (indexPath);
276
278
for (Map <String , dynamic > entry in jsonData) {
277
279
if (entry.containsKey ('href' )) {
278
- String entryPath = pathLib .joinAll ([origin, entry['href' ]]);
280
+ String entryPath = path .joinAll ([origin, entry['href' ]]);
279
281
if (! visited.contains (entryPath)) {
280
282
_warn (packageGraph, PackageWarning .brokenLink, entryPath,
281
- pathLib .normalize (origin),
283
+ path .normalize (origin),
282
284
referredFrom: fullPath);
283
285
}
284
286
found.add (entryPath);
@@ -288,7 +290,7 @@ class Dartdoc extends PackageBuilder {
288
290
Set <String > missing_from_search = visited.difference (found);
289
291
for (String s in missing_from_search) {
290
292
_warn (packageGraph, PackageWarning .missingFromSearchIndex, s,
291
- pathLib .normalize (origin),
293
+ path .normalize (origin),
292
294
referredFrom: fullPath);
293
295
}
294
296
}
@@ -297,14 +299,14 @@ class Dartdoc extends PackageBuilder {
297
299
String pathToCheck,
298
300
[String source, String fullPath]) {
299
301
if (fullPath == null ) {
300
- fullPath = pathLib .joinAll ([origin, pathToCheck]);
301
- fullPath = pathLib .normalize (fullPath);
302
+ fullPath = path .joinAll ([origin, pathToCheck]);
303
+ fullPath = path .normalize (fullPath);
302
304
}
303
305
304
306
Tuple2 stringLinksAndHref = _getStringLinksAndHref (fullPath);
305
307
if (stringLinksAndHref == null ) {
306
308
_warn (packageGraph, PackageWarning .brokenLink, pathToCheck,
307
- pathLib .normalize (origin),
309
+ path .normalize (origin),
308
310
referredFrom: source);
309
311
_onCheckProgress.add (pathToCheck);
310
312
// Remove so that we properly count that the file doesn't exist for
@@ -328,18 +330,20 @@ class Dartdoc extends PackageBuilder {
328
330
Uri uri;
329
331
try {
330
332
uri = Uri .parse (href);
331
- } catch (FormatError ) {}
333
+ } catch (FormatError ) {
334
+ // ignore
335
+ }
332
336
333
337
if (uri == null || ! uri.hasAuthority && ! uri.hasFragment) {
334
338
var full;
335
339
if (baseHref != null ) {
336
- full = '${pathLib .dirname (pathToCheck )}/$baseHref /$href ' ;
340
+ full = '${path .dirname (pathToCheck )}/$baseHref /$href ' ;
337
341
} else {
338
- full = '${pathLib .dirname (pathToCheck )}/$href ' ;
342
+ full = '${path .dirname (pathToCheck )}/$href ' ;
339
343
}
340
- var newPathToCheck = pathLib .normalize (full);
341
- String newFullPath = pathLib .joinAll ([origin, newPathToCheck]);
342
- newFullPath = pathLib .normalize (newFullPath);
344
+ var newPathToCheck = path .normalize (full);
345
+ String newFullPath = path .joinAll ([origin, newPathToCheck]);
346
+ newFullPath = path .normalize (newFullPath);
343
347
if (! visited.contains (newFullPath)) {
344
348
toVisit.add (new Tuple2 (newPathToCheck, newFullPath));
345
349
visited.add (newFullPath);
0 commit comments