-
-
Notifications
You must be signed in to change notification settings - Fork 14.3k
rustdoc: render doc(hidden) as a code attribute #151001
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
base: main
Are you sure you want to change the base?
Conversation
|
rustbot has assigned @GuillaumeGomez. Use |
719dca9 to
d88a903
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| use crate::html::format::print_anchor; | ||
|
|
||
| let visibility_and_hidden = visibility_and_hidden(myitem); | ||
| write!(w, "<dt><code>")?; |
There was a problem hiding this comment.
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.
b6e120a to
273d673
Compare
|
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"]' '👻' |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
| 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) | ||
| }; |
There was a problem hiding this comment.
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:
| 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).
Move
#[doc(hidden)]into the shared code-attribute renderer so it matches the styling and placement of other attributes in rustdoc HTML.Closes #132304