Skip to content

Commit 9698e8f

Browse files
committed
rustdoc: Print feature flag and issue link if present in short_stability
1 parent b310387 commit 9698e8f

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

src/librustdoc/html/render.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1709,7 +1709,22 @@ fn short_stability(item: &clean::Item, cx: &Context, show_reason: bool) -> Optio
17091709
};
17101710
format!("Deprecated{}{}", since, Markdown(&reason))
17111711
} else if stab.level == attr::Unstable {
1712-
format!("Unstable{}", Markdown(&reason))
1712+
let unstable_extra = if show_reason {
1713+
match (!stab.feature.is_empty(), &cx.issue_tracker_base_url, stab.issue) {
1714+
(true, &Some(ref tracker_url), Some(issue_no)) =>
1715+
format!(" (<code>{}</code> <a href=\"{}{}\">#{}</a>)", Escape(&stab.feature),
1716+
tracker_url, issue_no, issue_no),
1717+
(false, &Some(ref tracker_url), Some(issue_no)) =>
1718+
format!(" (<a href=\"{}{}\">#{}</a>)", Escape(&tracker_url), issue_no,
1719+
issue_no),
1720+
(true, _, _) =>
1721+
format!(" (<code>{}</code>)", Escape(&stab.feature)),
1722+
_ => String::new(),
1723+
}
1724+
} else {
1725+
String::new()
1726+
};
1727+
format!("Unstable{}{}", unstable_extra, Markdown(&reason))
17131728
} else {
17141729
return None
17151730
};

src/librustdoc/html/static/main.css

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ code, pre {
123123
font-family: "Source Code Pro", Menlo, Monaco, Consolas, "DejaVu Sans Mono", Inconsolata, monospace;
124124
white-space: pre-wrap;
125125
}
126-
.docblock code {
126+
.docblock code, .stability code {
127127
background-color: #F5F5F5;
128128
border-radius: 3px;
129129
padding: 0 0.2em;
@@ -387,11 +387,11 @@ a {
387387
background: transparent;
388388
}
389389

390-
.docblock a {
390+
.docblock a, .stability a {
391391
color: #4e8bca;
392392
}
393393

394-
.docblock a:hover {
394+
.docblock a:hover, .stability a {
395395
text-decoration: underline;
396396
}
397397

0 commit comments

Comments
 (0)