rust-lang / cargo

The Rust package manager
https://doc.rust-lang.org/cargo
Apache License 2.0
12.73k stars 2.42k forks source link

`cargo clean -p` does not clean documentation #8790

Open jyn514 opened 4 years ago

jyn514 commented 4 years ago

Problem

cargo clean -p package should remove target/doc/package, but does not.

Steps

$ cargo new test-doc
     Created binary (application) `test-doc` package
$ cd test-doc
Cargo.toml  src
$ cargo doc
 Documenting test-doc v0.1.0 (/home/joshua/src/rust/test-doc)
    Finished dev [unoptimized + debuginfo] target(s) in 0.70s
$ ls target/doc
ayu.css                main.js                      source-files.js
brush.svg              normalize.css                source-script.js
COPYRIGHT.txt          noscript.css                 SourceSerifPro-Bold.ttf.woff
dark.css               rustdoc.css                  SourceSerifPro-It.ttf.woff
down-arrow.svg         rust-logo.png                SourceSerifPro-LICENSE.md
favicon.ico            search-index.js              SourceSerifPro-Regular.ttf.woff
FiraSans-LICENSE.txt   settings.css                 src
FiraSans-Medium.woff   settings.html                storage.js
FiraSans-Regular.woff  settings.js                  test_doc
LICENSE-APACHE.txt     SourceCodePro-LICENSE.txt    theme.js
LICENSE-MIT.txt        SourceCodePro-Regular.woff   wheel.svg
light.css              SourceCodePro-Semibold.woff
$ cargo clean -p test-doc
$ ls target/doc
ayu.css                main.js                      source-files.js
brush.svg              normalize.css                source-script.js
COPYRIGHT.txt          noscript.css                 SourceSerifPro-Bold.ttf.woff
dark.css               rustdoc.css                  SourceSerifPro-It.ttf.woff
down-arrow.svg         rust-logo.png                SourceSerifPro-LICENSE.md
favicon.ico            search-index.js              SourceSerifPro-Regular.ttf.woff
FiraSans-LICENSE.txt   settings.css                 src
FiraSans-Medium.woff   settings.html                storage.js
FiraSans-Regular.woff  settings.js                  test_doc
LICENSE-APACHE.txt     SourceCodePro-LICENSE.txt    theme.js
LICENSE-MIT.txt        SourceCodePro-Regular.woff   wheel.svg
light.css              SourceCodePro-Semibold.woff
$ cargo clean
$ ls target/doc
ls: cannot access 'target/doc': No such file or directory

Possible Solution(s)

Notes

Output of cargo version:

cargo 1.47.0 (f3c7e066a 2020-08-28), but the bug is also present in cargo 1.48.0-nightly (9d1a4863a 2020-10-05).

ehuss commented 4 years ago

I think part of the problem is that the search index would be broken since it would contain references to the now missing package.

jyn514 commented 4 years ago

🤷 that seems like a reasonable tradeoff if the user explicitly opted-in to removing the documentation. This isn't specific to the search index, there could also be links in the downstream docs that are now broken.

heisen-li commented 3 years ago

Hello, because you may be busy, do not have time to do such simple things. I'm getting familiar with the cargo source code, which is interesting to me. Does this issue need to be fixed? Or have you guys not figured it out yet?

ehuss commented 3 years ago

I think it would probably be fine to support this. I still think it could be confusing since things like the index won't be updated, but I also don't expect this to be needed too often.

heisen-li commented 3 years ago

@rustbot claim