Skip to content

Commit

Permalink
Split CSS classes for "typedef" vs "associatedtype".
Browse files Browse the repository at this point in the history
  • Loading branch information
jsha committed Dec 11, 2021
1 parent c8e0f97 commit 3f517fb
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/librustdoc/html/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -944,7 +944,7 @@ fn fmt_type<'cx>(
Ok((ref url, _, ref path)) if !f.alternate() => {
write!(
f,
"<a class=\"type\" href=\"{url}#{shortty}.{name}\" \
"<a class=\"associatedtype\" href=\"{url}#{shortty}.{name}\" \
title=\"type {path}::{name}\">{name}</a>",
url = url,
shortty = ItemType::AssocType,
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/html/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,7 @@ fn assoc_type(
) {
write!(
w,
"{}type <a href=\"{}\" class=\"type\">{}</a>",
"{}type <a href=\"{}\" class=\"associatedtype\">{}</a>",
extra,
naive_assoc_href(it, link, cx),
it.name.as_ref().unwrap()
Expand Down
12 changes: 10 additions & 2 deletions src/librustdoc/html/static/css/themes/ayu.css
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,12 @@ pre, .rustdoc.source .example-wrap {
.content span.type, .content a.type {
color: #39AFD7;
}
.content span.type,
.content a.type,
.block a.current.type { color: #39AFD7; }
.content span.associatedtype,
.content a.associatedtype,
.block a.current.associatedtype { color: #39AFD7; }
.content span.fn, .content a.fn, .content span.method,
.content a.method, .content span.tymethod,
.content a.tymethod, .content .fnname {
Expand Down Expand Up @@ -454,11 +460,12 @@ above the `@media (max-width: 700px)` rules due to a bug in the css checker */
.block a.current.derive,.content span.macro,.content a.macro,.block a.current.macro {}
.content span.struct,.content a.struct,.block a.current.struct {}
#titles>button:hover,#titles>button.selected {}
.content span.type,.content a.type,.block a.current.type {}
.content span.typedef,.content a.typedef,.block a.current.typedef {}
.content span.union,.content a.union,.block a.current.union {}
pre.rust .lifetime {}
.stab.unstable {}
h2,h3:not(.impl):not(.method):not(.type):not(.tymethod),h4:not(.method):not(.type):not(.tymethod) {}
h2,
h3:not(.impl):not(.method):not(.type):not(.tymethod), h4:not(.method):not(.type):not(.tymethod) {}
.content span.enum,.content a.enum,.block a.current.enum {}
.content span.constant,.content a.constant,.block a.current.constant,.content span.static,
.content a.static, .block a.current.static {}
Expand Down Expand Up @@ -495,6 +502,7 @@ a.result-fn:focus,
a.result-method:focus,
a.result-tymethod:focus {}
a.result-type:focus {}
a.result-associatedtype:focus {}
a.result-foreigntype:focus {}
a.result-attr:focus,
a.result-derive:focus,
Expand Down
8 changes: 6 additions & 2 deletions src/librustdoc/html/static/css/themes/dark.css
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ a.result-union:focus { background-color: #194e9f; }
a.result-fn:focus,
a.result-method:focus,
a.result-tymethod:focus { background-color: #4950ed; }
a.result-type:focus { background-color: #884719; }
a.result-type:focus { background-color: #194e9f; }
a.result-associatedtype:focus { background-color: #884719; }
a.result-foreigntype:focus { background-color: #194e9f; }
a.result-attr:focus,
a.result-derive:focus,
Expand All @@ -140,7 +141,10 @@ a.result-keyword:focus { background-color: #884719; }

.content span.enum, .content a.enum, .block a.current.enum { color: #2dbfb8; }
.content span.struct, .content a.struct, .block a.current.struct { color: #2dbfb8; }
.content span.type, .content a.type, .block a.current.type { color: #D2991D; }
.content span.type, .content a.type, .block a.current.type { color: #2dbfb8; }
.content span.associatedtype,
.content a.associatedtype,
.block a.current.associatedtype { color: #D2991D; }
.content span.foreigntype, .content a.foreigntype, .block a.current.foreigntype { color: #2dbfb8; }
.content span.attr, .content a.attr, .block a.current.attr,
.content span.derive, .content a.derive, .block a.current.derive,
Expand Down
10 changes: 7 additions & 3 deletions src/librustdoc/html/static/css/themes/light.css
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ a.result-union:focus { background-color: #e7b1a0; }
a.result-fn:focus,
a.result-method:focus,
a.result-tymethod:focus { background-color: #c6afb3; }
a.result-type:focus { background-color: #afc6e4; }
a.result-type:focus { background-color: #e7b1a0; }
a.result-associatedtype:focus { background-color: #afc6e4; }
a.result-foreigntype:focus { background-color: #e7b1a0; }
a.result-attr:focus,
a.result-derive:focus,
Expand All @@ -140,8 +141,11 @@ a.result-keyword:focus { background-color: #afc6e4; }

.content span.enum, .content a.enum, .block a.current.enum { color: #AD378A; }
.content span.struct, .content a.struct, .block a.current.struct { color: #AD378A; }
.content span.type, .content a.type, .block a.current.type { color: #3873AD; }
.content span.foreigntype, .content a.foreigntype, .block a.current.foreigntype { color: #AD378A; }
.content span.type, .content a.type, .block a.current.type { color: #AD378A; }
.content span.foreigntype, .content a.foreigntype, .block a.current.foreigntype { color: #3873AD; }
.content span.associatedtype,
.content a.associatedtype,
.block a.current.associatedtype { color: #3873AD; }
.content span.attr, .content a.attr, .block a.current.attr,
.content span.derive, .content a.derive, .block a.current.derive,
.content span.macro, .content a.macro, .block a.current.macro { color: #068000; }
Expand Down
4 changes: 2 additions & 2 deletions src/test/rustdoc-gui/font-weight.goml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ goto: file://|DOC_PATH|/lib2/trait.Trait.html
assert-count: ("//*[@class='docblock item-decl']/pre[@class='rust trait']/code/a[@class='constant']//text()/parent::*", 1)
assert-css: ("//*[@class='docblock item-decl']/pre[@class='rust trait']/code/a[@class='constant']//text()/parent::*", {"font-weight": "400"})

assert-count: (".methods .type", 1)
assert-css: (".methods .type", {"font-weight": "600"})
assert-count: (".methods .associatedtype", 1)
assert-css: (".methods .associatedtype", {"font-weight": "600"})
assert-count: (".methods .constant", 1)
assert-css: (".methods .constant", {"font-weight": "600"})
assert-css: (".methods .method", {"font-weight": "600"})
3 changes: 1 addition & 2 deletions src/test/rustdoc/assoc-item-cast.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#![crate_name = "foo"]


pub trait Expression {
type SqlType;
}
Expand All @@ -11,5 +10,5 @@ pub trait AsExpression<T> {
}

// @has foo/type.AsExprOf.html
// @has - '//*[@class="rust typedef"]' 'type AsExprOf<Item, Type> = <Item as AsExpression<Type>>::Expression;'
// @has - '//pre[@class="rust typedef"]' 'type AsExprOf<Item, Type> = <Item as AsExpression<Type>>::Expression;'
pub type AsExprOf<Item, Type> = <Item as AsExpression<Type>>::Expression;
7 changes: 3 additions & 4 deletions src/test/rustdoc/trait-impl-items-links-and-anchors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ pub trait MyTrait {
fn defaulted_override(&self) {}
}


impl MyTrait for String {
// @has trait_impl_items_links_and_anchors/trait.MyTrait.html '//div[@id="associatedtype.Assoc-1"]//a[@class="type"]/@href' #associatedtype.Assoc
// @has trait_impl_items_links_and_anchors/trait.MyTrait.html '//div[@id="associatedtype.Assoc-1"]//a[@class="associatedtype"]/@href' #associatedtype.Assoc
// @has trait_impl_items_links_and_anchors/trait.MyTrait.html '//div[@id="associatedtype.Assoc-1"]//a[@class="anchor"]/@href' #associatedtype.Assoc-1
type Assoc = ();
// @has trait_impl_items_links_and_anchors/trait.MyTrait.html '//div[@id="associatedconstant.VALUE-1"]//a[@class="constant"]/@href' #associatedconstant.VALUE
Expand All @@ -23,7 +22,7 @@ impl MyTrait for String {
}

impl MyTrait for Vec<u8> {
// @has trait_impl_items_links_and_anchors/trait.MyTrait.html '//div[@id="associatedtype.Assoc-2"]//a[@class="type"]/@href' #associatedtype.Assoc
// @has trait_impl_items_links_and_anchors/trait.MyTrait.html '//div[@id="associatedtype.Assoc-2"]//a[@class="associatedtype"]/@href' #associatedtype.Assoc
// @has trait_impl_items_links_and_anchors/trait.MyTrait.html '//div[@id="associatedtype.Assoc-2"]//a[@class="anchor"]/@href' #associatedtype.Assoc-2
type Assoc = ();
// @has trait_impl_items_links_and_anchors/trait.MyTrait.html '//div[@id="associatedconstant.VALUE-2"]//a[@class="constant"]/@href' #associatedconstant.VALUE
Expand All @@ -39,7 +38,7 @@ impl MyTrait for Vec<u8> {

impl MyTrait for MyStruct {
// @has trait_impl_items_links_and_anchors/trait.MyTrait.html '//div[@id="associatedtype.Assoc-3"]//a[@class="anchor"]/@href' #associatedtype.Assoc-3
// @has trait_impl_items_links_and_anchors/struct.MyStruct.html '//div[@id="associatedtype.Assoc"]//a[@class="type"]/@href' trait.MyTrait.html#associatedtype.Assoc
// @has trait_impl_items_links_and_anchors/struct.MyStruct.html '//div[@id="associatedtype.Assoc"]//a[@class="associatedtype"]/@href' trait.MyTrait.html#associatedtype.Assoc
// @has trait_impl_items_links_and_anchors/struct.MyStruct.html '//div[@id="associatedtype.Assoc"]//a[@class="anchor"]/@href' #associatedtype.Assoc
type Assoc = bool;
// @has trait_impl_items_links_and_anchors/trait.MyTrait.html '//div[@id="associatedconstant.VALUE-3"]//a[@class="anchor"]/@href' #associatedconstant.VALUE-3
Expand Down

0 comments on commit 3f517fb

Please sign in to comment.