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
This commit is contained in:
commit
cbf113182c
5 changed files with 49 additions and 38 deletions
|
@ -471,7 +471,7 @@ Two examples of paths with type arguments:
|
||||||
# fn f() {
|
# fn f() {
|
||||||
# fn id<T>(t: T) -> T { t }
|
# fn id<T>(t: T) -> T { t }
|
||||||
type T = HashMap<int,~str>; // Type arguments used in a type expression
|
type T = HashMap<int,~str>; // Type arguments used in a type expression
|
||||||
let x = id::<int>(10); // Type arguments used in a call expression
|
let x = id::<int>(10); // Type arguments used in a call expression
|
||||||
# }
|
# }
|
||||||
~~~~
|
~~~~
|
||||||
|
|
||||||
|
|
|
@ -982,7 +982,8 @@ The obvious approach is to define `Cons` as containing an element in the list
|
||||||
along with the next `List` node. However, this will generate a compiler error.
|
along with the next `List` node. However, this will generate a compiler error.
|
||||||
|
|
||||||
~~~ {.ignore}
|
~~~ {.ignore}
|
||||||
// error: illegal recursive enum type; wrap the inner value in a box to make it representable
|
// error: illegal recursive enum type; wrap the inner value in a box to make it
|
||||||
|
// representable
|
||||||
enum List {
|
enum List {
|
||||||
Cons(u32, List), // an element (`u32`) and the next node in the list
|
Cons(u32, List), // an element (`u32`) and the next node in the list
|
||||||
Nil
|
Nil
|
||||||
|
@ -1054,10 +1055,10 @@ immutable, the whole list is immutable. The memory allocation itself is the
|
||||||
box, while the owner holds onto a pointer to it:
|
box, while the owner holds onto a pointer to it:
|
||||||
|
|
||||||
~~~ {.notrust}
|
~~~ {.notrust}
|
||||||
List box List box List box List box
|
List box List box List box List box
|
||||||
+--------------+ +--------------+ +--------------+ +--------------+
|
+--------------+ +--------------+ +--------------+ +----------+
|
||||||
list -> | Cons | 1 | ~ | -> | Cons | 2 | ~ | -> | Cons | 3 | ~ | -> | Nil |
|
list -> | Cons | 1 | ~ | -> | Cons | 2 | ~ | -> | Cons | 3 | ~ | -> | Nil |
|
||||||
+--------------+ +--------------+ +--------------+ +--------------+
|
+--------------+ +--------------+ +--------------+ +----------+
|
||||||
~~~
|
~~~
|
||||||
|
|
||||||
> *Note:* the above diagram shows the logical contents of the enum. The actual
|
> *Note:* the above diagram shows the logical contents of the enum. The actual
|
||||||
|
@ -1197,7 +1198,8 @@ fn eq(xs: &List, ys: &List) -> bool {
|
||||||
// If we have reached the end of both lists, they are equal.
|
// If we have reached the end of both lists, they are equal.
|
||||||
(&Nil, &Nil) => true,
|
(&Nil, &Nil) => true,
|
||||||
// If the current element in both lists is equal, keep going.
|
// If the current element in both lists is equal, keep going.
|
||||||
(&Cons(x, ~ref next_xs), &Cons(y, ~ref next_ys)) if x == y => eq(next_xs, next_ys),
|
(&Cons(x, ~ref next_xs), &Cons(y, ~ref next_ys))
|
||||||
|
if x == y => eq(next_xs, next_ys),
|
||||||
// If the current elements are not equal, the lists are not equal.
|
// If the current elements are not equal, the lists are not equal.
|
||||||
_ => false
|
_ => false
|
||||||
}
|
}
|
||||||
|
@ -1256,7 +1258,7 @@ Using the generic `List<T>` works much like before, thanks to type inference:
|
||||||
# Cons(value, ~xs)
|
# Cons(value, ~xs)
|
||||||
# }
|
# }
|
||||||
let mut xs = Nil; // Unknown type! This is a `List<T>`, but `T` can be anything.
|
let mut xs = Nil; // Unknown type! This is a `List<T>`, but `T` can be anything.
|
||||||
xs = prepend(xs, 10); // The compiler infers the type of `xs` as `List<int>` from this.
|
xs = prepend(xs, 10); // Here the compiler infers `xs`'s type as `List<int>`.
|
||||||
xs = prepend(xs, 15);
|
xs = prepend(xs, 15);
|
||||||
xs = prepend(xs, 20);
|
xs = prepend(xs, 20);
|
||||||
~~~
|
~~~
|
||||||
|
@ -1303,7 +1305,8 @@ fn eq<T: Eq>(xs: &List<T>, ys: &List<T>) -> bool {
|
||||||
// If we have reached the end of both lists, they are equal.
|
// If we have reached the end of both lists, they are equal.
|
||||||
(&Nil, &Nil) => true,
|
(&Nil, &Nil) => true,
|
||||||
// If the current element in both lists is equal, keep going.
|
// If the current element in both lists is equal, keep going.
|
||||||
(&Cons(ref x, ~ref next_xs), &Cons(ref y, ~ref next_ys)) if x == y => eq(next_xs, next_ys),
|
(&Cons(ref x, ~ref next_xs), &Cons(ref y, ~ref next_ys))
|
||||||
|
if x == y => eq(next_xs, next_ys),
|
||||||
// If the current elements are not equal, the lists are not equal.
|
// If the current elements are not equal, the lists are not equal.
|
||||||
_ => false
|
_ => false
|
||||||
}
|
}
|
||||||
|
@ -1331,7 +1334,8 @@ impl<T: Eq> Eq for List<T> {
|
||||||
// If we have reached the end of both lists, they are equal.
|
// If we have reached the end of both lists, they are equal.
|
||||||
(&Nil, &Nil) => true,
|
(&Nil, &Nil) => true,
|
||||||
// If the current element in both lists is equal, keep going.
|
// If the current element in both lists is equal, keep going.
|
||||||
(&Cons(ref x, ~ref next_xs), &Cons(ref y, ~ref next_ys)) if x == y => next_xs == next_ys,
|
(&Cons(ref x, ~ref next_xs), &Cons(ref y, ~ref next_ys))
|
||||||
|
if x == y => next_xs == next_ys,
|
||||||
// If the current elements are not equal, the lists are not equal.
|
// If the current elements are not equal, the lists are not equal.
|
||||||
_ => false
|
_ => false
|
||||||
}
|
}
|
||||||
|
|
|
@ -209,7 +209,7 @@ pub fn render(w: &mut io::Writer, s: &str, print_toc: bool) -> fmt::Result {
|
||||||
};
|
};
|
||||||
|
|
||||||
// Render the HTML
|
// Render the HTML
|
||||||
let text = format!(r#"<h{lvl} id="{id}" class='section-link'><a
|
let text = format!(r#"<h{lvl} id="{id}" class='section-header'><a
|
||||||
href="\#{id}">{sec_len,plural,=0{}other{{sec} }}{}</a></h{lvl}>"#,
|
href="\#{id}">{sec_len,plural,=0{}other{{sec} }}{}</a></h{lvl}>"#,
|
||||||
s, lvl = level, id = id,
|
s, lvl = level, id = id,
|
||||||
sec_len = sec.len(), sec = sec);
|
sec_len = sec.len(), sec = sec);
|
||||||
|
|
|
@ -1121,7 +1121,7 @@ fn item_module(w: &mut Writer, cx: &Context,
|
||||||
clean::MacroItem(..) => ("macros", "Macros"),
|
clean::MacroItem(..) => ("macros", "Macros"),
|
||||||
};
|
};
|
||||||
try!(write!(w,
|
try!(write!(w,
|
||||||
"<h2 id='{id}' class='section-link'>\
|
"<h2 id='{id}' class='section-header'>\
|
||||||
<a href=\"\\#{id}\">{name}</a></h2>\n<table>",
|
<a href=\"\\#{id}\">{name}</a></h2>\n<table>",
|
||||||
id = short, name = name));
|
id = short, name = name));
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,32 +53,40 @@
|
||||||
body {
|
body {
|
||||||
color: #333;
|
color: #333;
|
||||||
min-width: 500px;
|
min-width: 500px;
|
||||||
font: 18px "Heuristica", "Helvetica Neue", Helvetica, Arial, sans-serif;
|
font: 15.5px/1.4 "Heuristica", "Helvetica Neue", Helvetica, Arial, sans-serif;
|
||||||
line-height: 1.4;
|
|
||||||
margin: 0;
|
margin: 0;
|
||||||
position: relative;
|
position: relative;
|
||||||
padding: 10px 15px 20px 15px;
|
padding: 10px 15px 20px 15px;
|
||||||
}
|
}
|
||||||
|
|
||||||
h1, h2, h3:not(.impl), h4:not(.method) {
|
h1 {
|
||||||
|
font-size: 1.5em;
|
||||||
|
}
|
||||||
|
h2 {
|
||||||
|
font-size: 1.4em;
|
||||||
|
}
|
||||||
|
h3 {
|
||||||
|
font-size: 1.3em;
|
||||||
|
}
|
||||||
|
h1, h2, h3:not(.impl):not(.method), h4:not(.method) {
|
||||||
color: black;
|
color: black;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
margin: 30px 0 15px 0;
|
margin: 20px 0 15px 0;
|
||||||
padding-bottom: 6px;
|
padding-bottom: 6px;
|
||||||
}
|
}
|
||||||
h1.fqn {
|
h1.fqn {
|
||||||
border-bottom: 1px dashed #D5D5D5;
|
border-bottom: 1px dashed #D5D5D5;
|
||||||
margin-top: 0;
|
margin-top: 0;
|
||||||
}
|
}
|
||||||
h2, h3:not(.impl), h4:not(.method) {
|
h2, h3:not(.impl):not(.method), h4:not(.method) {
|
||||||
border-bottom: 1px solid #DDDDDD;
|
border-bottom: 1px solid #DDDDDD;
|
||||||
}
|
}
|
||||||
h3.impl, h4.method {
|
h3.impl, h3.method, h4.method {
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
margin-top: 10px;
|
margin-top: 10px;
|
||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
}
|
}
|
||||||
h3.impl {
|
h3.impl, h3.method {
|
||||||
margin-top: 15px;
|
margin-top: 15px;
|
||||||
}
|
}
|
||||||
h1, h2, h3, h4, section.sidebar, a.source, .search-input, .content table a {
|
h1, h2, h3, h4, section.sidebar, a.source, .search-input, .content table a {
|
||||||
|
@ -93,7 +101,7 @@ ul ul, ol ul, ul ol, ol ol {
|
||||||
}
|
}
|
||||||
|
|
||||||
p {
|
p {
|
||||||
margin: 0 0 1em 0;
|
margin: 0 0 .6em 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
code, pre {
|
code, pre {
|
||||||
|
@ -101,19 +109,15 @@ code, pre {
|
||||||
white-space: pre-wrap;
|
white-space: pre-wrap;
|
||||||
}
|
}
|
||||||
pre {
|
pre {
|
||||||
font-size: 15px;
|
background-color: #F5F5F5;
|
||||||
padding: 14px;
|
padding: 14px;
|
||||||
padding-right: 0;
|
|
||||||
border-left: 2px solid #eee;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.source pre {
|
.source pre {
|
||||||
border-left: none;
|
|
||||||
padding: 20px;
|
padding: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
nav.sub {
|
nav.sub {
|
||||||
padding-top: 10px;
|
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
text-transform: uppercase;
|
text-transform: uppercase;
|
||||||
}
|
}
|
||||||
|
@ -149,7 +153,7 @@ nav.sub {
|
||||||
}
|
}
|
||||||
|
|
||||||
.block {
|
.block {
|
||||||
padding: 10px;
|
padding: 0 10px;
|
||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
}
|
}
|
||||||
.block h2 {
|
.block h2 {
|
||||||
|
@ -170,7 +174,7 @@ nav.sub {
|
||||||
}
|
}
|
||||||
|
|
||||||
.content {
|
.content {
|
||||||
padding: 20px 0;
|
padding: 15px 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.content.source pre.rust {
|
.content.source pre.rust {
|
||||||
|
@ -211,9 +215,9 @@ nav.sub {
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
.docblock.short code { white-space: nowrap; }
|
||||||
|
|
||||||
.docblock h1, .docblock h2, .docblock h3, .docblock h4, .docblock h5 {
|
.docblock h1, .docblock h2, .docblock h3, .docblock h4, .docblock h5 {
|
||||||
margin: 30px 0 15px 0;
|
|
||||||
border-bottom: 1px solid #DDD;
|
border-bottom: 1px solid #DDD;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -367,9 +371,10 @@ a {
|
||||||
.stability {
|
.stability {
|
||||||
border-left: 6px solid #000;
|
border-left: 6px solid #000;
|
||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
padding: 2px 10px;
|
font-weight: 400;
|
||||||
|
padding: 4px 10px;
|
||||||
text-transform: lowercase;
|
text-transform: lowercase;
|
||||||
margin-left: 10px;
|
margin-left: 14px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.stability.Deprecated { border-color: #D60027; color: #880017; }
|
.stability.Deprecated { border-color: #D60027; color: #880017; }
|
||||||
|
@ -392,16 +397,18 @@ pre.rust .doccomment { color: #4D4D4C; }
|
||||||
pre.rust .macro, pre.rust .macro-nonterminal { color: #3E999F; }
|
pre.rust .macro, pre.rust .macro-nonterminal { color: #3E999F; }
|
||||||
pre.rust .lifetime { color: #B76514; }
|
pre.rust .lifetime { color: #B76514; }
|
||||||
|
|
||||||
h1.section-link:hover a:after,
|
.section-header {
|
||||||
h2.section-link:hover a:after,
|
/* Override parent class attributes. */
|
||||||
h3.section-link:hover a:after,
|
border-bottom: none !important;
|
||||||
h4.section-link:hover a:after,
|
font-size: 1.1em !important;
|
||||||
h5.section-link:hover a:after,
|
margin: 0 0 -5px;
|
||||||
h6.section-link:hover a:after {
|
padding: 0;
|
||||||
content: '\2002\00a7\2002';
|
}
|
||||||
|
.section-header:hover a:after {
|
||||||
|
content: '\2002\00a7\2002';
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Media Queries **/
|
/* Media Queries */
|
||||||
|
|
||||||
@media (max-width: 700px) {
|
@media (max-width: 700px) {
|
||||||
.sidebar {
|
.sidebar {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue