about summary refs log tree commit diff
diff options
context:
space:
mode:
authorSteve Klabnik <steve@steveklabnik.com>2017-02-10 16:38:20 -0500
committerSteve Klabnik <steve@steveklabnik.com>2017-02-13 13:41:27 -0500
commitcacb3bc9c741a7d41a1085af850cd3ff852307f5 (patch)
tree2afcab96e3bea14dc3a725e5e83a361b59b222dc
parent7f1d1c6d9a7be5e427bace30e740b16b25f25c92 (diff)
downloadrust-cacb3bc9c741a7d41a1085af850cd3ff852307f5.tar.gz
rust-cacb3bc9c741a7d41a1085af850cd3ff852307f5.zip
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
-rw-r--r--src/tools/linkchecker/main.rs18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/tools/linkchecker/main.rs b/src/tools/linkchecker/main.rs
index f84d685127b..304c722bbe5 100644
--- a/src/tools/linkchecker/main.rs
+++ b/src/tools/linkchecker/main.rs
@@ -171,6 +171,13 @@ fn check(cache: &mut Cache,
             }
         }
 
+        if let Some(extension) = path.extension() {
+            // don't check these files
+            if extension == "png" {
+                return;
+            }
+        }
+
         // Alright, if we've found a file name then this file had better
         // exist! If it doesn't then we register and print an error.
         if path.exists() {
@@ -188,7 +195,9 @@ fn check(cache: &mut Cache,
             let res = load_file(cache, root, path.clone(), FromRedirect(false));
             let (pretty_path, contents) = match res {
                 Ok(res) => res,
-                Err(LoadError::IOError(err)) => panic!(format!("{}", err)),
+                Err(LoadError::IOError(err)) => {
+                    panic!(format!("error loading {}: {}", path.display(), err));
+                }
                 Err(LoadError::BrokenRedirect(target, _)) => {
                     *errors = true;
                     println!("{}:{}: broken redirect to {}",
@@ -200,6 +209,13 @@ fn check(cache: &mut Cache,
                 Err(LoadError::IsRedirect) => unreachable!(),
             };
 
+            // we don't check the book for fragments because they're added via JS
+            for book in ["book/", "nomicon/"].iter() {
+                if !pretty_path.to_str().unwrap().starts_with(book) {
+                    return;
+                }
+            }
+
             if let Some(ref fragment) = fragment {
                 // Fragments like `#1-6` are most likely line numbers to be
                 // interpreted by javascript, so we're ignoring these