rust-lang / mdBook

Create book from markdown files. Like Gitbook but implemented in Rust
https://rust-lang.github.io/mdBook/
Mozilla Public License 2.0
17.72k stars 1.61k forks source link

[Feature Request] Automatically delete files not referenced anywhere #1720

Open inodentry opened 2 years ago

inodentry commented 2 years ago

I am maintaining a long-lived project based on mdbook (Bevy Cheatbook) that I am regularly updating and reorganizing. This often means deleting outdated content. Some of my pages include/embed other markdown files in their body.

Currently, I found no easy way to make sure I don't have any stale files left in the repo. If I delete a page from SUMMARY.md, but forget to remove the file, or if one of the included files is no longer used anywhere, there is nothing that can detect that.

Would be nice to have some way to detect and remove (garbage collect) files in src that are unnecessary / no longer used anywhere.

ISSOtm commented 2 years ago

This seems a bit difficult to do, considering that other custom plugins may use such files. Couldn't you write a custom preproc that decides which files are in use, and thus which aren't?