Skip to content

Commit 703c0e3

Browse files
authored
Fix grind link checker (though not bugs it discovered) (#1362)
1 parent dd02cae commit 703c0e3

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

CHANGELOG.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
## 1.0.0
2-
1+
* fix grind check-links and check-sdk-links (#1360)
32
* fix multiple issues in annotation/feature list handling (#1268, #1162, #1081)
4-
53
* Added `pretty-index-json` command line flag.
6-
74
* `index.json` file entries are now sorted.
85

96
## 0.9.12

tool/grind.dart

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ _getPackageVersion() {
7979
checkLinks() {
8080
bool foundError = false;
8181
Set<String> visited = new Set();
82-
final origin = 'testing/test_package/doc/api/';
82+
final origin = 'testing/test_package_docs/';
8383
var start = 'index.html';
8484

8585
_doCheck(origin, visited, start, foundError);
@@ -267,8 +267,11 @@ _doCheck(String origin, Set<String> visited, String pathToCheck, bool error,
267267

268268
File file = new File("$fullPath");
269269
if (!file.existsSync()) {
270-
error = true;
271-
log(' * Not found: $fullPath from $source');
270+
// There is a deliberately broken link in one place.
271+
if (!fullPath.endsWith("ftp:/ftp.myfakepackage.com/donthidemyschema")) {
272+
error = true;
273+
log(' * Not found: $fullPath from $source');
274+
}
272275
return;
273276
}
274277
Document doc = parse(file.readAsStringSync());
@@ -283,7 +286,12 @@ _doCheck(String origin, Set<String> visited, String pathToCheck, bool error,
283286
.where((href) => href != null)
284287
.forEach((href) {
285288
if (!href.startsWith('http') && !href.contains('#')) {
286-
var full = '${path.dirname(pathToCheck)}/$baseHref/$href';
289+
var full;
290+
if (baseHref != null) {
291+
full = '${path.dirname(pathToCheck)}/$baseHref/$href';
292+
} else {
293+
full = '${path.dirname(pathToCheck)}/$href';
294+
}
287295
var normalized = path.normalize(full);
288296
_doCheck(origin, visited, normalized, error, pathToCheck);
289297
}

0 commit comments

Comments
 (0)