Skip to content

Commit

Permalink
Rollup merge of rust-lang#84283 - jsha:de-emphasize-attributes, r=Gui…
Browse files Browse the repository at this point in the history
…llaumeGomez

rustdoc: Reduce visual weight of attributes.

Followup from rust-lang#83337. As part of that PR, we stopped hiding attributes behind a toggle, because most things have just zero or one attributes. However, this made clear that the current rendering of attributes emphasizes them a lot, which distracts from function signatures. This PR changes their color of attributes to be the same as the toggles, and reduces their font weight.

This also removes `#[lang]` from the list of ALLOWED_ATTRIBUTES. This attribute is an implementation detail rather than part of the public-facing documentation.

![image](https://user-images.githubusercontent.com/220205/115131061-cc407d80-9fa9-11eb-9a77-ad3f3217f391.png)

Demo at https://hoffman-andrews.com/rust/de-emph-attr/std/string/struct.String.html#method.trim
  • Loading branch information
GuillaumeGomez committed Apr 18, 2021
2 parents 55be034 + e23b035 commit bc43227
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 4 deletions.
1 change: 0 additions & 1 deletion src/librustdoc/html/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -989,7 +989,6 @@ fn render_assoc_item(

const ALLOWED_ATTRIBUTES: &[Symbol] = &[
sym::export_name,
sym::lang,
sym::link_section,
sym::must_use,
sym::no_mangle,
Expand Down
4 changes: 4 additions & 0 deletions src/librustdoc/html/static/rustdoc.css
Original file line number Diff line number Diff line change
Expand Up @@ -967,6 +967,10 @@ a.test-arrow:hover{
color: inherit;
}

.code-attribute {
font-weight: 300;
}

.collapse-toggle {
font-weight: 300;
position: absolute;
Expand Down
3 changes: 2 additions & 1 deletion src/librustdoc/html/static/themes/ayu.css
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,8 @@ a.test-arrow:hover {
color: #c5c5c5;
}

.toggle-label {
.toggle-label,
.code-attribute {
color: #999;
}

Expand Down
3 changes: 2 additions & 1 deletion src/librustdoc/html/static/themes/dark.css
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,8 @@ a.test-arrow:hover{
background-color: #4e8bca;
}

.toggle-label {
.toggle-label,
.code-attribute {
color: #999;
}

Expand Down
3 changes: 2 additions & 1 deletion src/librustdoc/html/static/themes/light.css
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,8 @@ a.test-arrow:hover{
background-color: #4e8bca;
}

.toggle-label {
.toggle-label,
.code-attribute {
color: #999;
}

Expand Down

0 comments on commit bc43227

Please sign in to comment.