Skip to content

Commit e1e4816

Browse files
huonwalexcrichton
authored andcommitted
rustdoc: whitelist the headers that get a § on hover.
Previously the :hover rules were making the links to the traits/types in something like impl<K: Hash + Eq, V> ... { ... } be displayed with a trailing `§` when hovered over. This commit restricts that behaviour to specific headers, i.e. those that are known to be section headers (like those rendered in markdown doc-comments, and the "Modules", "Functions" etc. headings).
1 parent 0bfb61e commit e1e4816

File tree

3 files changed

+10
-13
lines changed

3 files changed

+10
-13
lines changed

src/librustdoc/html/markdown.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ pub fn render(w: &mut io::Writer, s: &str, print_toc: bool) -> fmt::Result {
209209
};
210210

211211
// Render the HTML
212-
let text = format!(r#"<h{lvl} id="{id}"><a
212+
let text = format!(r#"<h{lvl} id="{id}" class='section-link'><a
213213
href="\#{id}">{sec_len,plural,=0{}other{{sec} }}{}</a></h{lvl}>"#,
214214
s, lvl = level, id = id,
215215
sec_len = sec.len(), sec = sec);

src/librustdoc/html/render.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1064,7 +1064,9 @@ fn item_module(w: &mut Writer, cx: &Context,
10641064
clean::ForeignStaticItem(..) => ("ffi-statics", "Foreign Statics"),
10651065
clean::MacroItem(..) => ("macros", "Macros"),
10661066
};
1067-
try!(write!(w, "<h2 id='{id}'><a href=\"\\#{id}\">{name}</a></h2>\n<table>",
1067+
try!(write!(w,
1068+
"<h2 id='{id}' class='section-link'>\
1069+
<a href=\"\\#{id}\">{name}</a></h2>\n<table>",
10681070
id = short, name = name));
10691071
}
10701072

src/librustdoc/html/static/main.css

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -317,16 +317,11 @@ pre.rust .doccomment { color: #4D4D4C; }
317317
pre.rust .macro, pre.rust .macro-nonterminal { color: #3E999F; }
318318
pre.rust .lifetime { color: #B76514; }
319319

320-
h1:hover a:after,
321-
h2:hover a:after,
322-
h3:hover a:after,
323-
h4:hover a:after,
324-
h5:hover a:after,
325-
h6:hover a:after {
320+
h1.section-link:hover a:after,
321+
h2.section-link:hover a:after,
322+
h3.section-link:hover a:after,
323+
h4.section-link:hover a:after,
324+
h5.section-link:hover a:after,
325+
h6.section-link:hover a:after {
326326
content: ' § ';
327327
}
328-
329-
h1.fqn:hover a:after,
330-
:hover a.fnname:after {
331-
content: none;
332-
}

0 commit comments

Comments
 (0)