Skip to content

Conversation

@chojs23
Copy link
Contributor

@chojs23 chojs23 commented Jan 12, 2026

Move #[doc(hidden)] into the shared code-attribute renderer so it matches the styling and placement of other attributes in rustdoc HTML.

Closes #132304

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output. labels Jan 12, 2026
@rustbot
Copy link
Collaborator

rustbot commented Jan 12, 2026

r? @GuillaumeGomez

rustbot has assigned @GuillaumeGomez.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@JayanAXHF JayanAXHF added the A-rustdoc-ui Area: Rustdoc UI (generated HTML) label Jan 12, 2026
@chojs23 chojs23 force-pushed the fix/hidden-attr-docs branch from 719dca9 to d88a903 Compare January 13, 2026 11:01
@rustbot

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

use crate::html::format::print_anchor;

let visibility_and_hidden = visibility_and_hidden(myitem);
write!(w, "<dt><code>")?;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move this into render_attributes_in_code so we don't write <dt><code> if there are no attributes.

Move `#[doc(hidden)]` into the shared code-attribute renderer so it
matches the styling and placement of other attributes in rustdoc HTML.
@chojs23 chojs23 force-pushed the fix/hidden-attr-docs branch from b6e120a to 273d673 Compare January 15, 2026 07:02
@rustbot
Copy link
Collaborator

rustbot commented Jan 15, 2026

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

//@ has - '//dt/span[@title="Hidden item"]' '👻'

//@ has - '//*[@id="reexport.hidden_reexport"]/code' '#[doc(hidden)] pub use hidden::inside_hidden as hidden_reexport;'
//@ has - '//dt/span[@title="Hidden item"]' '👻'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's duplicated with the check on line 8.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, is there a way like for reexports to check it's the reexport that has this ghost and not just any item?

Comment on lines +2932 to +2940
let mut render_attr = |attr: &str| -> fmt::Result {
if !wrote_any {
if let Some(open_tag) = open_tag {
w.write_str(open_tag)?;
}
wrote_any = true;
}
render_code_attribute(prefix, attr, w)
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In case open_tag is None, we could remove the need for the if check by creating two different closures:

Suggested change
let mut render_attr = |attr: &str| -> fmt::Result {
if !wrote_any {
if let Some(open_tag) = open_tag {
w.write_str(open_tag)?;
}
wrote_any = true;
}
render_code_attribute(prefix, attr, w)
};
let mut render_attr: FnMut(&str) -> fmt::Result = if let Some(open_tag) = open_tag {
|attr: &str| -> fmt::Result {
if !wrote_any {
w.write_str(open_tag)?;
wrote_any = true;
}
render_code_attribute(prefix, attr, w)
}
} else {
|attr: &str| -> fmt::Result {
render_code_attribute(prefix, attr, w)
}
};

Not sure it compiles but with a few tweaks it should (or use functions instead, it works too).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-rustdoc-ui Area: Rustdoc UI (generated HTML) S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

rustdoc: Appearance of #[doc(hidden)] differs from all the other attributes

5 participants