Skip to content

Commit b3577a1

Browse files
committed
rustdoc: bring it inline
1 parent c9d995d commit b3577a1

File tree

3 files changed

+30
-36
lines changed

3 files changed

+30
-36
lines changed

src/doc/rust.css

+4-17
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
src: local('Heuristica Bold'), url("Heuristica-Bold.woff") format('woff');
4242
}
4343

44-
* {
44+
*:not(body) {
4545
-webkit-box-sizing: border-box;
4646
-moz-box-sizing: border-box;
4747
box-sizing: border-box;
@@ -78,16 +78,6 @@ h1, h2, h3 {
7878
h1 {
7979
margin-bottom: 20px;
8080
}
81-
@media (min-width: 1170px) {
82-
h1 {
83-
margin-top: 40px;
84-
margin-bottom: 30px;
85-
}
86-
h1, h2, h3 {
87-
margin-top: 30px;
88-
margin-bottom: 15px;
89-
}
90-
}
9181
h4, h5, h6 {
9282
margin-top: 12px;
9383
margin-bottom: 10px;
@@ -197,7 +187,6 @@ pre, code {
197187
}
198188
pre {
199189
border-left: 2px solid #eee;
200-
border-radius: 0;
201190
white-space: pre-wrap;
202191
padding: 14px;
203192
padding-right: 0;
@@ -209,14 +198,12 @@ pre {
209198
code {
210199
padding: 0 2px;
211200
color: #8D1A38;
212-
white-space: nowrap;
201+
white-space: pre-wrap;
213202
}
214203
pre code {
215204
padding: 0;
216205
font-size: inherit;
217206
color: inherit;
218-
white-space: pre-wrap;
219-
background-color: transparent;
220207
}
221208

222209
/* Code highlighting */
@@ -237,7 +224,7 @@ pre.rust .lifetime { color: #B76514; }
237224
margin: 0.5em;
238225
font-size: 1.1em;
239226
}
240-
@media (min-width: 768px) {
227+
@media (min-width: 992px) {
241228
#versioninfo {
242229
font-size: 0.8em;
243230
position: fixed;
@@ -248,7 +235,7 @@ pre.rust .lifetime { color: #B76514; }
248235
background-color: #fff;
249236
margin: 2px;
250237
padding: 0 2px;
251-
border-radius: .3em;
238+
border-radius: .2em;
252239
}
253240
}
254241
#versioninfo a.hash {

src/librustdoc/html/render.rs

+15-13
Original file line numberDiff line numberDiff line change
@@ -924,19 +924,6 @@ impl<'a> Item<'a> {
924924

925925
impl<'a> fmt::Show for Item<'a> {
926926
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
927-
match attr::find_stability(self.item.attrs.iter()) {
928-
Some(ref stability) => {
929-
try!(write!(fmt.buf,
930-
"<a class='stability {lvl}' title='{reason}'>{lvl}</a>",
931-
lvl = stability.level.to_str(),
932-
reason = match stability.text {
933-
Some(ref s) => (*s).clone(),
934-
None => InternedString::new(""),
935-
}));
936-
}
937-
None => {}
938-
}
939-
940927
// Write the breadcrumb trail header for the top
941928
try!(write!(fmt.buf, "\n<h1 class='fqn'>"));
942929
match self.item.inner {
@@ -964,6 +951,21 @@ impl<'a> fmt::Show for Item<'a> {
964951
try!(write!(fmt.buf, "<a class='{}' href=''>{}</a>",
965952
shortty(self.item), self.item.name.get_ref().as_slice()));
966953

954+
// Write stability attributes
955+
match attr::find_stability(self.item.attrs.iter()) {
956+
Some(ref stability) => {
957+
try!(write!(fmt.buf,
958+
"<a class='stability {lvl}' title='{reason}'>{lvl}</a>",
959+
lvl = stability.level.to_str(),
960+
reason = match stability.text {
961+
Some(ref s) => (*s).clone(),
962+
None => InternedString::new(""),
963+
}));
964+
}
965+
None => {}
966+
}
967+
968+
// Write `src` tag
967969
if self.cx.include_sources {
968970
let mut path = Vec::new();
969971
clean_srcpath(self.item.source.filename.as_bytes(), |component| {

src/librustdoc/html/static/main.css

+11-6
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,18 @@ p {
9898

9999
code, pre {
100100
font-family: "Source Code Pro", Menlo, Monaco, Consolas, "DejaVu Sans Mono", Inconsolata, monospace;
101+
white-space: pre-wrap;
101102
}
102103
pre {
103104
font-size: 15px;
105+
padding: 14px;
106+
padding-right: 0;
107+
border-left: 2px solid #eee;
108+
}
109+
110+
.source pre {
111+
border-left: none;
112+
padding: 20px;
104113
}
105114

106115
nav.sub {
@@ -164,7 +173,6 @@ nav.sub {
164173
padding: 20px 0;
165174
}
166175

167-
.content pre { padding: 14px; }
168176
.content.source pre.rust {
169177
white-space: pre;
170178
overflow: auto;
@@ -355,10 +363,9 @@ a {
355363
.stability {
356364
border-left: 6px solid #000;
357365
border-radius: 3px;
358-
padding: 8px 3px 8px 10px;
366+
padding: 2px 10px;
359367
text-transform: lowercase;
360-
display: block;
361-
margin-bottom: 20px;
368+
margin-left: 10px;
362369
}
363370

364371
.stability.Deprecated { border-color: #D60027; color: #880017; }
@@ -370,8 +377,6 @@ a {
370377

371378
:target { background: #FDFFD3; }
372379

373-
pre.rust, pre.line-numbers { background-color: #F5F5F5; }
374-
375380
/* Code highlighting */
376381
pre.rust .kw { color: #8959A8; }
377382
pre.rust .kw-2, pre.rust .prelude-ty { color: #4271AE; }

0 commit comments

Comments
 (0)