]> git.lizzy.rs Git - rust.git/commitdiff
linkchecker: Treat directory links as errors
authorOliver Middleton <olliemail27@gmail.com>
Thu, 2 Jun 2016 12:33:21 +0000 (13:33 +0100)
committerOliver Middleton <olliemail27@gmail.com>
Thu, 2 Jun 2016 13:29:36 +0000 (14:29 +0100)
Directory links don't work well offline so they should be treated as errors.

src/tools/linkchecker/main.rs

index a7c8c01fab8503febe4d85a50eb74e0d2ccbf4c8..c02fc8a3f918cdcfb18f068b6693b9bb08592912 100644 (file)
@@ -191,6 +191,12 @@ fn check(cache: &mut Cache,
         // exist! If it doesn't then we register and print an error.
         if path.exists() {
             if path.is_dir() {
+                // Links to directories show as directory listings when viewing
+                // the docs offline so it's best to avoid them.
+                *errors = true;
+                let pretty_path = path.strip_prefix(root).unwrap_or(&path);
+                println!("{}:{}: directory link - {}", pretty_file.display(),
+                         i + 1, pretty_path.display());
                 return;
             }
             let res = load_file(cache, root, path.clone(), FromRedirect(false));