rust-lang / rust-lang/rust

Check hidden/private items documentation in `rustdoc`

Open
#149,105 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

A-intra-doc-links A-rust-for-linux T-rustdoc
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

Checking hidden/private items in rustdoc can be useful even if no docs are generated/displayed for them. For instance to detect broken intra-doc links there: someone may try to link something that didn't exist, for instance because there was a typo, or the docs became outdated, etc.

It is also nice when something is made public or un-hidden, or when the docs are copy-pasted to somewhere else, i.e. they would have a higher chance of working. Put another way, not checking means that the hidden/private items are, in a sense, less strict.

The fact that they are not checked can be surprising on its own. For instance, there was a brief period of time in 1.92's nightlies when checking actually took place by mistake [1][2], which made @BennoLossin send a fix for it, wondering why previous versions didn't catch it [3].

This can be worked around by doing two passes (i.e. one for checking, and one for the actual generation) with the --document-{hidden,private}-items flags (suggested by Guillaume). However, that requires two passes where one (the bigger one, in fact) will be simply discarded.

A related feature that can cover this one for some projects is the "Runtime toggle for private/hidden items documentation (and /* private fields */)" one, i.e. if there was a runtime toggle to see the private/hidden items, then the docs for those would of course have been checked already even if most users do not see/read them. That feature on its own is something that would be quite interesting [4].

[1] https://github.com/rust-lang/rust/pull/147153#issuecomment-3395484636
[2] https://github.com/rust-lang/rust/pull/147809
[3] https://lore.kernel.org/all/20251016211740.653599-1-lossin@kernel.org/T/
[4] https://github.com/rust-lang/rust/issues/149106

Cc @GuillaumeGomez @fmease @lolbinarycat

@rustbot label T-rustdoc
@rustbot label A-intra-doc-links
@rustbot label A-rust-for-linux

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with rustdoc's handling of the --document-hidden-items and --document-private-items flags, then read the linked issue #149106 and the referenced pull requests for prior behavior. Determine how intra-doc links in hidden and private items can be checked without a second discarded documentation pass; done means those links are validated while normal documentation output remains unchanged.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
documentation
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.