From 7a70ec1ba6e64949cab5edcad33b0d7538065884 Mon Sep 17 00:00:00 2001 From: Huon Wilson Date: Sat, 8 Mar 2014 01:24:54 +1100 Subject: [PATCH] rustdoc: hardcode each header as a link. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This avoids having to include JS in the guide/tutorial/manual pages just to get the headers being links. The on-hover behaviour showing the little section marker § is preserved, because that gives a useful hint that the heading is a link. --- src/librustdoc/html/markdown.rs | 3 ++- src/librustdoc/html/render.rs | 3 ++- src/librustdoc/html/static/main.css | 19 +++++++++++++------ src/librustdoc/html/static/main.js | 6 ------ 4 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/librustdoc/html/markdown.rs b/src/librustdoc/html/markdown.rs index 8f7829dda9d..61c1cd734a3 100644 --- a/src/librustdoc/html/markdown.rs +++ b/src/librustdoc/html/markdown.rs @@ -209,7 +209,8 @@ pub fn render(w: &mut io::Writer, s: &str, print_toc: bool) -> fmt::Result { }; // Render the HTML - let text = format!(r#"{sec_len,plural,=0{}other{{sec} }}{}"#, + let text = format!(r#"{sec_len,plural,=0{}other{{sec} }}{}"#, s, lvl = level, id = id, sec_len = sec.len(), sec = sec); diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index e985de4d2f5..b705e976e46 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -1064,7 +1064,8 @@ fn cmp(i1: &clean::Item, i2: &clean::Item, idx1: uint, idx2: uint) -> Ordering { clean::ForeignStaticItem(..) => ("ffi-statics", "Foreign Statics"), clean::MacroItem(..) => ("macros", "Macros"), }; - try!(write!(w, "

{}

\n", short, name)); + try!(write!(w, "

{name}

\n
", + id = short, name = name)); } match myitem.inner { diff --git a/src/librustdoc/html/static/main.css b/src/librustdoc/html/static/main.css index 9a5cdaba33c..0efee51a219 100644 --- a/src/librustdoc/html/static/main.css +++ b/src/librustdoc/html/static/main.css @@ -320,9 +320,16 @@ pre.rust .string { color: #718C00; } pre.rust .lifetime { color: #C13928; } pre.rust .attribute, pre.rust .attribute .ident { color: #C82829; } -h1 a.anchor, -h2 a.anchor, -h3 a.anchor { display: none; } -h1:hover a.anchor, -h2:hover a.anchor, -h3:hover a.anchor { display: inline-block; } +h1:hover a:after, +h2:hover a:after, +h3:hover a:after, +h4:hover a:after, +h5:hover a:after, +h6:hover a:after { + content: ' § '; +} + +h1.fqn:hover a:after, +:hover a.fnname:after { + content: none; +} diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js index 59970ac4508..3056bca68d7 100644 --- a/src/librustdoc/html/static/main.js +++ b/src/librustdoc/html/static/main.js @@ -600,10 +600,4 @@ initSearch(searchIndex); - $.each($('h1, h2, h3'), function(idx, element) { - if ($(element).attr('id') != undefined) { - $(element).append(' § '); - } - }); }());