Skip to content

Commit cbf1131

Browse files
committed
auto merge of #13776 : adrientetar/rust/rustdoc-fix, r=brson
- Closes #13591. Relevant example: http://adrientetar.legtux.org/cached/rust-docs/struct.CChars.htm (Had to use `!important` to override CSS selector precedence, namely matching over parent class.) - Implement changes from #13780 feedback, namely: * Changed font-size from 18px to 15px * Reintroduced gray background for code samples * Tightened up the margins - Fix point 1 and point 4 of #13804. Samples: - [enum.FileType](http://adrientetar.legtux.org/cached/rust-docs/enum.FileType.htm) - [struct.CChars](http://adrientetar.legtux.org/cached/rust-docs/struct.CChars.htm) - [std](http://adrientetar.legtux.org/cached/rust-docs/std.htm) - [std::io](http://adrientetar.legtux.org/cached/rust-docs/io.htm). r? @brson
2 parents 33259d9 + 2bf25a7 commit cbf1131

File tree

5 files changed

+49
-38
lines changed

5 files changed

+49
-38
lines changed

src/doc/rust.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ Two examples of paths with type arguments:
471471
# fn f() {
472472
# fn id<T>(t: T) -> T { t }
473473
type T = HashMap<int,~str>; // Type arguments used in a type expression
474-
let x = id::<int>(10); // Type arguments used in a call expression
474+
let x = id::<int>(10); // Type arguments used in a call expression
475475
# }
476476
~~~~
477477

src/doc/tutorial.md

+13-9
Original file line numberDiff line numberDiff line change
@@ -982,7 +982,8 @@ The obvious approach is to define `Cons` as containing an element in the list
982982
along with the next `List` node. However, this will generate a compiler error.
983983

