]> git.lizzy.rs Git - rust.git/commit - src/tools/rustfmt
Auto merge of #79742 - GuillaumeGomez:move-tooltips-messages-out-of-html, r=Nemo157
authorbors <bors@rust-lang.org>
Thu, 24 Dec 2020 15:22:28 +0000 (15:22 +0000)
committerbors <bors@rust-lang.org>
Thu, 24 Dec 2020 15:22:28 +0000 (15:22 +0000)
commitb2516121e2f908136ff8351fddd54265a7ba7227
tree7f85be79c3c37b7989a2067d876ffc6eb676a836
parent2acf6ee6d2ab3acf3f4d2117591ac1143c8232fe
parent152d4e74bec46c08e388b47f3c5693929caf377f
Auto merge of #79742 - GuillaumeGomez:move-tooltips-messages-out-of-html, r=Nemo157

Move tooltips messages out of html

First thing first: nothing in the output has changed. You still have the "i" on the left of code blocks examples when they have `ignore`, `compile_fail`, `should_panic` and `edition`. The behavior also remains the same: when you hover the "i", you have the corresponding message showing up.

So now, why this PR then? I realized recently that we were actually generating those messages into the HTML every time whereas all messages are the same (except for the edition ones, I'll come back to it later). So instead of generating more content, I simply moved it inside the CSS thanks to pseudo elements (`::before` and `::after`). The message is now inside `::after` and we use the `::before` to have the small triangle on the left of the message. So now, we have less HTML generated which is seems pretty nice.

So now, back to the `edition` change: the message is globally the same, but the "edition" itself can be different (2015 or 2018 currently, I expect 2021 to arrive not too far in the future). So the only difference for it is that I added a new attribute on the tooltip called `edition` which contains this information. Then, the `::after` uses it inside its `content` (you can get the content of an element's attribute by using `attr` and concat different strings by simply having them after the other).

Don't hesitate if a part of my explanations isn't clear.

r? `@jyn514`
src/librustdoc/html/markdown.rs
src/librustdoc/html/static/rustdoc.css
src/librustdoc/html/static/themes/ayu.css
src/librustdoc/html/static/themes/dark.css
src/librustdoc/html/static/themes/light.css