Skip to content
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

rustdoc doesn't show cfg items that can affect whether an item is available #66413

Closed
Twey opened this issue Nov 14, 2019 · 4 comments
Closed
Labels
T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@Twey
Copy link

Twey commented Nov 14, 2019

It's very frustrating and confusing to read the rustdoc for a crate and go to use some item, only to find out that the item isn't available — and the only way to figure out how to enable it is to read the source of the crate.

Instead, it would be nice to have documentation on items that indicates any cfg annotations that affect the the items' compilation.

@jonas-schievink jonas-schievink added the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label Nov 14, 2019
@CAD97
Copy link
Contributor

CAD97 commented Nov 26, 2019

This can be added by the crate author by using (unstable) #[doc(cfg(..))]. IIUC, it isn't possible for rustdoc to generally solve this problem in every case.

@Twey
Copy link
Author

Twey commented Dec 4, 2019

This is more of a wishlist ticket: given rustdoc's tight integration with rustc, it is architecturally possible, and I think it would add a large UX benefit. But I'm aware it's tricky :)

@Michael-F-Bryan
Copy link

it is architecturally possible

I don't think it is. From memory, the compiler will give rustdoc the parsed AST several steps after applying #[cfg] attributes, so the relevant items have already been stripped out by the time rustdoc gets it.

@jyn514
Copy link
Member

jyn514 commented Nov 21, 2020

Duplicate of #1998 (but I agree that #43781 is realistically the only thing that will happen here in the foreseeable future).

@jyn514 jyn514 closed this as completed Nov 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

5 participants