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

Reintroduce spotlight/"important traits" feature #74111

Closed
wants to merge 4 commits into from

Conversation

Manishearth
Copy link
Member

@Manishearth Manishearth commented Jul 6, 2020

Fixes #73785

This PR reintroduces the "spotlight" ("important traits") feature.

A couple changes have been made:

As there were concerns about its visibility, it has been moved to be next to the return type, as opposed to being on the side.

It also no longer produces a modal, it shows the traits on hover, and it can be clicked on to pin the hover bubble.

image

image

It also works fine on mobile:

image

@rust-highfive
Copy link
Collaborator

Some changes occurred in HTML/CSS/JS.

cc @GuillaumeGomez

Some changes occurred in HTML/CSS themes.

cc @GuillaumeGomez

@rust-highfive
Copy link
Collaborator

r? @steveklabnik

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 6, 2020
@Manishearth
Copy link
Member Author

Manishearth commented Jul 6, 2020

r? @kinnison @GuillaumeGomez

cc @jyn514

@GuillaumeGomez
Copy link
Member

Sorry but I'm still not in favor of this feature and the @rust-lang/rustdoc already voted to opt it out. It has been proven to be more noise than useful (and not only from the twitter thread linked in the issue).

@Mark-Simulacrum
Copy link
Member

I feel like closing this is premature. I don't see an FCP for removal anywhere, and based on @kinnison's comments on #73785 there's not really consensus amongst T-rustdoc that this isn't a good feature to have, rather, it was deemed "not horrible" to remove given your (strong?) opinion, especially because reverting that decision was relatively easy.

I for one continue to miss this feature pretty much every time I'm working with some non-obvious iterator where knowing the item type is super useful. The same goes for interactions with futures libraries, where it's particularly painful to figure out the item type.

If the problem is the choice of trait to display, IMO, we can require that the trait must be annotated with something like #[rustdoc::notable_trait] or whatever (fine to make unstable for now).

I don't think I've seen any discussion of why you're against it beyond it being too much information -- but the key point to me is that this is just enough information. I don't usually care about anything except for the Item/Output associated type, I already have a pretty good idea about the methods etc that Iterator and/or FutureExt or so provide.

@GuillaumeGomez
Copy link
Member

Like I said, this decision doesn't come out of nowhere. It had a few downsides but the main one was simply that users didn't use it (and I don't have this information only from the twitter thread like I said). We kept this feature around for a while and whenever I talked about it, people just realized it existed and didn't find it useful in most cases and often they just didn't understand what it was used for.

The other big issue was the amount of JS code needed for it. Maintaining something used by a very small minority of users is not worth it considering how much time it takes me to maintain them. Also, "important traits" or whatever the name still remains a very anecdotal information.

Anyway, like I said, the rustdoc team opted it. If you want to debate about this feature, we can do it in an issue so no one loses more time than necessary writing code to get it closed like this (I really feel bad about that because of the time @Manishearth took to write this PR...). But as is, this is a no-go.

@GuillaumeGomez GuillaumeGomez reopened this Jul 6, 2020
@GuillaumeGomez
Copy link
Member

So after discussion with @Manishearth, we came to this conclusion: a few more steps will be required to reach a good enough level for everyone to be able to enjoy this feature, and in order to do so, we'll do it in multiple steps (asking for feedbacks along the road).

For the current PR, I propose the following changes:

  • Please reword it to make it more clear.
  • No popup, just a hover (eventually click) event handling for the text to appear (like a bubble, not a popup). The click handling is for the mobile devices.
  • If possible, as little JS as possible (some CSS would allow us to handle the bubble easily on hover/click through a class).

@Manishearth Manishearth changed the title Reintroduce spotlight, move next to the return type Reintroduce spotlight/"important traits" feature Jul 7, 2020
@Manishearth
Copy link
Member Author

@GuillaumeGomez made all the changes. The JS now used by this feature is minimal.

This makes the spotlight show on hover instead of click. Clicks can be
used to persist it, which is also what's used on mobile.
@bors
Copy link
Contributor

bors commented Jul 7, 2020

☔ The latest upstream changes (presumably #74117) made this pull request unmergeable. Please resolve the merge conflicts.

@@ -2621,6 +2624,16 @@ function defocusSearchBar() {
});
}());

function showImportantTraits(content) {
let list = content.classList
Copy link
Member

Choose a reason for hiding this comment

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

What is list used for?

@@ -2621,6 +2624,16 @@ function defocusSearchBar() {
});
}());

function showImportantTraits(content) {
let list = content.classList
Copy link
Member

Choose a reason for hiding this comment

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

Missing ; too. :)

