mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 23:04:33 +00:00
linkchecker: add a reminder on broken links to add new/renamed pages to SUMMARY.md for mdBooks
This commit is contained in:
parent
00367d523e
commit
5f74fde853
@ -100,6 +100,7 @@ fn main() {
|
|||||||
links_ignored_external: 0,
|
links_ignored_external: 0,
|
||||||
links_ignored_exception: 0,
|
links_ignored_exception: 0,
|
||||||
intra_doc_exceptions: 0,
|
intra_doc_exceptions: 0,
|
||||||
|
has_broken_urls: false,
|
||||||
};
|
};
|
||||||
checker.walk(&docs, &mut report);
|
checker.walk(&docs, &mut report);
|
||||||
report.report();
|
report.report();
|
||||||
@ -116,6 +117,8 @@ struct Checker {
|
|||||||
|
|
||||||
struct Report {
|
struct Report {
|
||||||
errors: u32,
|
errors: u32,
|
||||||
|
// Used to provide help message to remind the user to register a page in `SUMMARY.md`.
|
||||||
|
has_broken_urls: bool,
|
||||||
start: Instant,
|
start: Instant,
|
||||||
html_files: u32,
|
html_files: u32,
|
||||||
html_redirects: u32,
|
html_redirects: u32,
|
||||||
@ -274,6 +277,7 @@ impl Checker {
|
|||||||
report.links_ignored_exception += 1;
|
report.links_ignored_exception += 1;
|
||||||
} else {
|
} else {
|
||||||
report.errors += 1;
|
report.errors += 1;
|
||||||
|
report.has_broken_urls = true;
|
||||||
println!("{}:{}: broken link - `{}`", pretty_path, i, target_pretty_path);
|
println!("{}:{}: broken link - `{}`", pretty_path, i, target_pretty_path);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@ -438,6 +442,13 @@ impl Report {
|
|||||||
println!("number of links ignored due to exceptions: {}", self.links_ignored_exception);
|
println!("number of links ignored due to exceptions: {}", self.links_ignored_exception);
|
||||||
println!("number of intra doc links ignored: {}", self.intra_doc_exceptions);
|
println!("number of intra doc links ignored: {}", self.intra_doc_exceptions);
|
||||||
println!("errors found: {}", self.errors);
|
println!("errors found: {}", self.errors);
|
||||||
|
|
||||||
|
if self.has_broken_urls {
|
||||||
|
eprintln!(
|
||||||
|
"NOTE: if you are adding or renaming a markdown file in a mdBook, don't forget to \
|
||||||
|
register the page in SUMMARY.md"
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user