Skip to content

Commit 5f74fde

Browse files
committed
linkchecker: add a reminder on broken links to add new/renamed pages to SUMMARY.md for mdBooks
1 parent 00367d5 commit 5f74fde

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/tools/linkchecker/main.rs

+11
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ fn main() {
100100
links_ignored_external: 0,
101101
links_ignored_exception: 0,
102102
intra_doc_exceptions: 0,
103+
has_broken_urls: false,
103104
};
104105
checker.walk(&docs, &mut report);
105106
report.report();
@@ -116,6 +117,8 @@ struct Checker {
116117

117118
struct Report {
118119
errors: u32,
120+
// Used to provide help message to remind the user to register a page in `SUMMARY.md`.
121+
has_broken_urls: bool,
119122
start: Instant,
120123
html_files: u32,
121124
html_redirects: u32,
@@ -274,6 +277,7 @@ impl Checker {
274277
report.links_ignored_exception += 1;
275278
} else {
276279
report.errors += 1;
280+
report.has_broken_urls = true;
277281
println!("{}:{}: broken link - `{}`", pretty_path, i, target_pretty_path);
278282
}
279283
return;
@@ -438,6 +442,13 @@ impl Report {
438442
println!("number of links ignored due to exceptions: {}", self.links_ignored_exception);
439443
println!("number of intra doc links ignored: {}", self.intra_doc_exceptions);
440444
println!("errors found: {}", self.errors);
445+
446+
if self.has_broken_urls {
447+
eprintln!(
448+
"NOTE: if you are adding or renaming a markdown file in a mdBook, don't forget to \
449+
register the page in SUMMARY.md"
450+
);
451+
}
441452
}
442453
}
443454

0 commit comments

Comments
 (0)