Skip to content

Commit 88805e1

Browse files
committed
auto merge of #13485 : adrientetar/rust/newrustdoc, r=brson
- Cherry-pick from #12996 - Use Fira Sans for headlines and sidebar (Light), Heuristica for the body (Adobe Utopia derivative). Both are licensed under the SIL OFL license. - A few tweaks Two examples: [modified `std`](http://adrientetar.legtux.org/cached/rust-docs/std.htm) and [modified `std::io`](http://adrientetar.legtux.org/cached/rust-docs/io.htm). cc #13484 **Blocked on rust-lang/prev.rust-lang.org#25 (for hosting of the fonts), that's showcased [here](http://adrientetar.github.io/rust-www/).** cc @brson, @thehydroimpulse
2 parents ccccbd2 + 84bf922 commit 88805e1

File tree

3 files changed

+164
-84
lines changed

3 files changed

+164
-84
lines changed

src/librustdoc/html/layout.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,12 @@ r##"<!DOCTYPE html>
3333
<html lang="en">
3434
<head>
3535
<meta charset="utf-8" />
36+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
37+
<meta name="description" content="The {krate} library documentation.">
38+
3639
<title>{title}</title>
3740
38-
<link href='http://fonts.googleapis.com/css?family=Oswald:700|Inconsolata:400,700'
41+
<link href='http://fonts.googleapis.com/css?family=Inconsolata:400,700'
3942
rel='stylesheet' type='text/css'>
4043
<link rel="stylesheet" type="text/css" href="{root_path}main.css">
4144
@@ -51,15 +54,14 @@ r##"<!DOCTYPE html>
5154
5255
<section class="sidebar">
5356
{logo, select, none{} other{
54-
<a href='{root_path}{krate}/index.html'><img src='#' alt=''/></a>
57+
<a href='{root_path}{krate}/index.html'><img src='#' alt='' width='100px' /></a>
5558
}}
5659
5760
{sidebar}
5861
</section>
5962
6063
<nav class="sub">
6164
<form class="search-form js-only">
62-
<button class="do-search">Search</button>
6365
<div class="search-container">
6466
<input class="search-input" name="search"
6567
autocomplete="off"

src/librustdoc/html/render.rs

+23-22
Original file line numberDiff line numberDiff line change
@@ -938,28 +938,8 @@ impl<'a> fmt::Show for Item<'a> {
938938
None => {}
939939
}
940940

941-
if self.cx.include_sources {
942-
let mut path = Vec::new();
943-
clean_srcpath(self.item.source.filename.as_bytes(), |component| {
944-
path.push(component.to_owned());
945-
});
946-
let href = if self.item.source.loline == self.item.source.hiline {
947-
format!("{}", self.item.source.loline)
948-
} else {
949-
format!("{}-{}", self.item.source.loline, self.item.source.hiline)
950-
};
951-
try!(write!(fmt.buf,
952-
"<a class='source'
953-
href='{root}src/{krate}/{path}.html\\#{href}'>\
954-
[src]</a>",
955-
root = self.cx.root_path,
956-
krate = self.cx.layout.krate,
957-
path = path.connect("/"),
958-
href = href));
959-
}
960-
961941
// Write the breadcrumb trail header for the top
962-
try!(write!(fmt.buf, "<h1 class='fqn'>"));
942+
try!(write!(fmt.buf, "\n<h1 class='fqn'>"));
963943
match self.item.inner {
964944
clean::ModuleItem(ref m) => if m.is_crate {
965945
try!(write!(fmt.buf, "Crate "));
@@ -982,9 +962,30 @@ impl<'a> fmt::Show for Item<'a> {
982962
try!(write!(fmt.buf, "<a href='{}index.html'>{}</a>::",
983963
trail, component.as_slice()));
984964
}
985-
try!(write!(fmt.buf, "<a class='{}' href=''>{}</a></h1>",
965+
try!(write!(fmt.buf, "<a class='{}' href=''>{}</a>",
986966
shortty(self.item), self.item.name.get_ref().as_slice()));
987967

968+
if self.cx.include_sources {
969+
let mut path = Vec::new();
970+
clean_srcpath(self.item.source.filename.as_bytes(), |component| {
971+
path.push(component.to_owned());
972+
});
973+
let href = if self.item.source.loline == self.item.source.hiline {
974+
format!("{}", self.item.source.loline)
975+
} else {
976+
format!("{}-{}", self.item.source.loline, self.item.source.hiline)
977+
};
978+
try!(write!(fmt.buf,
979+
"<a class='source'\
980+
href='{root}src/{krate}/{path}.html\\#{href}'>\
981+
[src]</a>",
982+
root = self.cx.root_path,
983+
krate = self.cx.layout.krate,
984+
path = path.connect("/"),
985+
href = href));
986+
}
987+
try!(write!(fmt.buf, "</h1>\n"));
988+
988989
match self.item.inner {
989990
clean::ModuleItem(ref m) => {
990991
item_module(fmt.buf, self.cx, self.item, m.items.as_slice())

0 commit comments

Comments
 (0)