Skip to content

Commit 84bf922

Browse files
committed
rustdoc: add webfonts and tweak the styles accordingly
1 parent ea344fd commit 84bf922

File tree

2 files changed

+82
-44
lines changed

2 files changed

+82
-44
lines changed

src/librustdoc/html/render.rs

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -934,28 +934,8 @@ impl<'a> fmt::Show for Item<'a> {
934934
None => {}
935935
}
936936

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

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

src/librustdoc/html/static/main.css

Lines changed: 59 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,37 @@
99
* option. This file may not be copied, modified, or distributed
1010
* except according to those terms.
1111
*/
12+
@font-face {
13+
font-family: 'Fira Sans';
14+
font-style: normal;
15+
font-weight: 400;
16+
src: local('Fira Sans'), url("http://rust-lang.org/fonts/FiraSans-Regular.woff") format('woff');
17+
}
18+
@font-face {
19+
font-family: 'Fira Sans';
20+
font-style: normal;
21+
font-weight: 500;
22+
src: local('Fira Sans Medium'), url("http://rust-lang.org/fonts/FiraSans-Medium.woff") format('woff');
23+
}
24+
@font-face {
25+
font-family: 'Heuristica';
26+
font-style: normal;
27+
font-weight: 400;
28+
src: local('Heuristica Regular'), url("http://rust-lang.org/fonts/Heuristica-Regular.woff") format('woff');
29+
}
30+
@font-face {
31+
font-family: 'Heuristica';
32+
font-style: italic;
33+
font-weight: 400;
34+
src: local('Heuristica Italic'), url("http://rust-lang.org/fonts/Heuristica-Italic.woff") format('woff');
35+
}
36+
@font-face {
37+
font-family: 'Heuristica';
38+
font-style: normal;
39+
font-weight: 700;
40+
src: local('Heuristica Bold'), url("http://rust-lang.org/fonts/Heuristica-Bold.woff") format('woff');
41+
}
42+
1243
@import "normalize.css";
1344

1445
* {
@@ -21,13 +52,12 @@
2152

2253
body {
2354
color: #333;
24-
min-height: 100%;
2555
min-width: 500px;
26-
height: 100%;
27-
font: 15px "Helvetica Neue", Helvetica, Arial, sans-serif;
28-
line-height: 150%;
56+
font: 18px "Heuristica", "Helvetica Neue", Helvetica, Arial, sans-serif;
57+
line-height: 1.4;
58+
margin: 0;
2959
position: relative;
30-
height: auto;
60+
padding: 10px 15px 20px 15px;
3161
padding-bottom: 20px;
3262
}
3363

@@ -44,13 +74,23 @@ h1.fqn {
4474
h2, h3, h4 {
4575
border-bottom: 1px solid #DDDDDD;
4676
}
47-
h2 code, h3 code, h4 code {
48-
77+
h2 code, h3 code, h4 code, .block a {
4978
font-size: 1.2em;
5079
}
80+
h1, h2, h3, h4, section.sidebar, a.source, .content a, .search-input {
81+
font-family: "Fira Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
82+
}
83+
84+
ul {
85+
padding-left: 25px;
86+
}
87+
88+
p {
89+
margin: 0 0 1em 0;
90+
}
5191

5292
code, pre {
53-
font-family: "Inconsolata", Menlo, Monaco, Consolas, "DejaVu Sans Mono", monospace;
93+
font-family: Menlo, Monaco, Consolas, Inconsolata, "DejaVu Sans Mono", monospace;
5494
}
5595
pre {
5696
font-size: 15px;
@@ -92,8 +132,6 @@ nav.sub {
92132
color: #333;
93133
}
94134

95-
.sidebar .block, pre { background: #fff; }
96-
97135
.block {
98136
padding: 10px;
99137
margin-bottom: 10px;
@@ -111,11 +149,12 @@ nav.sub {
111149
padding-left: 5px;
112150
padding-bottom: 6px;
113151
font-size: 14px;
152+
font-weight: 300;
114153
transition: border 500ms ease-out;
115154
}
116155

117156
.content {
118-
padding: 20px 40px;
157+
padding: 20px 0;
119158
}
120159

121160
.content pre { padding: 20px; }
@@ -165,10 +204,9 @@ nav.sub {
165204
.docblock h2 { font-size: 1.15em; }
166205
.docblock h3, .docblock h4, .docblock h5 { font-size: 1em; }
167206

168-
.content .source {
207+
.content .source {
169208
float: right;
170-
font-weight: 500;
171-
padding: 9px 15px;
209+
font-size: 23px;
172210
}
173211

174212
.content table {
@@ -224,7 +262,7 @@ nav.sum { text-align: right; }
224262
nav.sub form { display: inline; }
225263

226264
nav, .content {
227-
margin-left: 220px;
265+
margin-left: 230px;
228266
}
229267

230268
a {
@@ -254,18 +292,18 @@ a {
254292
margin-top: 5px;
255293
padding: 10px 16px;
256294
font-size: 17px;
257-
font-weight: 300;
258295
box-shadow: 0 0 0 1px #e0e0e0, 0 0 0 2px transparent;
259-
transition: background-color 50ms linear;
260-
transition: border 500ms ease-out;
261-
transition: box-shadow 500ms ease-out;
296+
transition: border-color 300ms ease;
297+
transition: border-radius 300ms ease-in-out;
298+
transition: box-shadow 300ms ease-in-out;
262299
}
263300

264301
.search-input:focus {
265302
border-color: #66afe9;
303+
border-radius: 2px;
266304
border: 0;
267305
outline: 0;
268-
box-shadow: 0 0 0 1px #078dd8, 0 0 0 2px #078dd8;
306+
box-shadow: 0 0 8px #078dd8;
269307
}
270308

271309
.search-results .desc {
@@ -327,7 +365,7 @@ a {
327365

328366
:target { background: #FDFFD3; }
329367

330-
pre.rust, pre.line-numbers { background-color: #FDFDFD; }
368+
pre.rust, pre.line-numbers { background-color: #F5F5F5; }
331369

332370
/* Code highlighting */
333371
pre.rust .kw { color: #8959A8; }
@@ -361,7 +399,6 @@ h6.section-link:hover a:after {
361399
}
362400

363401
nav.sub {
364-
width: 85.5%;
365402
margin: 0 auto;
366403
}
367404
}

0 commit comments

Comments
 (0)