@@ -24,7 +24,7 @@ import 'package:dartdoc/src/version.dart';
2424import 'package:dartdoc/src/warnings.dart' ;
2525import 'package:html/dom.dart' show Element, Document;
2626import 'package:html/parser.dart' show parse;
27- import 'package:path/path.dart' as pathLib ;
27+ import 'package:path/path.dart' as path ;
2828
2929export 'package:dartdoc/src/dartdoc_options.dart' ;
3030export 'package:dartdoc/src/element_type.dart' ;
@@ -105,10 +105,11 @@ class Dartdoc extends PackageBuilder {
105105
106106 for (var generator in generators) {
107107 await generator.generate (packageGraph, outputDir.path);
108- writtenFiles.addAll (generator.writtenFiles.map (pathLib .normalize));
108+ writtenFiles.addAll (generator.writtenFiles.map (path .normalize));
109109 }
110- if (config.validateLinks && writtenFiles.isNotEmpty)
110+ if (config.validateLinks && writtenFiles.isNotEmpty) {
111111 validateLinks (packageGraph, outputDir.path);
112+ }
112113 }
113114
114115 int warnings = packageGraph.packageWarningCounter.warningCount;
@@ -159,12 +160,12 @@ class Dartdoc extends PackageBuilder {
159160 Set <Warnable > warnOnElements;
160161
161162 // 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);
164165 }
165166 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);
168169 }
169170 // Source paths are always relative.
170171 if (_hrefs[referredFrom] != null ) {
@@ -185,8 +186,9 @@ class Dartdoc extends PackageBuilder {
185186 }
186187 }
187188
188- if (referredFromElements.isEmpty && referredFrom == 'index.html' )
189+ if (referredFromElements.isEmpty && referredFrom == 'index.html' ) {
189190 referredFromElements.add (packageGraph.defaultPackage);
191+ }
190192 String message = warnOn;
191193 if (referredFrom == 'index.json' ) message = '$warnOn (from index.json)' ;
192194 packageGraph.warnOnElement (warnOnElement, kind,
@@ -195,13 +197,13 @@ class Dartdoc extends PackageBuilder {
195197
196198 void _doOrphanCheck (
197199 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' ]);
201203 bool foundIndexJson = false ;
202204 for (FileSystemEntity f
203205 in new Directory (normalOrigin).listSync (recursive: true )) {
204- var fullPath = pathLib .normalize (f.path);
206+ var fullPath = path .normalize (f.path);
205207 if (f is Directory ) {
206208 continue ;
207209 }
@@ -214,7 +216,7 @@ class Dartdoc extends PackageBuilder {
214216 continue ;
215217 }
216218 if (visited.contains (fullPath)) continue ;
217- String relativeFullPath = pathLib .relative (fullPath, from: normalOrigin);
219+ String relativeFullPath = path .relative (fullPath, from: normalOrigin);
218220 if (! writtenFiles.contains (relativeFullPath)) {
219221 // This isn't a file we wrote (this time); don't claim we did.
220222 _warn (packageGraph, PackageWarning .unknownFile, fullPath, normalOrigin);
@@ -259,8 +261,8 @@ class Dartdoc extends PackageBuilder {
259261
260262 void _doSearchIndexCheck (
261263 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' ]);
264266 File file = new File ("$fullPath " );
265267 if (! file.existsSync ()) {
266268 return null ;
@@ -275,10 +277,10 @@ class Dartdoc extends PackageBuilder {
275277 found.add (indexPath);
276278 for (Map <String , dynamic > entry in jsonData) {
277279 if (entry.containsKey ('href' )) {
278- String entryPath = pathLib .joinAll ([origin, entry['href' ]]);
280+ String entryPath = path .joinAll ([origin, entry['href' ]]);
279281 if (! visited.contains (entryPath)) {
280282 _warn (packageGraph, PackageWarning .brokenLink, entryPath,
281- pathLib .normalize (origin),
283+ path .normalize (origin),
282284 referredFrom: fullPath);
283285 }
284286 found.add (entryPath);
@@ -288,7 +290,7 @@ class Dartdoc extends PackageBuilder {
288290 Set <String > missing_from_search = visited.difference (found);
289291 for (String s in missing_from_search) {
290292 _warn (packageGraph, PackageWarning .missingFromSearchIndex, s,
291- pathLib .normalize (origin),
293+ path .normalize (origin),
292294 referredFrom: fullPath);
293295 }
294296 }
@@ -297,14 +299,14 @@ class Dartdoc extends PackageBuilder {
297299 String pathToCheck,
298300 [String source, String fullPath]) {
299301 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);
302304 }
303305
304306 Tuple2 stringLinksAndHref = _getStringLinksAndHref (fullPath);
305307 if (stringLinksAndHref == null ) {
306308 _warn (packageGraph, PackageWarning .brokenLink, pathToCheck,
307- pathLib .normalize (origin),
309+ path .normalize (origin),
308310 referredFrom: source);
309311 _onCheckProgress.add (pathToCheck);
310312 // Remove so that we properly count that the file doesn't exist for
@@ -328,18 +330,20 @@ class Dartdoc extends PackageBuilder {
328330 Uri uri;
329331 try {
330332 uri = Uri .parse (href);
331- } catch (FormatError ) {}
333+ } catch (FormatError ) {
334+ // ignore
335+ }
332336
333337 if (uri == null || ! uri.hasAuthority && ! uri.hasFragment) {
334338 var full;
335339 if (baseHref != null ) {
336- full = '${pathLib .dirname (pathToCheck )}/$baseHref /$href ' ;
340+ full = '${path .dirname (pathToCheck )}/$baseHref /$href ' ;
337341 } else {
338- full = '${pathLib .dirname (pathToCheck )}/$href ' ;
342+ full = '${path .dirname (pathToCheck )}/$href ' ;
339343 }
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);
343347 if (! visited.contains (newFullPath)) {
344348 toVisit.add (new Tuple2 (newPathToCheck, newFullPath));
345349 visited.add (newFullPath);
0 commit comments