@@ -2621,6 +2624,16 @@ function defocusSearchBar() {
});
}());

function showImportantTraits(content) {
Copy link
Member

Choose a reason for hiding this comment

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

Actually, this function is never used. Please remove it.


onEachLazy(document.getElementsByClassName("important-traits"), function(e) {
e.onclick = function() {
e.getElementsByClassName('important-traits-tooltiptext')[0].classList.toggle("force-tooltip")
Copy link
Member

Choose a reason for hiding this comment

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

I think it's better to use either this or event.target in here (event would be the first argument given to onclick).

Copy link
Member Author

Choose a reason for hiding this comment

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

Wouldn't that just be e anyway?

Copy link
Member

Choose a reason for hiding this comment

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

I'm not too confident about the variable capture process in JS so I prefer to minimize it as much as possible.


onEachLazy(document.getElementsByClassName("important-traits"), function(e) {
e.onclick = function() {
e.getElementsByClassName('important-traits-tooltiptext')[0].classList.toggle("force-tooltip")
Copy link
Member

Choose a reason for hiding this comment

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

Also missing ;.

@GuillaumeGomez
Copy link
Member

You'll need to add the CSS changes inside the newly added ayu theme too.

@@ -363,6 +363,7 @@ function defocusSearchBar() {
function handleEscape(ev) {
var help = getHelpElement();
var search = getSearchElement();
hideModal();
Copy link
Member

Choose a reason for hiding this comment

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

Why did you add the hideModal calls BTW?

Copy link
Member Author

Choose a reason for hiding this comment

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

Didn't intend to. Will fix.

@@ -337,6 +337,11 @@ pre.ignore:hover, .information:hover + pre.ignore {
border-color: transparent black transparent transparent;
}

.important-traits-tooltiptext {
background-color: #111 !important;
Copy link
Member

Choose a reason for hiding this comment

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

Do you really need !important? Generally, just giving a more precise selector allows to override things without needing them.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, because we're just overriding the same declaration in the themeless version. I added a decl in the themeless version with the intent of having okayish defaults.

Copy link
Member

Choose a reason for hiding this comment

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

Maybe remove it from the themeless version then? We always have themes after all...

@Manishearth
Copy link
Member Author

Everything addressed except for the Ayu thing. I'll add that shortly after trying out my rebased build

@Manishearth
Copy link
Member Author

Hmm, i've updated my branch but the PR seems frozen https://github.com/Manishearth/rust/tree/re-spotlight

@Manishearth
Copy link
Member Author

Reopened as #74370

Manishearth added a commit to Manishearth/rust that referenced this pull request Jul 16, 2020
…meGomez

Reintroduce spotlight / "important traits" feature

(Reopened version of rust-lang#74111 because Github is broken, see discussion there)

Fixes rust-lang#73785

This PR reintroduces the "spotlight" ("important traits") feature.

A couple changes have been made:

As there were concerns about its visibility, it has been moved to be next to the return type, as opposed to being on the side.

It also no longer produces a modal, it shows the traits on hover, and it can be clicked on to pin the hover bubble.

![image](https://user-images.githubusercontent.com/1617736/86674555-a82d2600-bfad-11ea-9a4a-a1a9ffd66ae5.png)

![image](https://user-images.githubusercontent.com/1617736/86674533-a1061800-bfad-11ea-9e8a-c62ad86ed0d7.png)

It also works fine on mobile:

![image](https://user-images.githubusercontent.com/1617736/86674638-bda25000-bfad-11ea-8d8d-1798b608923e.png)
Manishearth added a commit to Manishearth/rust that referenced this pull request Jul 16, 2020
…meGomez

Reintroduce spotlight / "important traits" feature

(Reopened version of rust-lang#74111 because Github is broken, see discussion there)

Fixes rust-lang#73785

This PR reintroduces the "spotlight" ("important traits") feature.

A couple changes have been made:

As there were concerns about its visibility, it has been moved to be next to the return type, as opposed to being on the side.

It also no longer produces a modal, it shows the traits on hover, and it can be clicked on to pin the hover bubble.

![image](https://user-images.githubusercontent.com/1617736/86674555-a82d2600-bfad-11ea-9a4a-a1a9ffd66ae5.png)

![image](https://user-images.githubusercontent.com/1617736/86674533-a1061800-bfad-11ea-9e8a-c62ad86ed0d7.png)

It also works fine on mobile:

![image](https://user-images.githubusercontent.com/1617736/86674638-bda25000-bfad-11ea-8d8d-1798b608923e.png)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Reintroduce spotlight feature ("important traits")
7 participants