Skip to content

Commit caf6c57

Browse files
Rename "stability" CSS class to "item-info"
1 parent 53d19b3 commit caf6c57

File tree

8 files changed

+59
-53
lines changed

8 files changed

+59
-53
lines changed

Diff for: src/librustdoc/html/render/mod.rs

+28-23
Original file line numberDiff line numberDiff line change
@@ -1844,7 +1844,7 @@ fn document(w: &mut Buffer, cx: &Context, item: &clean::Item, parent: Option<&cl
18441844
if let Some(ref name) = item.name {
18451845
info!("Documenting {}", name);
18461846
}
1847-
document_stability(w, cx, item, false, parent);
1847+
document_item_info(w, cx, item, false, parent);
18481848
document_full(w, item, cx, "", false);
18491849
}
18501850

@@ -1928,18 +1928,23 @@ fn document_full(w: &mut Buffer, item: &clean::Item, cx: &Context, prefix: &str,
19281928
}
19291929
}
19301930

1931-
fn document_stability(
1931+
/// Add extra information about an item such as:
1932+
///
1933+
/// * Stability
1934+
/// * Deprecated
1935+
/// * Required features (through the `doc_cfg` feature)
1936+
fn document_item_info(
19321937
w: &mut Buffer,
19331938
cx: &Context,
19341939
item: &clean::Item,
19351940
is_hidden: bool,
19361941
parent: Option<&clean::Item>,
19371942
) {
1938-
let stabilities = short_stability(item, cx, parent);
1939-
if !stabilities.is_empty() {
1940-
write!(w, "<div class=\"stability{}\">", if is_hidden { " hidden" } else { "" });
1941-
for stability in stabilities {
1942-
write!(w, "{}", stability);
1943+
let item_infos = short_item_info(item, cx, parent);
1944+
if !item_infos.is_empty() {
1945+
write!(w, "<div class=\"item-info{}\">", if is_hidden { " hidden" } else { "" });
1946+
for info in item_infos {
1947+
write!(w, "{}", info);
19431948
}
19441949
write!(w, "</div>");
19451950
}
@@ -2194,7 +2199,7 @@ fn item_module(w: &mut Buffer, cx: &Context, item: &clean::Item, items: &[clean:
21942199
<td class=\"docblock-short\">{stab_tags}{docs}</td>\
21952200
</tr>",
21962201
name = *myitem.name.as_ref().unwrap(),
2197-
stab_tags = stability_tags(myitem, item),
2202+
stab_tags = extra_info_tags(myitem, item),
21982203
docs = MarkdownSummaryLine(doc_value, &myitem.links()).into_string(),
21992204
class = myitem.type_(),
22002205
add = add,
@@ -2216,9 +2221,9 @@ fn item_module(w: &mut Buffer, cx: &Context, item: &clean::Item, items: &[clean:
22162221
}
22172222
}
22182223

2219-
/// Render the stability and deprecation tags that are displayed in the item's summary at the
2220-
/// module level.
2221-
fn stability_tags(item: &clean::Item, parent: &clean::Item) -> String {
2224+
/// Render the stability, deprecation and portability tags that are displayed in the item's summary
2225+
/// at the module level.
2226+
fn extra_info_tags(item: &clean::Item, parent: &clean::Item) -> String {
22222227
let mut tags = String::new();
22232228

22242229
fn tag_html(class: &str, title: &str, contents: &str) -> String {
@@ -2271,10 +2276,10 @@ fn portability(item: &clean::Item, parent: Option<&clean::Item>) -> Option<Strin
22712276
Some(format!("<div class=\"stab portability\">{}</div>", cfg?.render_long_html()))
22722277
}
22732278

2274-
/// Render the stability and/or deprecation warning that is displayed at the top of the item's
2275-
/// documentation.
2276-
fn short_stability(item: &clean::Item, cx: &Context, parent: Option<&clean::Item>) -> Vec<String> {
2277-
let mut stability = vec![];
2279+
/// Render the stability, deprecation and portability information that is displayed at the top of
2280+
/// the item's documentation.
2281+
fn short_item_info(item: &clean::Item, cx: &Context, parent: Option<&clean::Item>) -> Vec<String> {
2282+
let mut extra_info = vec![];
22782283
let error_codes = cx.shared.codes;
22792284

22802285
if let Some(Deprecation { ref note, ref since, is_since_rustc_version }) = item.deprecation {
@@ -2301,7 +2306,7 @@ fn short_stability(item: &clean::Item, cx: &Context, parent: Option<&clean::Item
23012306
);
23022307
message.push_str(&format!(": {}", html.into_string()));
23032308
}
2304-
stability.push(format!(
2309+
extra_info.push(format!(
23052310
"<div class=\"stab deprecated\"><span class=\"emoji\">👎</span> {}</div>",
23062311
message,
23072312
));
@@ -2345,14 +2350,14 @@ fn short_stability(item: &clean::Item, cx: &Context, parent: Option<&clean::Item
23452350
);
23462351
}
23472352

2348-
stability.push(format!("<div class=\"stab unstable\">{}</div>", message));
2353+
extra_info.push(format!("<div class=\"stab unstable\">{}</div>", message));
23492354
}
23502355

23512356
if let Some(portability) = portability(item, parent) {
2352-
stability.push(portability);
2357+
extra_info.push(portability);
23532358
}
23542359

2355-
stability
2360+
extra_info
23562361
}
23572362

23582363
fn item_constant(w: &mut Buffer, cx: &Context, it: &clean::Item, c: &clean::Constant) {
@@ -3703,7 +3708,7 @@ fn render_impl(
37033708

37043709
if trait_.is_some() {
37053710
if let Some(portability) = portability(&i.impl_item, Some(parent)) {
3706-
write!(w, "<div class=\"stability\">{}</div>", portability);
3711+
write!(w, "<div class=\"item-info\">{}</div>", portability);
37073712
}
37083713
}
37093714

@@ -3801,7 +3806,7 @@ fn render_impl(
38013806
if let Some(it) = t.items.iter().find(|i| i.name == item.name) {
38023807
// We need the stability of the item from the trait
38033808
// because impls can't have a stability.
3804-
document_stability(w, cx, it, is_hidden, Some(parent));
3809+
document_item_info(w, cx, it, is_hidden, Some(parent));
38053810
if item.doc_value().is_some() {
38063811
document_full(w, item, cx, "", is_hidden);
38073812
} else if show_def_docs {
@@ -3811,13 +3816,13 @@ fn render_impl(
38113816
}
38123817
}
38133818
} else {
3814-
document_stability(w, cx, item, is_hidden, Some(parent));
3819+
document_item_info(w, cx, item, is_hidden, Some(parent));
38153820
if show_def_docs {
38163821
document_full(w, item, cx, "", is_hidden);
38173822
}
38183823
}
38193824
} else {
3820-
document_stability(w, cx, item, is_hidden, Some(parent));
3825+
document_item_info(w, cx, item, is_hidden, Some(parent));
38213826
if show_def_docs {
38223827
document_short(w, item, link, "", is_hidden);
38233828
}

Diff for: src/librustdoc/html/static/main.js

+9-8
Original file line numberDiff line numberDiff line change
@@ -2266,7 +2266,7 @@ function defocusSearchBar() {
22662266
}
22672267
}
22682268
var ns = n.nextElementSibling;
2269-
while (ns && (hasClass(ns, "docblock") || hasClass(ns, "stability"))) {
2269+
while (ns && (hasClass(ns, "docblock") || hasClass(ns, "item-info"))) {
22702270
if (addOrRemove) {
22712271
addClass(ns, "hidden-by-impl-hider");
22722272
} else {
@@ -2282,7 +2282,7 @@ function defocusSearchBar() {
22822282
var action = mode;
22832283
if (hasClass(toggle.parentNode, "impl") === false) {
22842284
relatedDoc = toggle.parentNode.nextElementSibling;
2285-
if (hasClass(relatedDoc, "stability")) {
2285+
if (hasClass(relatedDoc, "item-info")) {
22862286
relatedDoc = relatedDoc.nextElementSibling;
22872287
}
22882288
if (hasClass(relatedDoc, "docblock") || hasClass(relatedDoc, "sub-variant")) {
@@ -2332,16 +2332,17 @@ function defocusSearchBar() {
23322332
var dontApplyBlockRule = toggle.parentNode.parentNode.id !== "main";
23332333
if (action === "show") {
23342334
removeClass(relatedDoc, "fns-now-collapsed");
2335-
// Stability information is never hidden.
2336-
if (hasClass(docblock, "stability") === false) {
2335+
// Stability/deprecation/portability information is never hidden.
2336+
if (hasClass(docblock, "item-info") === false) {
23372337
removeClass(docblock, "hidden-by-usual-hider");
23382338
}
23392339
onEachLazy(toggle.childNodes, adjustToggle(false, dontApplyBlockRule));
23402340
onEachLazy(relatedDoc.childNodes, implHider(false, dontApplyBlockRule));
23412341
} else if (action === "hide") {
23422342
addClass(relatedDoc, "fns-now-collapsed");
2343-
// Stability information should be shown even when detailed info is hidden.
2344-
if (hasClass(docblock, "stability") === false) {
2343+
// Stability/deprecation/portability information should be shown even when detailed
2344+
// info is hidden.
2345+
if (hasClass(docblock, "item-info") === false) {
23452346
addClass(docblock, "hidden-by-usual-hider");
23462347
}
23472348
onEachLazy(toggle.childNodes, adjustToggle(true, dontApplyBlockRule));
@@ -2445,7 +2446,7 @@ function defocusSearchBar() {
24452446

24462447
var func = function(e) {
24472448
var next = e.nextElementSibling;
2448-
if (next && hasClass(next, "stability")) {
2449+
if (next && hasClass(next, "item-info")) {
24492450
next = next.nextElementSibling;
24502451
}
24512452
if (!next) {
@@ -2462,7 +2463,7 @@ function defocusSearchBar() {
24622463

24632464
var funcImpl = function(e) {
24642465
var next = e.nextElementSibling;
2465-
if (next && hasClass(next, "stability")) {
2466+
if (next && hasClass(next, "item-info")) {
24662467
next = next.nextElementSibling;
24672468
}
24682469
if (next && hasClass(next, "docblock")) {

Diff for: src/librustdoc/html/static/rustdoc.css

+9-9
Original file line numberDiff line numberDiff line change
@@ -553,21 +553,21 @@ h4 > code, h3 > code, .invisible > code {
553553
border: none;
554554
}
555555

556-
.content .stability code {
556+
.content .item-info code {
557557
font-size: 90%;
558558
}
559559

560-
.content .stability {
560+
.content .item-info {
561561
position: relative;
562562
margin-left: 33px;
563563
margin-top: -13px;
564564
}
565565

566-
.sub-variant > div > .stability {
566+
.sub-variant > div > .item-info {
567567
margin-top: initial;
568568
}
569569

570-
.content .stability::before {
570+
.content .item-info::before {
571571
content: '⬑';
572572
font-size: 25px;
573573
position: absolute;
@@ -579,23 +579,23 @@ h4 > code, h3 > code, .invisible > code {
579579
margin-left: 20px;
580580
}
581581

582-
.content .impl-items .docblock, .content .impl-items .stability {
582+
.content .impl-items .docblock, .content .impl-items .item-info {
583583
margin-bottom: .6em;
584584
}
585585

586-
.content .impl-items > .stability {
586+
.content .impl-items > .item-info {
587587
margin-left: 40px;
588588
}
589589

590-
.methods > .stability, .content .impl-items > .stability {
590+
.methods > .item-info, .content .impl-items > .item-info {
591591
margin-top: -8px;
592592
}
593593

594594
.impl-items {
595595
flex-basis: 100%;
596596
}
597597

598-
#main > .stability {
598+
#main > .item-info {
599599
margin-top: 0;
600600
}
601601

@@ -655,7 +655,7 @@ a {
655655
}
656656

657657
.docblock a:not(.srclink):not(.test-arrow):hover,
658-
.docblock-short a:not(.srclink):not(.test-arrow):hover, .stability a {
658+
.docblock-short a:not(.srclink):not(.test-arrow):hover, .item-info a {
659659
text-decoration: underline;
660660
}
661661

Diff for: src/librustdoc/html/static/themes/ayu.css

+2-2
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ pre {
166166
color: #c5c5c5;
167167
}
168168

169-
.content .stability::before { color: #ccc; }
169+
.content .item-info::before { color: #ccc; }
170170

171171
.content span.foreigntype, .content a.foreigntype { color: #ef57ff; }
172172
.content span.union, .content a.union { color: #98a01c; }
@@ -219,7 +219,7 @@ a {
219219
}
220220

221221
.docblock:not(.type-decl) a:not(.srclink):not(.test-arrow),
222-
.docblock-short a:not(.srclink):not(.test-arrow), .stability a,
222+
.docblock-short a:not(.srclink):not(.test-arrow), .item-info a,
223223
#help a {
224224
color: #39AFD7;
225225
}

Diff for: src/librustdoc/html/static/themes/dark.css

+2-2
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ pre {
136136
.content .highlighted.primitive { background-color: #00708a; }
137137
.content .highlighted.keyword { background-color: #884719; }
138138

139-
.content .stability::before { color: #ccc; }
139+
.content .item-info::before { color: #ccc; }
140140

141141
.content span.enum, .content a.enum, .block a.current.enum { color: #82b089; }
142142
.content span.struct, .content a.struct, .block a.current.struct { color: #2dbfb8; }
@@ -177,7 +177,7 @@ a {
177177
}
178178

179179
.docblock:not(.type-decl) a:not(.srclink):not(.test-arrow),
180-
.docblock-short a:not(.srclink):not(.test-arrow), .stability a,
180+
.docblock-short a:not(.srclink):not(.test-arrow), .item-info a,
181181
#help a {
182182
color: #D2991D;
183183
}

Diff for: src/librustdoc/html/static/themes/light.css

+2-2
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ pre {
134134
.content .highlighted.primitive { background-color: #9aecff; }
135135
.content .highlighted.keyword { background-color: #f99650; }
136136

137-
.content .stability::before { color: #ccc; }
137+
.content .item-info::before { color: #ccc; }
138138

139139
.content span.enum, .content a.enum, .block a.current.enum { color: #508157; }
140140
.content span.struct, .content a.struct, .block a.current.struct { color: #ad448e; }
@@ -175,7 +175,7 @@ a {
175175
}
176176

177177
.docblock:not(.type-decl) a:not(.srclink):not(.test-arrow),
178-
.docblock-short a:not(.srclink):not(.test-arrow), .stability a,
178+
.docblock-short a:not(.srclink):not(.test-arrow), .item-info a,
179179
#help a {
180180
color: #3873AD;
181181
}

Diff for: src/test/rustdoc/doc-cfg.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,28 @@
22
#![feature(target_feature, cfg_target_feature)]
33

44
// @has doc_cfg/struct.Portable.html
5-
// @!has - '//*[@id="main"]/*[@class="stability"]/*[@class="stab portability"]' ''
5+
// @!has - '//*[@id="main"]/*[@class="item-info"]/*[@class="stab portability"]' ''
66
// @has - '//*[@id="method.unix_and_arm_only_function"]' 'fn unix_and_arm_only_function()'
77
// @has - '//*[@class="stab portability"]' 'This is supported on Unix and ARM only.'
88
pub struct Portable;
99

1010
// @has doc_cfg/unix_only/index.html \
11-
// '//*[@id="main"]/*[@class="stability"]/*[@class="stab portability"]' \
11+
// '//*[@id="main"]/*[@class="item-info"]/*[@class="stab portability"]' \
1212
// 'This is supported on Unix only.'
1313
// @matches - '//*[@class="module-item"]//*[@class="stab portability"]' '\AARM\Z'
1414
// @count - '//*[@class="stab portability"]' 2
1515
#[doc(cfg(unix))]
1616
pub mod unix_only {
1717
// @has doc_cfg/unix_only/fn.unix_only_function.html \
18-
// '//*[@id="main"]/*[@class="stability"]/*[@class="stab portability"]' \
18+
// '//*[@id="main"]/*[@class="item-info"]/*[@class="stab portability"]' \
1919
// 'This is supported on Unix only.'
2020
// @count - '//*[@class="stab portability"]' 1
2121
pub fn unix_only_function() {
2222
content::should::be::irrelevant();
2323
}
2424

2525
// @has doc_cfg/unix_only/trait.ArmOnly.html \
26-
// '//*[@id="main"]/*[@class="stability"]/*[@class="stab portability"]' \
26+
// '//*[@id="main"]/*[@class="item-info"]/*[@class="stab portability"]' \
2727
// 'This is supported on Unix and ARM only.'
2828
// @count - '//*[@class="stab portability"]' 2
2929
#[doc(cfg(target_arch = "arm"))]
@@ -44,15 +44,15 @@ pub mod unix_only {
4444
// @matches - '//*[@class="module-item"]//*[@class="stab portability"]' '\Aavx\Z'
4545

4646
// @has doc_cfg/fn.uses_target_feature.html
47-
// @has - '//*[@id="main"]/*[@class="stability"]/*[@class="stab portability"]' \
47+
// @has - '//*[@id="main"]/*[@class="item-info"]/*[@class="stab portability"]' \
4848
// 'This is supported with target feature avx only.'
4949
#[target_feature(enable = "avx")]
5050
pub unsafe fn uses_target_feature() {
5151
content::should::be::irrelevant();
5252
}
5353

5454
// @has doc_cfg/fn.uses_cfg_target_feature.html
55-
// @has - '//*[@id="main"]/*[@class="stability"]/*[@class="stab portability"]' \
55+
// @has - '//*[@id="main"]/*[@class="item-info"]/*[@class="stab portability"]' \
5656
// 'This is supported with target feature avx only.'
5757
#[doc(cfg(target_feature = "avx"))]
5858
pub fn uses_cfg_target_feature() {

Diff for: src/test/rustdoc/stability.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
pub struct Unstable {
66
// @has stability/struct.Unstable.html \
7-
// '//div[@class="stability"]//div[@class="stab unstable"]' \
7+
// '//div[@class="item-info"]//div[@class="stab unstable"]' \
88
// 'This is a nightly-only experimental API'
99
// @count stability/struct.Unstable.html '//span[@class="stab unstable"]' 0
1010
pub foo: u32,

0 commit comments

Comments
 (0)