-
-
Notifications
You must be signed in to change notification settings - Fork 14.1k
Add flag to exclude deprecated items in rustdoc #149551
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 |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Instead of not generating items, I think adding a setting to hide them would be better. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Added a flag to hide unstable items (based on feedback in the parent issue). I also tried adding a corresponding option in the settings panel, but ran into two issues:
I will check this out more but will keep the flags for now. |
This comment has been minimized.
This comment has been minimized.
I meant in the JS settings, not at doc generation time. |
|
We talked about this feature in last rustdoc team meeting and it was unanimously accepted by the members present at the time. However, we'd like the implementation to be like #141299. Could you update your PR please? |
|
Some changes occurred in HTML/CSS/JS. |
This comment has been minimized.
This comment has been minimized.
|
The job Click to see the possible cause of the failure (guessed by this bot) |
| // Inject non-visual marker for deprecated filtering in sidebar entries | ||
| // by appending a hidden span to the displayed name. | ||
| // Note: we rely on `Link::new` to accept enriched HTML for the name. | ||
| Link::new(l.href.clone(), format!("{}<span class=\"depr-item\" hidden></span>", l.name)) |
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.
Why adding a hidden attribute?
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 might be better to use deprecated instead of depr-item.
| assoc_types | ||
| .into_iter() | ||
| .map(|l| { | ||
| Link::new(l.href.clone(), format!("{}<span class=\"depr-item\" hidden></span>", l.name)) |
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.
Same question.
| methods | ||
| .into_iter() | ||
| .map(|l| { | ||
| Link::new(l.href.clone(), format!("{}<span class=\"depr-item\" hidden></span>", l.name)) |
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.
Same question.
| <ul> | ||
| {% for child in link.children %} | ||
| <li><a href="#{{child.href|safe}}" title="{{child.name}}"> | ||
| <li{% if (block.heading.name == "Structs" || block.heading.name == "Functions") && child.deprecated +%} class="depr-item"{% endif %}><a href="#{{child.href|safe}}" title="{{child.name}}"> |
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.
I think the only interested check in here should be if child.deprecated.
| <ul class="block{% if !block.class.is_empty() +%} {{+block.class}}{% endif %}"> | ||
| {% for link in block.links %} | ||
| <li> {# #} | ||
| <li{% if (block.heading.name == "Structs" || block.heading.name == "Functions") && link.deprecated +%} class="depr-item"{% endif %}> {# #} |
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.
I think the only interested check in here should be if child.deprecated.
| if (hideDepr === "true") { | ||
| addClass(document.documentElement, "hide-depr"); | ||
| } else { | ||
| removeClass(document.documentElement, "hide-depr"); |
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.
You don't need this else clause.
| window.currentCrate = getVar("current-crate"); | ||
|
|
||
| // Tag deprecated entries in the current page and sidebar, and expose an updater | ||
| function rustdocTagDeprecated() { |
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.
All of these changes are unnecessary. If you have the document class set to hide deprecated items, then a rule in the CSS should hide all of them, there is no need to modify the existing HTML.
| } | ||
|
|
||
| /* General structure and fonts */ | ||
| .hide-depr dt:has(.stab.deprecated), |
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 use hide-deprecated instead of hide-depr.
| .is_some_and(|d| d.is_in_effect()) | ||
| { | ||
| link.deprecated = true; | ||
| link.name_html = Some(format!( |
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.
Not sure to understand why we need this new name_html field.
| .collect(); | ||
|
|
||
| sidebar_module_like(item_sections_in_use, ids, module_like) | ||
| let mut blocks = vec![sidebar_module_like(item_sections_in_use, ids, module_like)]; |
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.
Why changing all this code?
Fixes: #149483
This PR introduces a flag that hides all deprecated items when generating docs.
For example, given the following code:
And on generating the docs:
Edits: