Skip to content

Commit dd437ee

Browse files
committed
make rustdoc more responsive
* move some sidebar contents to a title bar when small * inline description toggle when small * make out-of-band and in-band content share space, rather than float and clash * compress wording of out-of-band content to avoid line-wrap as much as possible
1 parent e5df5f5 commit dd437ee

File tree

2 files changed

+79
-28
lines changed

2 files changed

+79
-28
lines changed

src/librustdoc/html/render.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -1294,7 +1294,7 @@ impl<'a> Item<'a> {
12941294
impl<'a> fmt::Show for Item<'a> {
12951295
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
12961296
// Write the breadcrumb trail header for the top
1297-
try!(write!(fmt, "\n<h1 class='fqn'>"));
1297+
try!(write!(fmt, "\n<h1 class='fqn'><div class='in-band'>"));
12981298
match self.item.inner {
12991299
clean::ModuleItem(ref m) => if m.is_crate {
13001300
try!(write!(fmt, "Crate "));
@@ -1316,7 +1316,7 @@ impl<'a> fmt::Show for Item<'a> {
13161316
let cur = self.cx.current.as_slice();
13171317
let amt = if self.ismodule() { cur.len() - 1 } else { cur.len() };
13181318
for (i, component) in cur.iter().enumerate().take(amt) {
1319-
try!(write!(fmt, "<a href='{}index.html'>{}</a>::",
1319+
try!(write!(fmt, "<a href='{}index.html'>{}</a>&#8203;::",
13201320
"../".repeat(cur.len() - i - 1),
13211321
component.as_slice()));
13221322
}
@@ -1325,10 +1325,10 @@ impl<'a> fmt::Show for Item<'a> {
13251325
shortty(self.item), self.item.name.get_ref().as_slice()));
13261326

13271327
// Write stability level
1328-
try!(write!(fmt, "{}", Stability(&self.item.stability)));
1328+
try!(write!(fmt, "&#8203;{}", Stability(&self.item.stability)));
13291329

13301330
// Links to out-of-band information, i.e. src and stability dashboard
1331-
try!(write!(fmt, "<span class='out-of-band'>"));
1331+
try!(write!(fmt, "</div><div class='out-of-band'>"));
13321332

13331333
// Write stability dashboard link
13341334
match self.item.inner {
@@ -1340,8 +1340,8 @@ impl<'a> fmt::Show for Item<'a> {
13401340

13411341
try!(write!(fmt,
13421342
r##"<span id='render-detail'>
1343-
<a id="collapse-all" href="#">[collapse all]</a>
1344-
<a id="expand-all" href="#">[expand all]</a>
1343+
<a id="collapse-all" href="#">[-]
1344+
</a>&nbsp;<a id="expand-all" href="#">[+]</a>
13451345
</span>"##));
13461346

13471347
// Write `src` tag
@@ -1360,7 +1360,7 @@ impl<'a> fmt::Show for Item<'a> {
13601360
}
13611361
}
13621362

1363-
try!(write!(fmt, "</span>"));
1363+
try!(write!(fmt, "</div>"));
13641364

13651365
try!(write!(fmt, "</h1>\n"));
13661366

src/librustdoc/html/static/main.css

+72-21
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,19 @@ nav.sub {
247247
.docblock h3, .docblock h4, .docblock h5 { font-size: 1em; }
248248

249249
.content .out-of-band {
250-
float: right;
251250
font-size: 23px;
251+
width: 40%;
252+
margin: 0px;
253+
padding: 0px;
254+
text-align: right;
255+
display: inline-block;
256+
}
257+
258+
.content .in-band {
259+
width: 60%;
260+
margin: 0px;
261+
padding: 0px;
262+
display: inline-block;
252263
}
253264

254265
.content table {
@@ -277,8 +288,8 @@ nav.sub {
277288
}
278289
.content .multi-column li { width: 100%; display: inline-block; }
279290

280-
.content .method {
281-
font-size: 1em;
291+
.content .method {
292+
font-size: 1em;
282293
position: relative;
283294
}
284295
.content .methods .docblock { margin-left: 40px; }
@@ -450,8 +461,8 @@ pre.rust { position: relative; }
450461
top: 0;
451462
right: 10px;
452463
font-size: 150%;
453-
-webkit-transform: scaleX(-1);
454-
transform: scaleX(-1);
464+
-webkit-transform: scaleX(-1);
465+
transform: scaleX(-1);
455466
}
456467

457468
.methods .section-header {
@@ -465,22 +476,6 @@ pre.rust { position: relative; }
465476
content: '\2002\00a7\2002';
466477
}
467478

468-
/* Media Queries */
469-
470-
@media (max-width: 700px) {
471-
.sidebar {
472-
display: none;
473-
}
474-
475-
.content {
476-
margin-left: 0px;
477-
}
478-
479-
nav.sub {
480-
margin: 0 auto;
481-
}
482-
}
483-
484479
.collapse-toggle {
485480
font-weight: 100;
486481
position: absolute;
@@ -513,3 +508,59 @@ pre.rust { position: relative; }
513508
color: #999;
514509
font-style: italic;
515510
}
511+
512+
513+
514+
/* Media Queries */
515+
516+
@media (max-width: 700px) {
517+
body {
518+
padding-top: 0px;
519+
}
520+
521+
.sidebar {
522+
height: 40px;
523+
min-height: 40px;
524+
width: 100%;
525+
margin: 0px;
526+
padding: 0px;
527+
position: static;
528+
}
529+
530+
.sidebar .location {
531+
float: left;
532+
margin: 0px;
533+
padding: 5px;
534+
width: 60%;
535+
background: inherit;
536+
text-align: left;
537+
font-size: 24px;
538+
}
539+
540+
.sidebar img {
541+
width: 35px;
542+
margin-top: 5px;
543+
margin-bottom: 0px;
544+
float: left;
545+
}
546+
547+
nav.sub {
548+
margin: 0 auto;
549+
}
550+
551+
.sidebar .block {
552+
display: none;
553+
}
554+
555+
.content {
556+
margin-left: 0px;
557+
}
558+
559+
.toggle-wrapper > .collapse-toggle {
560+
left: 0px;
561+
}
562+
563+
.toggle-wrapper {
564+
height: 1.5em;
565+
}
566+
}

0 commit comments

Comments
 (0)