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

Rustdoc: indicate deprecated items on the sidebar #107568

Closed
tgross35 opened this issue Feb 1, 2023 · 9 comments
Closed

Rustdoc: indicate deprecated items on the sidebar #107568

tgross35 opened this issue Feb 1, 2023 · 9 comments
Labels
A-rustdoc-ui Area: Rustdoc UI (generated HTML) C-enhancement Category: An issue proposing an enhancement or a PR with one. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@tgross35
Copy link
Contributor

tgross35 commented Feb 1, 2023

For example, at this link: https://doc.rust-lang.org/std/macro.try.html

image

try is deprecated but there's no way to easily identify that from the sidebar. Adding a deprecated label there (or the thumbs down emoji if space is a concern) would be quite helpful.

Sorting deprecated items to the bottom would also be quite reasonable imho, to avoid noise for anyone looking for only non-deprecated methods. (This probably wouldn't be bad to do for deprecated methods as well on the main page, since the ordering is a bit random. But that's a separate discussion.)

@rustbot label A-rustdoc-ui C-enhancement T-rustdoc

@rustbot rustbot added A-rustdoc-ui Area: Rustdoc UI (generated HTML) C-enhancement Category: An issue proposing an enhancement or a PR with one. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Feb 1, 2023
@tgross35
Copy link
Contributor Author

tgross35 commented Feb 1, 2023

@jsha
Copy link
Contributor

jsha commented Feb 2, 2023

I think sorting to the bottom would be a bad idea because it violates the typical behavior that the list of methods is sorted alphabetically, and is hard to explain concisely. When people read documentation, it's not only to discover new methods that they might use. It's also to discover the meaning of a method that they saw used in existing code. We shouldn't make a method harder to find just because it's deprecated.

Given the restricted space in the sidebar, I think it's reasonable to require clicking on the item before seeing that it's deprecated. After all, there's no risk that someone will see try in the sidebar and immediately try to use it without reading the documentation. Because without reading the documentation how would you know which arguments to pass it?

@tgross35
Copy link
Contributor Author

tgross35 commented Feb 2, 2023

Good point about the alphabetical sorting, I guess moving them to the bottom isn't needed.

I still think a deprecated or smaller dep. flag would be good, since I see deprecation as quite different from function signatures. It's less about "does this function suit my needs" that you might expect to find in the signature, and more about "should I consider using this function at all". Which doesn't matter when you're trying to understand existing code as in your example, but does matter when you're creating new code.

Having a flag just allows a bit of visual filtering that isn't otherwise available when you're searching for a method. You can kind of guess what a function signature looks like from the name (try_ indicates failable, _with indicates a closure, and the name itself is usually a good description), but there's no equivalent for deprecation. Having a dep. flag would just make it easy to quickly prune off completely useless items from your search.

@GuillaumeGomez
Copy link
Member

I agree with @jsha: the space in the sidebar is very limited so adding new information would need to be very space efficient.

@tgross35
Copy link
Contributor Author

tgross35 commented Feb 3, 2023

Just for a rough idea, this is about what I had in mind:

image

I kind of also like the single letter option. It's better with space and could be used to indicate nightly as well - not that I think this is needed as much as something to indicate deprecation.

image

Just a<span title="" class="stab deprecated sb-flag">Dep.</span> with:

.sb-flag {
	padding: 2.5px;
	margin-bottom: 3px;
	font-size: 0.82rem;
	margin-left: 5px;
}

@tgross35 tgross35 changed the title Rustdoc: indicate deprecated items on the sidebar & sort them to the bottom Rustdoc: indicate deprecated items on the sidebar ~~& sort them to the bottom~~ Feb 3, 2023
@tgross35 tgross35 changed the title Rustdoc: indicate deprecated items on the sidebar ~~& sort them to the bottom~~ Rustdoc: indicate deprecated items on the sidebar ~& sort them to the bottom~ Feb 3, 2023
@tgross35 tgross35 changed the title Rustdoc: indicate deprecated items on the sidebar ~& sort them to the bottom~ Rustdoc: indicate deprecated items on the sidebar Feb 3, 2023
@GuillaumeGomez
Copy link
Member

As soon as the item is too long (where the "..." appears), this wouldn't work anymore. What I had in mind was actually to use the space on the left. But I'm really not sure it's a good idea.

@jsha
Copy link
Contributor

jsha commented Feb 3, 2023

I still don't think this is a good idea. The purpose of the sidebar is skimming for an item name and jumping to it. Any decoration other than the item name slows down that process, and actually draws more attention to the decorated items. It's okay to discover that an item is deprecated by clicking on it.

@Jules-Bertholet
Copy link
Contributor

Jules-Bertholet commented Mar 11, 2023

Another option is to have deprecated items use a different text color in the sidebar ("grayed out"). That way the space used doesn't increase.

@notriddle
Copy link
Contributor

Consensus in the recent meeting seemed to reject this PR.

https://rust-lang.zulipchat.com/#narrow/stream/393423-t-rustdoc.2Fmeetings/topic/meeting.2004-09-2023/near/389048618

Thanks for the time, and sorry it didn't work out.

@notriddle notriddle closed this as not planned Won't fix, can't repro, duplicate, stale Sep 8, 2023
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) C-enhancement Category: An issue proposing an enhancement or a PR with one. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants