-
Notifications
You must be signed in to change notification settings - Fork 2.5k
cargo should clear doc
directory between versions
#8461
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi @ehuss I'd like to work on that. I've been checking the code and looks like we could apply this check and delete the cargo/src/cargo/ops/cargo_doc.rs Line 38 in d3360ad What I'm not sure about is the fingerprint and where/how it should be set. |
I don't think there is anything existing. I'm thinking there could probably just be a file stored in the I'm not sure how much you know about the cargo codebase. Information about fingerprinting can be found in https://github.com/rust-lang/cargo/blob/master/src/cargo/core/compiler/fingerprint.rs. Unfortunately I don't think that can be used in this case because those fingerprints are unit-oriented, but this fingerprint needs to be triggered globally (otherwise, if two units are building docs concurrently, there would need to be some messy coordination). There is a cache of rustc information at https://github.com/rust-lang/cargo/blob/master/src/cargo/util/rustc.rs, stored in the |
Thanks for the info. I don't know much about the Cargo codebase as you'll probably witness.. hahah. The JSON file looks like a good solution. Indeed we already have one in the package directory, inside of cat .rustc_info.json
{"rustc_fingerprint":5969268850994687783,"outputs":{"16929990295604814582":["___\n",""],"1164083562126845933":["rustc 1.46.0-nightly (346aec9b0 2020-07-11)\nbinary: r......................} Therefore, we could simply take this version if If it is we just let it follow the same logic it has now, if it is older, we delete the whole Does it make sense? Or you'll create a specific file for docs fingerprinting? |
I don't think the |
Makes sense. Therefore, as you mentioned, a JSON file under Then the logic would be something like:
What does it seem to you @ehuss ? |
Yea, generally seems correct. To be a little more precise:
There probably isn't a need to specifically check for the directory. It can just try to open the fingerprint file, and if it doesn't exist, it can proceed as usual.
It will probably be sufficient to check the version of |
Before compiling, we need to make sure that if there were any previous docs already compiled, they were compiled with the same Rustc version that we're currently using. Otherways we must remove the `doc/` folder and compile again. This is important because as stated in rust-lang#8461 the .js/.html&.css files that are generated by Rustc don't have any versioning. Therefore, we can fall in weird bugs and behaviours if we mix different compiler versions of these js/.html&.css files.
This was kind of a heavy hammer (and caused rustbuild trouble: rust-lang/rust#83530). What do you think about passing a |
Rustdoc can fail if you build documentation with different versions of rustdoc. Rustdoc has some persistent files (like
search-index.js
) which are not internally versioned. If the format of these changes, this can cause things to break. Example:In a project with at least one dependency:
cargo +1.40.0 doc
cargo +1.41.0 doc --no-deps --open
The result will have javascript errors in the console, and the sidebar and search will be broken.
cc rust-lang/rust#70781
To fix this, Cargo should retain a fingerprint somewhere that tracks the rustc version used when building documentation. Changes to that should cause Cargo to delete the
doc
directory.The text was updated successfully, but these errors were encountered: