Skip to content

rustdoc: design fixes and changes #13776

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 30, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/doc/rust.md
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ Two examples of paths with type arguments:
# fn f() {
# fn id<T>(t: T) -> T { t }
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
# }
~~~~

Expand Down
22 changes: 13 additions & 9 deletions src/doc/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

~~~ {.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 {
Cons(u32, List), // an element (`u32`) and the next node in the list
Nil
Expand Down Expand Up @@ -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:

~~~ {.notrust}
List box List box List box List box
+--------------+ +--------------+ +--------------+ +--------------+
list -> | Cons | 1 | ~ | -> | Cons | 2 | ~ | -> | Cons | 3 | ~ | -> | Nil |
+--------------+ +--------------+ +--------------+ +--------------+
List box List box List box List box
+--------------+ +--------------+ +--------------+ +----------+
list -> | Cons | 1 | ~ | -> | Cons | 2 | ~ | -> | Cons | 3 | ~ | -> | Nil |
+--------------+ +--------------+ +--------------+ +----------+
~~~

> *Note:* the above diagram shows the logical contents of the enum. The actual
Expand Down Expand Up @@ -1197,7 +1198,8 @@ fn eq(xs: &List, ys: &List) -> bool {
// If we have reached the end of both lists, they are equal.
(&Nil, &Nil) => true,
// 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.
_ => false
}
Expand Down Expand Up @@ -1256,7 +1258,7 @@ Using the generic `List<T>` works much like before, thanks to type inference:
# Cons(value, ~xs)
# }
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, 20);
~~~
Expand Down Expand Up @@ -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.
(&Nil, &Nil) => true,
// 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.
_ => false
}
Expand Down Expand Up @@ -1331,7 +1334,8 @@ impl<T: Eq> Eq for List<T> {
// If we have reached the end of both lists, they are equal.
(&Nil, &Nil) => true,
// 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.
_ => false
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/html/markdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ pub fn render(w: &mut io::Writer, s: &str, print_toc: bool) -> fmt::Result {
};

// 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}>"#,
s, lvl = level, id = id,
sec_len = sec.len(), sec = sec);
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/html/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1121,7 +1121,7 @@ fn item_module(w: &mut Writer, cx: &Context,
clean::MacroItem(..) => ("macros", "Macros"),
};
try!(write!(w,
"<h2 id='{id}' class='section-link'>\
"<h2 id='{id}' class='section-header'>\
<a href=\"\\#{id}\">{name}</a></h2>\n<table>",
id = short, name = name));
}
Expand Down
59 changes: 33 additions & 26 deletions src/librustdoc/html/static/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -53,32 +53,40 @@
body {
color: #333;
min-width: 500px;
font: 18px "Heuristica", "Helvetica Neue", Helvetica, Arial, sans-serif;
line-height: 1.4;
font: 15.5px/1.4 "Heuristica", "Helvetica Neue", Helvetica, Arial, sans-serif;
margin: 0;
position: relative;
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;
font-weight: 500;
margin: 30px 0 15px 0;
margin: 20px 0 15px 0;
padding-bottom: 6px;
}
h1.fqn {
border-bottom: 1px dashed #D5D5D5;
margin-top: 0;
}
h2, h3:not(.impl), h4:not(.method) {
h2, h3:not(.impl):not(.method), h4:not(.method) {
border-bottom: 1px solid #DDDDDD;
}
h3.impl, h4.method {
h3.impl, h3.method, h4.method {
font-weight: 600;
margin-top: 10px;
margin-bottom: 10px;
}
h3.impl {
h3.impl, h3.method {
margin-top: 15px;
}
h1, h2, h3, h4, section.sidebar, a.source, .search-input, .content table a {
Expand All @@ -93,27 +101,23 @@ ul ul, ol ul, ul ol, ol ol {
}

p {
margin: 0 0 1em 0;
margin: 0 0 .6em 0;
}

code, pre {
font-family: "Source Code Pro", Menlo, Monaco, Consolas, "DejaVu Sans Mono", Inconsolata, monospace;
white-space: pre-wrap;
}
pre {
font-size: 15px;
background-color: #F5F5F5;
padding: 14px;
padding-right: 0;
border-left: 2px solid #eee;
}

.source pre {
border-left: none;
padding: 20px;
}

nav.sub {
padding-top: 10px;
font-size: 16px;
text-transform: uppercase;
}
Expand Down Expand Up @@ -149,7 +153,7 @@ nav.sub {
}

.block {
padding: 10px;
padding: 0 10px;
margin-bottom: 10px;
}
.block h2 {
Expand All @@ -170,7 +174,7 @@ nav.sub {
}

.content {
padding: 20px 0;
padding: 15px 0;
}

.content.source pre.rust {
Expand Down Expand Up @@ -207,9 +211,9 @@ nav.sub {
text-overflow: ellipsis;
margin: 0;
}
.docblock.short code { white-space: nowrap; }

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

Expand Down Expand Up @@ -363,9 +367,10 @@ a {
.stability {
border-left: 6px solid #000;
border-radius: 3px;
padding: 2px 10px;
font-weight: 400;
padding: 4px 10px;
text-transform: lowercase;
margin-left: 10px;
margin-left: 14px;
}

.stability.Deprecated { border-color: #D60027; color: #880017; }
Expand All @@ -388,16 +393,18 @@ pre.rust .doccomment { color: #4D4D4C; }
pre.rust .macro, pre.rust .macro-nonterminal { color: #3E999F; }
pre.rust .lifetime { color: #B76514; }

h1.section-link:hover a:after,
h2.section-link:hover a:after,
h3.section-link:hover a:after,
h4.section-link:hover a:after,
h5.section-link:hover a:after,
h6.section-link:hover a:after {
content: '\2002\00a7\2002';
.section-header {
/* Override parent class attributes. */
border-bottom: none !important;
font-size: 1.1em !important;
margin: 0 0 -5px;
padding: 0;
}
.section-header:hover a:after {
content: '\2002\00a7\2002';
}

/** Media Queries **/
/* Media Queries */

@media (max-width: 700px) {
.sidebar {
Expand Down