Skip to content

Commit a1429bc

Browse files
committed
auto merge of #16277 : Gankro/rust/responsive-docs, r=cmr
* 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 ## [Live Version Here](http://cg.scs.carleton.ca/~abeinges/doc/index.html) Pages Of Interest: * [Vec](http://cg.scs.carleton.ca/~abeinges/doc/std/vec/struct.Vec.html) (small path) * [TreeSet](http://cg.scs.carleton.ca/~abeinges/doc/collections/treemap/struct.TreeSet.html) (long path) * [std](http://cg.scs.carleton.ca/~abeinges/doc/std/index.html) (for stability dash) TBD in a future PR is to convert links in the sidebar into a series of nest ul/li's, so that they can easily be moved to a drop-down in the new title bar. I think this is out of scope for this PR, but am willing to implement it now if desired.
2 parents 57630eb + dd437ee commit a1429bc

File tree

2 files changed

+79
-28
lines changed

2 files changed

+79
-28
lines changed

src/librustdoc/html/render.rs

Lines changed: 7 additions & 7 deletions
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

Lines changed: 72 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -252,8 +252,19 @@ nav.sub {
252252
.docblock h3, .docblock h4, .docblock h5 { font-size: 1em; }
253253

254254
.content .out-of-band {
255-
float: right;
256255
font-size: 23px;
256+
width: 40%;
257+
margin: 0px;
258+
padding: 0px;
259+
text-align: right;
260+
display: inline-block;
261+
}
262+
263+
.content .in-band {
264+
width: 60%;
265+
margin: 0px;
266+
padding: 0px;
267+
display: inline-block;
257268
}
258269

259270
.content table {
@@ -282,8 +293,8 @@ nav.sub {
282293
}
283294
.content .multi-column li { width: 100%; display: inline-block; }
284295

285-
.content .method {
286-
font-size: 1em;
296+
.content .method {
297+
font-size: 1em;
287298
position: relative;
288299
}
289300
.content .methods .docblock { margin-left: 40px; }
@@ -455,8 +466,8 @@ pre.rust { position: relative; }
455466
top: 0;
456467
right: 10px;
457468
font-size: 150%;
458-
-webkit-transform: scaleX(-1);
459-
transform: scaleX(-1);
469+
-webkit-transform: scaleX(-1);
470+
transform: scaleX(-1);
460471
}
461472

462473
.methods .section-header {
@@ -470,22 +481,6 @@ pre.rust { position: relative; }
470481
content: '\2002\00a7\2002';
471482
}
472483

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

0 commit comments

Comments
 (0)