Skip to content

Commit cacb3bc

Browse files
committed
fix up linkchecker
1. skip png files 2. skip fragments for the book and nomicon, as these are added by JS 3. Actually print the filename for errors
1 parent 7f1d1c6 commit cacb3bc

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

src/tools/linkchecker/main.rs

+17-1
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,13 @@ fn check(cache: &mut Cache,
171171
}
172172
}
173173

174+
if let Some(extension) = path.extension() {
175+
// don't check these files
176+
if extension == "png" {
177+
return;
178+
}
179+
}
180+
174181
// Alright, if we've found a file name then this file had better
175182
// exist! If it doesn't then we register and print an error.
176183
if path.exists() {
@@ -188,7 +195,9 @@ fn check(cache: &mut Cache,
188195
let res = load_file(cache, root, path.clone(), FromRedirect(false));
189196
let (pretty_path, contents) = match res {
190197
Ok(res) => res,
191-
Err(LoadError::IOError(err)) => panic!(format!("{}", err)),
198+
Err(LoadError::IOError(err)) => {
199+
panic!(format!("error loading {}: {}", path.display(), err));
200+
}
192201
Err(LoadError::BrokenRedirect(target, _)) => {
193202
*errors = true;
194203
println!("{}:{}: broken redirect to {}",
@@ -200,6 +209,13 @@ fn check(cache: &mut Cache,
200209
Err(LoadError::IsRedirect) => unreachable!(),
201210
};
202211

212+
// we don't check the book for fragments because they're added via JS
213+
for book in ["book/", "nomicon/"].iter() {
214+
if !pretty_path.to_str().unwrap().starts_with(book) {
215+
return;
216+
}
217+
}
218+
203219
if let Some(ref fragment) = fragment {
204220
// Fragments like `#1-6` are most likely line numbers to be
205221
// interpreted by javascript, so we're ignoring these

0 commit comments

Comments
 (0)