-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
cargo doc --open
error message is confusing when all targets are skipped
#14776
Comments
The Cargo team briefly looked at this, and agree that it would be helpful to update the error message to make it clearer that this is related to the The |
cargo doc --open
error message is confusing when all targets are skipped
Actually the error is wrong. The crate does have documentation, just not examples (yet). As long as some crate documentation is produced, --examples should be a no-op and not produce any error; the warning is fine and the browser should open. My workaround for this bug is to have two aliases, one with --examples and the other without. Please revert the change in the title of this issue. Thanks for listening! |
If there were some examples documented after running In this case, there was no example, so no crate doc was produced. Not even the doc of the |
If that's the intended behavior, then I agree with rewording the error message. However, the warning is wrong in that case and should be removed. But I wish the intended behavior would be to produce crate docs if any, and that --examples was indeed a no-op if there is documentation but no examples. It seems inconvenient to require a developer to use two slightly different commands to produce documentation during development. |
How is the warning wrong?
In this case, cargo is doing exactly what you told it to do. imo we shouldn't be second guessing the user. Personally, I've stopped using |
The warning is wrong because it is not a no-op. It is an error and there's an error message produced already, so the erroneous warning is not only wrong but redundant. The command with --examples along with --open may be working as intended. But that is most definitely not as I expected. I expect the browser to open if there's any crate documentation at all and produce a warning if --examples is specified but there are no examples. If that's not what cargo maintainers desire for the behavior, I understand. But in that case, the warning is incorrect and should be eliminated or at least reworded. I will leave this issue to your judgment for resolution at this point. I do appreciate you taking the time to correspond with me and appreciate the great work you do. Even if you don't agree with me! :-) |
Two different things are being reported
There is overlap (nothing). Whether something should be done depends on a couple of factors
|
Hey @epage, You're right that the examples did nothing wrong. It was executed through the command, but it didn't find the examples file and gave the error. If a person just wants to open the file, then writing the But now the problem arises, if the It has two parts. Part No. 1 At this point, @profwpollock also has a strong point to open the browser and an error message should be given that the examples directory is missing. If you agree on this point then we can change the message in which we can write that the docs of other files are provided except the examples and that's why
After some findings, I noticed that this behavior also exists in git where it takes the add, commit, and push commands. It adds and commits the changes successfully but when the wrong branch name is provided, then it does not push the code. All the things happen in just one line of command. Here is the git commands to showcase: Part No. 2: Now if you want to keep the docs strict so that it gives you the error message without opening it in the browser. then it is also fine because
I presented both points that could be implemented and I want to know what is your priority to implement. Let me know. Thank you! |
No. See #14776 (comment) |
@weihanglo Well, I was not aware of the expected behavior of examples. Now, here are 2 points about which I am confused.
|
### What does this PR try to resolve? This PR is resolving an [issue](#14776 (comment)) where `cargo doc --open --examples` does not give a clear message when the examples file is given to it. I changed the message from `no crates with documentation` in the [cargo_doc.rs](https://github.com/rust-lang/cargo/blob/58b2d609ece6bd0333e4d0f63a024fe3dd350b4b/src/cargo/ops/cargo_doc.rs#L62) and [doc.rs](https://github.com/rust-lang/cargo/blob/58b2d609ece6bd0333e4d0f63a024fe3dd350b4b/tests/testsuite/doc.rs#L1504) to `requested crate documentation is not available to open`. Now it becomes easy for the user to understand what they're missing. Fixes #14776 ### How should we test and review this PR? Here is the command through which you can test this change: `cargo test SNAPSHOTS=overwrite -- doc::open_no_doc_crate` <!-- Thanks for submitting a pull request 🎉! Here are some tips for you: * If this is your first contribution, read "Cargo Contribution Guide" first: https://doc.crates.io/contrib/ * Run `cargo fmt --all` to format your code changes. * Small commits and pull requests are always preferable and easy to review. * If your idea is large and needs feedback from the community, read how: https://doc.crates.io/contrib/process/#working-on-large-features * Cargo takes care of compatibility. Read our design principles: https://doc.crates.io/contrib/design.html * When changing help text of cargo commands, follow the steps to generate docs: https://github.com/rust-lang/cargo/tree/master/src/doc#building-the-man-pages * If your PR is not finished, set it as "draft" PR or add "WIP" in its title. * It's ok to use the CI resources to test your PR, but please don't abuse them. ### What does this PR try to resolve? Explain the motivation behind this change. A clear overview along with an in-depth explanation are helpful. You can use `Fixes #<issue number>` to associate this PR to an existing issue. ### How should we test and review this PR? Demonstrate how you test this change and guide reviewers through your PR. With a smooth review process, a pull request usually gets reviewed quicker. If you don't know how to write and run your tests, please read the guide: https://doc.crates.io/contrib/tests ### Additional information Other information you want to mention in this PR, such as prior arts, future extensions, an unresolved problem, or a TODO list. -->
Problem
I use an alias for this command:
$ cargo doc -v --open --workspace --document-private-items --all-features --no-deps --examples
When first developing a new project, there are no examples yet. The output is:
So it is NOT a "no-op". I believe it should be. The warning alone is fine.
Proposed Solution
Instead of failing to provide crate documentation, it should create crate documentation even if there's no examples yet.
Notes
No response
The text was updated successfully, but these errors were encountered: