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: how does #[doc(hidden)] interact with --document-private-items? #46380

Closed
hdevalence opened this issue Nov 29, 2017 · 3 comments
Closed
Labels
A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@hdevalence
Copy link

I have types Public (which is exported) and Private (which isn't) and an impl Add<Private> for Public. I would like the impl Add<Private> for Public to appear in the Rustdoc output only when using --document-private-items.

As far as I can tell, the impl Add<Private> for Public appears in the normal rustdoc output unless it has a #[doc(hidden)] attribute. But this prevents the impl from appearing with --document-private-items.

Is --document-private-items supposed to override #[doc(hidden)]? Is there another way to hide impl Add<Private> for Public from the public rustdoc output?

hdevalence added a commit to hdevalence/curve25519-dalek that referenced this issue Nov 29, 2017
@QuietMisdreavus
Copy link
Member

So it seems like there's two things going on here:

  • --document-private-items runs the strip-hidden pass, which i would consider a bug. #[doc(hidden)] items are private implementation details and fall under the same camp, conceptually, as regular items that aren't public. (Removing the String::from("strip-hidden"), line from that block will fix that.)
  • Trait impls whose trait's type parameters include private items still appear in the docs, because the type it's impl'd for is public. Again, i would consider this a bug, but a separate one. The fix for that is more involved, though. >_>

@QuietMisdreavus QuietMisdreavus added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. labels Nov 29, 2017
@QuietMisdreavus
Copy link
Member

To fix the second note in my previous comment, you'd need to unpack imp.trait_ in here, iterate through the contained Type's .generics() and check each of those (via .def_id()) against self.retained the same way that imp.for_ is. Something like this:

if let Some(generics) = imp.trait_.and_then(|t| t.generics()) {
    for typaram in generics {
        if let Some(did) = typaram.def_id() {
            if did.is_local() && !self.retained.contains(did) {
                return None;
            }
        }
    }
}

Right after that linked block.

This is technically not part of the issue (at least it sounds like the issue was more about --document-private-items) but would also be a nice thing to add, probably separately from the other proposed change.

@QuietMisdreavus QuietMisdreavus added the E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. label Nov 29, 2017
kennytm added a commit to kennytm/rust that referenced this issue Dec 1, 2017
…reavus

Hide private trait type params and show hidden items with document-private

As discussed in rust-lang#46380, this PR removes the `strip-hidden` pass from `--document-private-items` which allows showing `#[doc(hidden)]` with rustdoc.

The second commit removes the trait implementation from the docs if the trait's parameter is private.
@QuietMisdreavus
Copy link
Member

Fixed in #46412

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 E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. 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

2 participants