rustdoc: notable trait badge color attribute - #160370
Conversation
|
Some changes occurred in GUI tests. Some changes occurred in HTML/CSS/JS. cc @GuillaumeGomez, @lolbinarycat Some changes occurred in compiler/rustc_attr_parsing cc @jdonszelmann, @JonathanBrouwer Some changes occurred in compiler/rustc_hir/src/attrs |
|
rustbot has assigned @petrochenkov. Use Why was this reviewer chosen?The reviewer was selected based on:
|
| --notable-badge-pink: oklch(0.88 0.21 0); | ||
| --notable-badge-red: oklch(0.88 0.21 40); | ||
| --notable-badge-orange: oklch(0.88 0.21 70); | ||
| --notable-badge-grey: oklch(0.88 0 0); |
There was a problem hiding this comment.
We're now switching to 8 colors?
There was a problem hiding this comment.
I can’t find it in the meeting minutes, but I remember mentioning the possibility of using the ANSI 3-bit color pallet, because it makes both directions of interop easier:
- terminal apps like rusty-man can display these colors without requiring their own bespoke color theming system
- anyone adding new themes to rustdoc-html can easily use a terminal color theme as a starting point
| {% if !notable_trait_badges.is_empty() %} | ||
| <div class="notable-trait-badge-container"> | ||
| {% for badge in notable_trait_badges.iter() %} | ||
| <a class="notable-trait-badge notable-trait-badge-{{badge.color}}" |
There was a problem hiding this comment.
I feel like this is duplicating information: the parent is already the unique class notable-trait-badge-container and the badge itself already has the notable-trait-badge class, so having notable-trait-badge- seems too much (also maybe we should remove the notable-trait-badge class). What about just keeping the color?
There was a problem hiding this comment.
Oh also, please indent. Makes it simpler to read the template.
| one of the other colors in the list: | ||
|
|
||
| <style> | ||
| .notabletrait-badge { |
There was a problem hiding this comment.
Why changing the appearance of the badge?
There was a problem hiding this comment.
I wanted the text inside the badge to be aligned with the code block below it.
| border-radius: 6px; | ||
| padding: 8px; | ||
| } | ||
| .notabletrait-badge.light { |
There was a problem hiding this comment.
Same: why changing the color property?
| border-color: #0f1419; | ||
| } | ||
| /* https://github.com/rust-lang/rust/pull/91480 */ | ||
| .notabletrait-badge.light.grey { |
There was a problem hiding this comment.
I'm really not sure it's worth it to show people how to add their own colors.
| padding: 0 0.5rem; | ||
| border-radius: 0.75rem; | ||
| padding: 0 14px; | ||
| border-radius: var(--code-block-border-radius); |
There was a problem hiding this comment.
Why this change?
There was a problem hiding this comment.
It’s the same padding and border radius as code blocks.
| --notable-badge-violet: oklch(0.88 0.21 300); | ||
| --notable-badge-magenta: oklch(0.88 0.21 320); | ||
| --notable-badge-cyan: oklch(0.88 0.21 180); | ||
| --notable-badge-transparent: white; |
There was a problem hiding this comment.
I don't think having text floating around is a good idea, especially when it's a color picked by rustdoc automatically...
Co-authored-by: Guillaume Gomez <contact@guillaume-gomez.fr>
|
The job Click to see the possible cause of the failure (guessed by this bot) |
| Transparent, | ||
| } | ||
|
|
||
| impl Into<&'static str> for NotableTraitColor { |
There was a problem hiding this comment.
Should we prefer From ?
Also, should we consider having the opposite direction ? Simplifying the parsing code and grouping similar behaviour in here.
| /// Determines whether an item is annotated with `#[doc(notable_trait)]`. | ||
| query is_doc_notable_trait(def_id: DefId) -> bool { | ||
| /// If an item is annotated with `#[doc(notable_trait)]`, | ||
| /// returns the color used to render its pill. If the crate specifies |
There was a problem hiding this comment.
Is it a pill or a badge ? We should have consistent naming
Part of #45040
Screenshots