984984
~~~ {.ignore}
985-
// error: illegal recursive enum type; wrap the inner value in a box to make it representable
985+
// error: illegal recursive enum type; wrap the inner value in a box to make it
986+
// representable
986987
enum List {
987988
Cons(u32, List), // an element (`u32`) and the next node in the list
988989
Nil
@@ -1054,10 +1055,10 @@ immutable, the whole list is immutable. The memory allocation itself is the
10541055
box, while the owner holds onto a pointer to it:
10551056

10561057
~~~ {.notrust}
1057-
List box List box List box List box
1058-
+--------------+ +--------------+ +--------------+ +--------------+
1059-
list -> | Cons | 1 | ~ | -> | Cons | 2 | ~ | -> | Cons | 3 | ~ | -> | Nil |
1060-
+--------------+ +--------------+ +--------------+ +--------------+
1058+
List box List box List box List box
1059+
+--------------+ +--------------+ +--------------+ +----------+
1060+
list -> | Cons | 1 | ~ | -> | Cons | 2 | ~ | -> | Cons | 3 | ~ | -> | Nil |
1061+
+--------------+ +--------------+ +--------------+ +----------+
10611062
~~~
10621063

10631064
> *Note:* the above diagram shows the logical contents of the enum. The actual
@@ -1197,7 +1198,8 @@ fn eq(xs: &List, ys: &List) -> bool {
11971198
// If we have reached the end of both lists, they are equal.
11981199
(&Nil, &Nil) => true,
11991200
// If the current element in both lists is equal, keep going.
1200-
(&Cons(x, ~ref next_xs), &Cons(y, ~ref next_ys)) if x == y => eq(next_xs, next_ys),
1201+
(&Cons(x, ~ref next_xs), &Cons(y, ~ref next_ys))
1202+
if x == y => eq(next_xs, next_ys),
12011203
// If the current elements are not equal, the lists are not equal.
12021204
_ => false
12031205
}
@@ -1256,7 +1258,7 @@ Using the generic `List<T>` works much like before, thanks to type inference:
12561258
# Cons(value, ~xs)
12571259
# }
12581260
let mut xs = Nil; // Unknown type! This is a `List<T>`, but `T` can be anything.
1259-
xs = prepend(xs, 10); // The compiler infers the type of `xs` as `List<int>` from this.
1261+
xs = prepend(xs, 10); // Here the compiler infers `xs`'s type as `List<int>`.
12601262
xs = prepend(xs, 15);
12611263
xs = prepend(xs, 20);
12621264
~~~
@@ -1303,7 +1305,8 @@ fn eq<T: Eq>(xs: &List<T>, ys: &List<T>) -> bool {
13031305
// If we have reached the end of both lists, they are equal.
13041306
(&Nil, &Nil) => true,
13051307
// If the current element in both lists is equal, keep going.
1306-
(&Cons(ref x, ~ref next_xs), &Cons(ref y, ~ref next_ys)) if x == y => eq(next_xs, next_ys),
1308+
(&Cons(ref x, ~ref next_xs), &Cons(ref y, ~ref next_ys))
1309+
if x == y => eq(next_xs, next_ys),
13071310
// If the current elements are not equal, the lists are not equal.
13081311
_ => false
13091312
}
@@ -1331,7 +1334,8 @@ impl<T: Eq> Eq for List<T> {
13311334
// If we have reached the end of both lists, they are equal.
13321335
(&Nil, &Nil) => true,
13331336
// If the current element in both lists is equal, keep going.
1334-
(&Cons(ref x, ~ref next_xs), &Cons(ref y, ~ref next_ys)) if x == y => next_xs == next_ys,
1337+
(&Cons(ref x, ~ref next_xs), &Cons(ref y, ~ref next_ys))
1338+
if x == y => next_xs == next_ys,
13351339
// If the current elements are not equal, the lists are not equal.
13361340
_ => false
13371341
}

src/librustdoc/html/markdown.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ pub fn render(w: &mut io::Writer, s: &str, print_toc: bool) -> fmt::Result {
209209
};
210210

211211
// Render the HTML
212-
let text = format!(r#"<h{lvl} id="{id}" class='section-link'><a
212+
let text = format!(r#"<h{lvl} id="{id}" class='section-header'><a
213213
href="\#{id}">{sec_len,plural,=0{}other{{sec} }}{}</a></h{lvl}>"#,
214214
s, lvl = level, id = id,
215215
sec_len = sec.len(), sec = sec);

src/librustdoc/html/render.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1121,7 +1121,7 @@ fn item_module(w: &mut Writer, cx: &Context,
11211121
clean::MacroItem(..) => ("macros", "Macros"),
11221122
};
11231123
try!(write!(w,
1124-
"<h2 id='{id}' class='section-link'>\
1124+
"<h2 id='{id}' class='section-header'>\
11251125
<a href=\"\\#{id}\">{name}</a></h2>\n<table>",
11261126
id = short, name = name));
11271127
}

src/librustdoc/html/static/main.css

+33-26
Original file line numberDiff line numberDiff line change
@@ -53,32 +53,40 @@
5353
body {
5454
color: #333;
5555
min-width: 500px;
56-
font: 18px "Heuristica", "Helvetica Neue", Helvetica, Arial, sans-serif;
57-
line-height: 1.4;
56+
font: 15.5px/1.4 "Heuristica", "Helvetica Neue", Helvetica, Arial, sans-serif;
5857
margin: 0;
5958
position: relative;
6059
padding: 10px 15px 20px 15px;
6160
}
6261

63-
h1, h2, h3:not(.impl), h4:not(.method) {
62+
h1 {
63+
font-size: 1.5em;
64+
}
65+
h2 {
66+
font-size: 1.4em;
67+
}
68+
h3 {
69+
font-size: 1.3em;
70+
}
71+
h1, h2, h3:not(.impl):not(.method), h4:not(.method) {
6472
color: black;
6573
font-weight: 500;
66-
margin: 30px 0 15px 0;
74+
margin: 20px 0 15px 0;
6775
padding-bottom: 6px;
6876
}
6977
h1.fqn {
7078
border-bottom: 1px dashed #D5D5D5;
7179
margin-top: 0;
7280
}
73-
h2, h3:not(.impl), h4:not(.method) {
81+
h2, h3:not(.impl):not(.method), h4:not(.method) {
7482
border-bottom: 1px solid #DDDDDD;
7583
}
76-
h3.impl, h4.method {
84+
h3.impl, h3.method, h4.method {
7785
font-weight: 600;
7886
margin-top: 10px;
7987
margin-bottom: 10px;
8088
}
81-
h3.impl {
89+
h3.impl, h3.method {
8290
margin-top: 15px;
8391
}
8492
h1, h2, h3, h4, section.sidebar, a.source, .search-input, .content table a {
@@ -93,27 +101,23 @@ ul ul, ol ul, ul ol, ol ol {
93101
}
94102

95103
p {
96-
margin: 0 0 1em 0;
104+
margin: 0 0 .6em 0;
97105
}
98106

99107
code, pre {
100108
font-family: "Source Code Pro", Menlo, Monaco, Consolas, "DejaVu Sans Mono", Inconsolata, monospace;
101109
white-space: pre-wrap;
102110
}
103111
pre {
104-
font-size: 15px;
112+
background-color: #F5F5F5;
105113
padding: 14px;
106-
padding-right: 0;
107-
border-left: 2px solid #eee;
108114
}
109115

110116
.source pre {
111-
border-left: none;
112117
padding: 20px;
113118
}
114119

115120
nav.sub {
116-
padding-top: 10px;
117121
font-size: 16px;
118122
text-transform: uppercase;
119123
}
@@ -149,7 +153,7 @@ nav.sub {
149153
}
150154

151155
.block {
152-
padding: 10px;
156+
padding: 0 10px;
153157
margin-bottom: 10px;
154158
}
155159
.block h2 {
@@ -170,7 +174,7 @@ nav.sub {
170174
}
171175

172176
.content {
173-
padding: 20px 0;
177+
padding: 15px 0;
174178
}
175179

176180
.content.source pre.rust {
@@ -211,9 +215,9 @@ nav.sub {
211215
text-overflow: ellipsis;
212216
margin: 0;
213217
}
218+
.docblock.short code { white-space: nowrap; }
214219

215220
.docblock h1, .docblock h2, .docblock h3, .docblock h4, .docblock h5 {
216-
margin: 30px 0 15px 0;
217221
border-bottom: 1px solid #DDD;
218222
}
219223

@@ -367,9 +371,10 @@ a {
367371
.stability {
368372
border-left: 6px solid #000;
369373
border-radius: 3px;
370-
padding: 2px 10px;
374+
font-weight: 400;
375+
padding: 4px 10px;
371376
text-transform: lowercase;
372-
margin-left: 10px;
377+
margin-left: 14px;
373378
}
374379

375380
.stability.Deprecated { border-color: #D60027; color: #880017; }
@@ -392,16 +397,18 @@ pre.rust .doccomment { color: #4D4D4C; }
392397
pre.rust .macro, pre.rust .macro-nonterminal { color: #3E999F; }
393398
pre.rust .lifetime { color: #B76514; }
394399

395-
h1.section-link:hover a:after,
396-
h2.section-link:hover a:after,
397-
h3.section-link:hover a:after,
398-
h4.section-link:hover a:after,
399-
h5.section-link:hover a:after,
400-
h6.section-link:hover a:after {
401-
content: '\2002\00a7\2002';
400+
.section-header {
401+
/* Override parent class attributes. */
402+
border-bottom: none !important;
403+
font-size: 1.1em !important;
404+
margin: 0 0 -5px;
405+
padding: 0;
406+
}
407+
.section-header:hover a:after {
408+
content: '\2002\00a7\2002';
402409
}
403410

404-
/** Media Queries **/
411+
/* Media Queries */
405412

406413
@media (max-width: 700px) {
407414
.sidebar {

0 commit comments

Comments
 (0)