Compute the right output filenames for rustdoc invocations that request the JSON format#12100
Compute the right output filenames for rustdoc invocations that request the JSON format#12100LukeMathWalker wants to merge 3 commits intorust-lang:masterfrom
Conversation
…compilation unit when `cargo rustdoc` has been instructed to generate JSON output rather than the conventional HTML output.
|
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @epage (or someone else) soon. Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (
|
|
Just FYI, cargo has a policy of not parsing rustc or rustdoc flags. Generally, if there is some behavior that cargo needs to be aware of, then that needs to be lifted up as a first-class feature where cargo is driving the process (such as with its own flags). I don't offhand know how this should be designed, but I think it would be good to at least start with an issue where that design could be discussed. |
|
I see, then I'll pursue the alternative I listed in the PR description—lifitng |
|
Opened #12103 |
What does this PR try to resolve?
cargocurrently assumes that all invocations ofcargo rustdocproduce HTML files as outputs.This assumption breaks down for invocations of
cargo rustdocthat instructrustdocto produce documentation in a different format (i.e. JSON).As a consequence, running the very same command multiple times (
cargo +nightly rustdoc --lib -p <NAME> -- -Zunstable-options -wjson) recomputes the documentation every single time, instead of detecting that the pre-existing file is still fresh.This PR fixes the logic in
cargoto correctly detect the output filename when the JSON format is required.How should we test and review this PR?
I've added a test to confirm that:
<crate name>.json);Additional information
An alternative implementation strategy could see us adding
--output-formatas acargo rustdocoption, rather than trying to parse the extra arguments being passed torustdoc.