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 --document-hidden-items flag to cargo doc #7766

Open
dtolnay opened this issue Jan 6, 2020 · 7 comments
Open

Add --document-hidden-items flag to cargo doc #7766

dtolnay opened this issue Jan 6, 2020 · 7 comments
Labels
C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` Command-doc S-blocked-external Status: ❌ blocked on something out of the direct control of the Cargo project, e.g., upstream fix

Comments

@dtolnay
Copy link
Member

dtolnay commented Jan 6, 2020

Rustdoc's existing stable --document-private-items flag was split into stable --document-private-items and unstable --document-hidden-items in rust-lang/rust#67875, as these are orthogonal concepts (visibility lower than pub, vs attribute doc(hidden)). Cargo doc has a way to call the first but not the second.

@dtolnay dtolnay added the C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` label Jan 6, 2020
@jyn514
Copy link
Member

jyn514 commented Jan 7, 2020

As a workaround, you could use RUSTDOCFLAGS: RUSTDOCFLAGS='--document-hidden-items' cargo +nightly doc.

@xiongmao86
Copy link
Contributor

If no one is working on this, I would like to take a stab.

@oconnor663
Copy link

Currently it looks like I have to spell this:

RUSTDOCFLAGS='-Z unstable-options --document-hidden-items' cargo +nightly doc

@jyn514
Copy link
Member

jyn514 commented Mar 22, 2021

I have a question for the cargo team - how much of rustdoc's flags do you want to expose? Rustdoc has quite a lot of options:

$ rustdoc --help | grep -- -- | wc -l
67

and it seems silly to expose them all. --document-hidden-items doesn't come to mind as a "primary" option I'd expect lots of people to use.

@ehuss
Copy link
Contributor

ehuss commented Mar 22, 2021

There isn't a formal policy, but generally we only add flags if it seems like they would be commonly used.

@obi1kenobi
Copy link
Member

As a possibly unintended side-effect, this issue also appears to be blocking CI linting of hidden items on stable Rust.

Consider the following example:

/// Hidden fn with broken [rustdoc].
#[doc(hidden)]
pub fn hidden_fn() {}

This function's [rustdoc] link is broken.

However, running RUSTDOCFLAGS='-D warnings' cargo doc --all-features --no-deps --document-private-items reports no issues whatsoever.

Adding --document-hidden-items catches the problem successfully, however as I'm sure we all know, it requires nightly Rust and a much more complex invocation:

$ RUSTDOCFLAGS='-D warnings -Z unstable-options --document-hidden-items' cargo +nightly doc --all-features --no-deps --document-private-items
error: unresolved link to `rustdoc`
  --> example/src/lib.rs:10:28
   |
10 | /// Hidden fn with broken [rustdoc].
   |                            ^^^^^^^ no item named `rustdoc` in scope
   |
   = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
   = note: `-D rustdoc::broken-intra-doc-links` implied by `-D warnings`

error: could not document `example`

@weihanglo weihanglo added the S-blocked-external Status: ❌ blocked on something out of the direct control of the Cargo project, e.g., upstream fix label Aug 14, 2023
@weihanglo
Copy link
Member

From #8001 (comment)

For Cargo team I'd also like to have a conversation about how we want to handle rustdoc flags. Rustdoc has a lot of flags, should we replicate most of them as-is in cargo doc? Some (like --crate-version or --extern-html-root-url) make sense for Cargo to handle internally. Where do we draw the line of "this must be passed with RUSTDOCFLAGS" and "Cargo will forward this flag for you"?

In addition, there is a convention that we normally wait for a flag stabilized and add it to Cargo. Given --document-hidden-items is still unstable, this is labeled as S-blocked-external.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` Command-doc S-blocked-external Status: ❌ blocked on something out of the direct control of the Cargo project, e.g., upstream fix
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants