rustdoc: hardcode each header as a link.
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.
This commit is contained in:
parent
f22c96cc88
commit
7a70ec1ba6
4 changed files with 17 additions and 14 deletions
|
@ -209,7 +209,8 @@ pub fn render(w: &mut io::Writer, s: &str, print_toc: bool) -> fmt::Result {
|
||||||
};
|
};
|
||||||
|
|
||||||
// Render the HTML
|
// Render the HTML
|
||||||
let text = format!(r#"<h{lvl} id="{id}">{sec_len,plural,=0{}other{{sec} }}{}</h{lvl}>"#,
|
let text = format!(r#"<h{lvl} id="{id}"><a
|
||||||
|
href="\#{id}">{sec_len,plural,=0{}other{{sec} }}{}</a></h{lvl}>"#,
|
||||||
s, lvl = level, id = id,
|
s, lvl = level, id = id,
|
||||||
sec_len = sec.len(), sec = sec);
|
sec_len = sec.len(), sec = sec);
|
||||||
|
|
||||||
|
|
|
@ -1064,7 +1064,8 @@ fn item_module(w: &mut Writer, cx: &Context,
|
||||||
clean::ForeignStaticItem(..) => ("ffi-statics", "Foreign Statics"),
|
clean::ForeignStaticItem(..) => ("ffi-statics", "Foreign Statics"),
|
||||||
clean::MacroItem(..) => ("macros", "Macros"),
|
clean::MacroItem(..) => ("macros", "Macros"),
|
||||||
};
|
};
|
||||||
try!(write!(w, "<h2 id='{}'>{}</h2>\n<table>", short, name));
|
try!(write!(w, "<h2 id='{id}'><a href=\"\\#{id}\">{name}</a></h2>\n<table>",
|
||||||
|
id = short, name = name));
|
||||||
}
|
}
|
||||||
|
|
||||||
match myitem.inner {
|
match myitem.inner {
|
||||||
|
|
|
@ -320,9 +320,16 @@ pre.rust .string { color: #718C00; }
|
||||||
pre.rust .lifetime { color: #C13928; }
|
pre.rust .lifetime { color: #C13928; }
|
||||||
pre.rust .attribute, pre.rust .attribute .ident { color: #C82829; }
|
pre.rust .attribute, pre.rust .attribute .ident { color: #C82829; }
|
||||||
|
|
||||||
h1 a.anchor,
|
h1:hover a:after,
|
||||||
h2 a.anchor,
|
h2:hover a:after,
|
||||||
h3 a.anchor { display: none; }
|
h3:hover a:after,
|
||||||
h1:hover a.anchor,
|
h4:hover a:after,
|
||||||
h2:hover a.anchor,
|
h5:hover a:after,
|
||||||
h3:hover a.anchor { display: inline-block; }
|
h6:hover a:after {
|
||||||
|
content: ' § ';
|
||||||
|
}
|
||||||
|
|
||||||
|
h1.fqn:hover a:after,
|
||||||
|
:hover a.fnname:after {
|
||||||
|
content: none;
|
||||||
|
}
|
||||||
|
|
|
@ -600,10 +600,4 @@
|
||||||
|
|
||||||
initSearch(searchIndex);
|
initSearch(searchIndex);
|
||||||
|
|
||||||
$.each($('h1, h2, h3'), function(idx, element) {
|
|
||||||
if ($(element).attr('id') != undefined) {
|
|
||||||
$(element).append('<a href="#' + $(element).attr('id') + '" ' +
|
|
||||||
'class="anchor"> § </a>');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}());
|
}());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue