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

Add display of cfg in rustdoc #44165

Closed
wants to merge 1 commit into from

Conversation

GuillaumeGomez
Copy link
Member

It's been a question since a while now. Should we display cfg flags or not? An example of the output:

screen shot 2017-08-29 at 22 04 18

If yes, should we display it like this or in another way?

cc @rust-lang/docs

@rust-highfive
Copy link
Collaborator

r? @QuietMisdreavus

(rust_highfive has picked a reviewer for you, use r? to override)

@QuietMisdreavus
Copy link
Member

I'm really skittish about just turning this on, because it could leave the impression that rustdoc can somehow handle conditional compilation, which it still totally does not. There's no way for rustdoc to show everything that's tagged with a feature, for the same reason it can't truly show everything that's tagged with a platform-specific cfg. (e.g. #43348 needed to specifically hand several modules to rustdoc via cfg(dox), and on top of that needed to add a new doc(cfg) attribute parameter to make sure rustdoc didn't try to execute doctests on it.)

This may be helpful if people remember to turn on all their features when rendering docs, but this leaves out things like docs.rs and even that #[cfg(not(feature = "foo"))] - since your example won't render that page in the first place if that feature is turned on! I think it could lead to some misleading docs; if people see that cfg tag in one place, they may think they can find all of them there.

@kennytm
Copy link
Member

kennytm commented Aug 29, 2017

How will it looks like when applied to impl, functions, struct fields, enum variants, and fields inside enum variants?

#[cfg(foo)]
impl Foo {
    #[cfg(foo)]
    pub fn new() {}
}

#[cfg(foo)]
pub struct Foo {
    #[cfg(foo)]
    pub x: u32,
}

#[cfg(foo)]
pub enum Foo2 {
    #[cfg(foo)]
    Bar {
        #[cfg(foo)]
        baz: u32,
    }
}

@GuillaumeGomez
Copy link
Member Author

That's the whole point of this debate. I want to propose this add because otherwise I'll have to update how gtk-rs docs are generated (yes, I'm a bit lazy).

@aidanhs aidanhs added S-waiting-on-team Status: Awaiting decision from the relevant subteam (see the T-<team> label). A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools labels Aug 31, 2017
@alexcrichton
Copy link
Member

ping @rust-lang/doc, any thoughts on this PR?

@alexcrichton
Copy link
Member

er, @rust-lang/docs

@steveklabnik
Copy link
Member

I basically second @QuietMisdreavus ; I think this has the possibility of introducing more problems.

@GuillaumeGomez
Copy link
Member Author

I think it's way too early as well. I'll close it then and we'll discuss about it later in the future.

@carols10cents
Copy link
Member

Sounds like this should be closed, so I'm closing!

@GuillaumeGomez GuillaumeGomez deleted the display-cfg branch November 24, 2017 20:56
@apiraino apiraino removed the S-waiting-on-team Status: Awaiting decision from the relevant subteam (see the T-<team> label). label May 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants