Skip to content

Commit 3f6ce8e

Browse files
authored
Rollup merge of rust-lang#43747 - GuillaumeGomez:fix-css, r=QuietMisdreavus
Improve headers linking r? @QuietMisdreavus
2 parents 3dabf4f + 8ac4336 commit 3f6ce8e

File tree

2 files changed

+32
-22
lines changed

2 files changed

+32
-22
lines changed

src/librustdoc/html/render.rs

+22-22
Original file line numberDiff line numberDiff line change
@@ -2141,8 +2141,8 @@ fn item_trait(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
21412141

21422142
if !types.is_empty() {
21432143
write!(w, "
2144-
<h2 id='associated-types' class='section-header'>
2145-
<a href='#associated-types'>Associated Types</a>
2144+
<h2 id='associated-types' class='small-section-header'>
2145+
Associated Types<a href='#associated-types' class='anchor'></a>
21462146
</h2>
21472147
<div class='methods'>
21482148
")?;
@@ -2154,8 +2154,8 @@ fn item_trait(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
21542154

21552155
if !consts.is_empty() {
21562156
write!(w, "
2157-
<h2 id='associated-const' class='section-header'>
2158-
<a href='#associated-const'>Associated Constants</a>
2157+
<h2 id='associated-const' class='small-section-header'>
2158+
Associated Constants<a href='#associated-const' class='anchor'></a>
21592159
</h2>
21602160
<div class='methods'>
21612161
")?;
@@ -2168,8 +2168,8 @@ fn item_trait(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
21682168
// Output the documentation for each function individually
21692169
if !required.is_empty() {
21702170
write!(w, "
2171-
<h2 id='required-methods' class='section-header'>
2172-
<a href='#required-methods'>Required Methods</a>
2171+
<h2 id='required-methods' class='small-section-header'>
2172+
Required Methods<a href='#required-methods' class='anchor'></a>
21732173
</h2>
21742174
<div class='methods'>
21752175
")?;
@@ -2180,8 +2180,8 @@ fn item_trait(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
21802180
}
21812181
if !provided.is_empty() {
21822182
write!(w, "
2183-
<h2 id='provided-methods' class='section-header'>
2184-
<a href='#provided-methods'>Provided Methods</a>
2183+
<h2 id='provided-methods' class='small-section-header'>
2184+
Provided Methods<a href='#provided-methods' class='anchor'></a>
21852185
</h2>
21862186
<div class='methods'>
21872187
")?;
@@ -2196,8 +2196,8 @@ fn item_trait(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
21962196

21972197
let cache = cache();
21982198
write!(w, "
2199-
<h2 id='implementors' class='section-header'>
2200-
<a href='#implementors'>Implementors</a>
2199+
<h2 id='implementors' class='small-section-header'>
2200+
Implementors<a href='#implementors' class='anchor'></a>
22012201
</h2>
22022202
<ul class='item-list' id='implementors-list'>
22032203
")?;
@@ -2436,8 +2436,8 @@ fn item_struct(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
24362436
}).peekable();
24372437
if let doctree::Plain = s.struct_type {
24382438
if fields.peek().is_some() {
2439-
write!(w, "<h2 id='fields' class='fields section-header'>
2440-
<a href='#fields'>Fields</a></h2>")?;
2439+
write!(w, "<h2 id='fields' class='fields small-section-header'>
2440+
Fields<a href='#fields' class='anchor'></a></h2>")?;
24412441
for (field, ty) in fields {
24422442
let id = derive_id(format!("{}.{}",
24432443
ItemType::StructField,
@@ -2485,8 +2485,8 @@ fn item_union(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
24852485
}
24862486
}).peekable();
24872487
if fields.peek().is_some() {
2488-
write!(w, "<h2 id='fields' class='fields section-header'>
2489-
<a href='#fields'>Fields</a></h2>")?;
2488+
write!(w, "<h2 id='fields' class='fields small-section-header'>
2489+
Fields<a href='#fields' class='anchor'></a></h2>")?;
24902490
for (field, ty) in fields {
24912491
write!(w, "<span id='{shortty}.{name}' class=\"{shortty}\"><code>{name}: {ty}</code>
24922492
</span>",
@@ -2558,8 +2558,8 @@ fn item_enum(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
25582558

25592559
document(w, cx, it)?;
25602560
if !e.variants.is_empty() {
2561-
write!(w, "<h2 id='variants' class='variants section-header'>
2562-
<a href='#variants'>Variants</a></h2>\n")?;
2561+
write!(w, "<h2 id='variants' class='variants small-section-header'>
2562+
Variants<a href='#variants' class='anchor'></a></h2>\n")?;
25632563
for variant in &e.variants {
25642564
let id = derive_id(format!("{}.{}",
25652565
ItemType::Variant,
@@ -2831,16 +2831,16 @@ fn render_assoc_items(w: &mut fmt::Formatter,
28312831
let render_mode = match what {
28322832
AssocItemRender::All => {
28332833
write!(w, "
2834-
<h2 id='methods' class='section-header'>
2835-
<a href='#methods'>Methods</a>
2834+
<h2 id='methods' class='small-section-header'>
2835+
Methods<a href='#methods' class='anchor'></a>
28362836
</h2>
28372837
")?;
28382838
RenderMode::Normal
28392839
}
28402840
AssocItemRender::DerefFor { trait_, type_, deref_mut_ } => {
28412841
write!(w, "
2842-
<h2 id='deref-methods' class='section-header'>
2843-
<a href='#deref-methods'>Methods from {}&lt;Target = {}&gt;</a>
2842+
<h2 id='deref-methods' class='small-section-header'>
2843+
Methods from {}&lt;Target = {}&gt;<a href='#deref-methods' class='anchor'></a>
28442844
</h2>
28452845
", trait_, type_)?;
28462846
RenderMode::ForDeref { mut_: deref_mut_ }
@@ -2865,8 +2865,8 @@ fn render_assoc_items(w: &mut fmt::Formatter,
28652865
render_deref_methods(w, cx, impl_, containing_item, has_deref_mut)?;
28662866
}
28672867
write!(w, "
2868-
<h2 id='implementations' class='section-header'>
2869-
<a href='#implementations'>Trait Implementations</a>
2868+
<h2 id='implementations' class='small-section-header'>
2869+
Trait Implementations<a href='#implementations' class='anchor'></a>
28702870
</h2>
28712871
")?;
28722872
for i in &traits {

src/librustdoc/html/static/rustdoc.css

+10
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,16 @@ a {
438438
background: transparent;
439439
}
440440

441+
.small-section-header:hover > .anchor {
442+
display: initial;
443+
}
444+
.anchor {
445+
display: none;
446+
}
447+
.anchor:after {
448+
content: '\2002\00a7\2002';
449+
}
450+
441451
.docblock a:hover, .docblock-short a:hover, .stability a {
442452
text-decoration: underline;
443453
}

0 commit comments

Comments
 (0)