auto merge of #10421 : adridu59/rust/patch-www, r=alexcrichton

* Closes #10330
* Improves on #9873
* Adds favicon for tutorial files
This commit is contained in:
bors 2013-11-13 14:41:19 -08:00
commit 49c6ae10cb
9 changed files with 88 additions and 126 deletions

1
doc/favicon.inc Normal file
View File

@ -0,0 +1 @@
<link rel="shortcut icon" href="http://www.rust-lang.org/favicon.ico" />

View File

@ -4,4 +4,9 @@
display: block; display: block;
padding-left: 2em; padding-left: 2em;
} }
</style> #influences blockquote p:last-child {
display: block;
line-height: 1.428571429;
color: #999999;
}
</style>

View File

@ -2,7 +2,7 @@
* Copyright 2013 The Rust Project Developers. See the COPYRIGHT * Copyright 2013 The Rust Project Developers. See the COPYRIGHT
* file at the top-level directory of this distribution and at * file at the top-level directory of this distribution and at
* http://rust-lang.org/COPYRIGHT. * http://rust-lang.org/COPYRIGHT.
* With elements taken from Bootstrap v3.0.0 (Apache v2.0 licensed). * With elements taken from Bootstrap v3.0.2 (MIT licensed).
* *
* Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or * Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
* http://www.apache.org/licenses/LICENSE-2.0> or the MIT license * http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
@ -93,6 +93,7 @@ p {
a { a {
text-decoration: none; text-decoration: none;
color: #428BCA; color: #428BCA;
background: transparent;
} }
a:hover, a:focus { a:hover, a:focus {
color: #2A6496; color: #2A6496;
@ -114,7 +115,7 @@ h5 a:link, h5 a:visited {color: black;}
/* Code /* Code
========================================================================== */ ========================================================================== */
pre, code { pre, code {
font-family: Monaco, Menlo, Consolas, "Courier New", monospace; font-family: Menlo, Monaco, Consolas, "Courier New", monospace;
border-radius: 4px; border-radius: 4px;
} }
pre { pre {
@ -141,7 +142,7 @@ pre code {
color: inherit; color: inherit;
white-space: pre-wrap; white-space: pre-wrap;
background-color: transparent; background-color: transparent;
border: 0; border-radius: 0;
} }
/* Code highlighting */ /* Code highlighting */
@ -158,7 +159,7 @@ pre code {
.cm-s-default span.cm-string {color: #a11;} .cm-s-default span.cm-string {color: #a11;}
.cm-s-default span.cm-string-2 {color: #f50;} .cm-s-default span.cm-string-2 {color: #f50;}
.cm-s-default span.cm-meta {color: #555;} .cm-s-default span.cm-meta {color: #555;}
.cm-s-default span.cm-error {color: #f00;} /*.cm-s-default span.cm-error {color: #f00;}*/
.cm-s-default span.cm-qualifier {color: #555;} .cm-s-default span.cm-qualifier {color: #555;}
.cm-s-default span.cm-builtin {color: #30a;} .cm-s-default span.cm-builtin {color: #30a;}
.cm-s-default span.cm-bracket {color: #cc7;} .cm-s-default span.cm-bracket {color: #cc7;}
@ -187,7 +188,7 @@ pre code {
} }
#versioninfo a.hash { #versioninfo a.hash {
color: gray; color: gray;
font-size: 60%; font-size: 70%;
} }
blockquote { blockquote {
@ -303,4 +304,4 @@ hr {
table td, table th { table td, table th {
background-color: #fff !important; background-color: #fff !important;
} }
} }

View File

@ -210,10 +210,10 @@ solves the problem.
# Macro argument pattern matching # Macro argument pattern matching
Now consider code like the following:
## Motivation ## Motivation
Now consider code like the following:
~~~~ ~~~~
# enum t1 { good_1(t2, uint), bad_1 }; # enum t1 { good_1(t2, uint), bad_1 };
# pub struct t2 { body: t3 } # pub struct t2 { body: t3 }

View File

@ -27,7 +27,6 @@ $ rustc main.rs
main.rs:1:0: 1:17 error: can't find crate for `hello` main.rs:1:0: 1:17 error: can't find crate for `hello`
main.rs:1 extern mod hello; main.rs:1 extern mod hello;
^~~~~~~~~~~~~~~~~ ^~~~~~~~~~~~~~~~~
~~~~ ~~~~
This makes sense, as we haven't gotten it from anywhere yet! Luckily for us, This makes sense, as we haven't gotten it from anywhere yet! Luckily for us,
@ -216,7 +215,7 @@ a function that can be sensibly tested:
#[license = "MIT"]; #[license = "MIT"];
pub fn is_even(i: uint) -> bool { pub fn is_even(i: uint) -> bool {
i % 2 == 0 i % 2 == 0
} }
~~~ ~~~
@ -230,9 +229,9 @@ use hello::is_even;
#[test] #[test]
fn test_is_even() { fn test_is_even() {
assert!(is_even(0)); assert!(is_even(0));
assert!(!is_even(1)); assert!(!is_even(1));
assert!(is_even(2)); assert!(is_even(2));
} }
~~~ ~~~

View File

@ -104,8 +104,8 @@ an environment that it carries across tasks.
let child_task_number = generate_task_number(); let child_task_number = generate_task_number();
do spawn { do spawn {
// Capture it in the remote task // Capture it in the remote task
println!("I am child number {}", child_task_number); println!("I am child number {}", child_task_number);
} }
~~~ ~~~

View File

@ -804,7 +804,7 @@ confusing numbers that correspond to different units.
We've already seen several function definitions. Like all other static We've already seen several function definitions. Like all other static
declarations, such as `type`, functions can be declared both at the declarations, such as `type`, functions can be declared both at the
top level and inside other functions (or in modules, which we'll come top level and inside other functions (or in modules, which we'll come
back to [later](#modules-and-crates)). The `fn` keyword introduces a back to [later](#crates-and-the-module-system)). The `fn` keyword introduces a
function. A function has an argument list, which is a parenthesized function. A function has an argument list, which is a parenthesized
list of `expr: type` pairs separated by commas. An arrow `->` list of `expr: type` pairs separated by commas. An arrow `->`
separates the argument list and the function's return type. separates the argument list and the function's return type.
@ -2711,10 +2711,10 @@ extend with the `-L` switch).
However, Rust also ships with rustpkg, a package manager that is able to automatically download and build However, Rust also ships with rustpkg, a package manager that is able to automatically download and build
libraries if you use it for building your crate. How it works is explained [here][rustpkg], libraries if you use it for building your crate. How it works is explained [here][rustpkg],
but for this tutorial it's only important to know that you can optionally annotate an but for this tutorial it's only important to know that you can optionally annotate an
`extern mod` statement with an package id that rustpkg can use to identify it: `extern mod` statement with a package id that rustpkg can use to identify it:
~~~ {.ignore} ~~~ {.ignore}
extern mod rust = "github.com/mozilla/rust"; // pretend Rust is an simple library extern mod rust = "github.com/mozilla/rust"; // pretend Rust is a simple library
~~~ ~~~
[rustpkg]: rustpkg.html [rustpkg]: rustpkg.html
@ -2730,7 +2730,7 @@ the link name and the version. It also hashes the filename and the symbols in a
based on the link metadata, allowing you to use two different versions of the same library in a crate based on the link metadata, allowing you to use two different versions of the same library in a crate
without conflict. without conflict.
Therefor, if you plan to compile your crate as a library, you should annotate it with that information: Therefore, if you plan to compile your crate as a library, you should annotate it with that information:
~~~~ ~~~~
// lib.rs // lib.rs
@ -2746,8 +2746,8 @@ Therefor, if you plan to compile your crate as a library, you should annotate it
You can also in turn require in a `extern mod` statement that certain link metadata items match some criteria. You can also in turn require in a `extern mod` statement that certain link metadata items match some criteria.
For that, Rust currently parses a comma-separated list of name/value pairs that appear after For that, Rust currently parses a comma-separated list of name/value pairs that appear after
it, and ensures that they match the attributes provided in the `link` attribute of a crate file. it, and ensures that they match the attributes provided in the `link` attribute of a crate file.
This enables you to, eg, pick a a crate based on it's version number, or to link an library under an This enables you to, e.g., pick a crate based on its version number, or link a library under a
different name. For example, this two mod statements would both accept and select the crate define above: different name. For example, these two `mod` statements would both accept and select the crate define above:
~~~~ {.xfail-test} ~~~~ {.xfail-test}
extern mod farm(vers = "2.5"); extern mod farm(vers = "2.5");
@ -2836,14 +2836,14 @@ This allows you to use common types and functions like `Option<T>` or `println`
without needing to import them. And if you need something from `std` that's not in the prelude, without needing to import them. And if you need something from `std` that's not in the prelude,
you just have to import it with an `use` statement. you just have to import it with an `use` statement.
For example, it re-exports `println` which is defined in `std::io::println`: For example, it re-exports `println` which is defined in `std::io::stdio::println`:
~~~ ~~~
use puts = std::io::stdio::println; use puts = std::io::stdio::println;
fn main() { fn main() {
println("println is imported per default."); println("println is imported per default.");
puts("Doesn't hinder you from importing it under an different name yourself."); puts("Doesn't hinder you from importing it under a different name yourself.");
::std::io::stdio::println("Or from not using the automatic import."); ::std::io::stdio::println("Or from not using the automatic import.");
} }
~~~ ~~~

View File

@ -15,6 +15,10 @@
DOCS := DOCS :=
DOCS_L10N := DOCS_L10N :=
BASE_DOC_OPTS := --from=markdown --standalone --toc --number-sections --include-before-body=doc/version_info.html
HTML_OPTS = $(BASE_DOC_OPTS) --to=html5 --section-divs --css=rust.css --include-in-header=doc/favicon.inc
TEX_OPTS = $(BASE_DOC_OPTS) --to=latex
EPUB_OPTS = $(BASE_DOC_OPTS) --to=epub
###################################################################### ######################################################################
# Docs, from pandoc, rustdoc (which runs pandoc), and node # Docs, from pandoc, rustdoc (which runs pandoc), and node
@ -28,6 +32,10 @@ doc/manual.inc: manual.inc
@$(call E, cp: $@) @$(call E, cp: $@)
$(Q)cp -a $< $@ 2> /dev/null $(Q)cp -a $< $@ 2> /dev/null
doc/favicon.inc: favicon.inc
@$(call E, cp: $@)
$(Q)cp -a $< $@ 2> /dev/null
ifeq ($(CFG_PANDOC),) ifeq ($(CFG_PANDOC),)
$(info cfg: no pandoc found, omitting docs) $(info cfg: no pandoc found, omitting docs)
NO_DOCS = 1 NO_DOCS = 1
@ -41,86 +49,49 @@ endif
ifneq ($(NO_DOCS),1) ifneq ($(NO_DOCS),1)
DOCS += doc/rust.html DOCS += doc/rust.html
doc/rust.html: rust.md doc/version_info.html doc/rust.css doc/manual.inc doc/rust.html: rust.md doc/version_info.html doc/rust.css doc/manual.inc \
doc/favicon.inc
@$(call E, pandoc: $@) @$(call E, pandoc: $@)
$(Q)$(CFG_NODE) $(S)doc/prep.js --highlight $< | \ $(Q)$(CFG_NODE) $(S)doc/prep.js --highlight $< | \
"$(CFG_PANDOC)" \ $(CFG_PANDOC) $(HTML_OPTS) --include-in-header=doc/manual.inc --output=$@
--standalone --toc \
--section-divs \
--number-sections \
--from=markdown --to=html5 \
--css=rust.css --include-in-header=doc/manual.inc \
--include-before-body=doc/version_info.html \
--output=$@
DOCS += doc/rust.tex DOCS += doc/rust.tex
doc/rust.tex: rust.md doc/version.md doc/rust.tex: rust.md doc/version.md
@$(call E, pandoc: $@) @$(call E, pandoc: $@)
$(Q)$(CFG_NODE) $(S)doc/prep.js $< | \ $(Q)$(CFG_NODE) $(S)doc/prep.js $< | \
"$(CFG_PANDOC)" \ $(CFG_PANDOC) $(TEX_OPTS) --output=$@
--standalone --toc \
--number-sections \
--include-before-body=doc/version.md \
--from=markdown --to=latex \
--output=$@
DOCS += doc/rust.epub DOCS += doc/rust.epub
doc/rust.epub: rust.md doc/version_info.html doc/rust.css doc/manual.inc doc/rust.epub: rust.md doc/version_info.html doc/rust.css
@$(call E, pandoc: $@) @$(call E, pandoc: $@)
$(Q)$(CFG_NODE) $(S)doc/prep.js --highlight $< | \ $(Q)$(CFG_NODE) $(S)doc/prep.js --highlight $< | \
"$(CFG_PANDOC)" \ $(CFG_PANDOC) $(EPUB_OPTS) --output=$@
--standalone --toc \
--section-divs \
--number-sections \
--from=markdown --to=epub \
--css=rust.css --include-in-header=doc/manual.inc \
--include-before-body=doc/version_info.html \
--output=$@
DOCS += doc/rustpkg.html
doc/rustpkg.html: rustpkg.md doc/version_info.html doc/rust.css \
doc/favicon.inc
@$(call E, pandoc: $@)
$(Q)$(CFG_NODE) $(S)doc/prep.js --highlight $< | \
$(CFG_PANDOC) $(HTML_OPTS) --output=$@
DOCS += doc/tutorial.html
doc/tutorial.html: tutorial.md doc/version_info.html doc/rust.css \
doc/favicon.inc
@$(call E, pandoc: $@)
$(Q)$(CFG_NODE) $(S)doc/prep.js --highlight $< | \
$(CFG_PANDOC) $(HTML_OPTS) --output=$@
DOCS += doc/tutorial.tex DOCS += doc/tutorial.tex
doc/tutorial.tex: tutorial.md doc/version.md doc/tutorial.tex: tutorial.md doc/version.md
@$(call E, pandoc: $@) @$(call E, pandoc: $@)
$(Q)$(CFG_NODE) $(S)doc/prep.js $< | \ $(Q)$(CFG_NODE) $(S)doc/prep.js $< | \
"$(CFG_PANDOC)" \ $(CFG_PANDOC) $(TEX_OPTS) --output=$@
--standalone --toc \
--number-sections \
--include-before-body=doc/version.md \
--from=markdown --to=latex \
--output=$@
DOCS += doc/rustpkg.html
doc/rustpkg.html: rustpkg.md doc/version_info.html doc/rust.css doc/manual.inc
@$(call E, pandoc: $@)
$(Q)$(CFG_NODE) $(S)doc/prep.js --highlight $< | \
"$(CFG_PANDOC)" \
--standalone --toc \
--section-divs \
--number-sections \
--from=markdown --to=html5 \
--css=rust.css --include-in-header=doc/manual.inc \
--include-before-body=doc/version_info.html \
--output=$@
DOCS += doc/tutorial.html
doc/tutorial.html: tutorial.md doc/version_info.html doc/rust.css
@$(call E, pandoc: $@)
$(Q)$(CFG_NODE) $(S)doc/prep.js --highlight $< | \
$(CFG_PANDOC) --standalone --toc \
--section-divs --number-sections \
--from=markdown --to=html5 --css=rust.css \
--include-before-body=doc/version_info.html \
--output=$@
DOCS += doc/tutorial.epub DOCS += doc/tutorial.epub
doc/tutorial.epub: tutorial.md doc/version_info.html doc/rust.css doc/tutorial.epub: tutorial.md doc/version_info.html doc/rust.css
@$(call E, pandoc: $@) @$(call E, pandoc: $@)
$(Q)$(CFG_NODE) $(S)doc/prep.js --highlight $< | \ $(Q)$(CFG_NODE) $(S)doc/prep.js --highlight $< | \
$(CFG_PANDOC) --standalone --toc \ $(CFG_PANDOC) $(EPUB_OPTS) --output=$@
--section-divs --number-sections \
--from=markdown --to=epub --css=rust.css \
--include-before-body=doc/version_info.html \
--output=$@
DOCS_L10N += doc/l10n/ja/tutorial.html DOCS_L10N += doc/l10n/ja/tutorial.html
@ -134,75 +105,53 @@ doc/l10n/ja/tutorial.html: doc/l10n/ja/tutorial.md doc/version_info.html doc/rus
--output=$@ --output=$@
DOCS += doc/tutorial-macros.html DOCS += doc/tutorial-macros.html
doc/tutorial-macros.html: tutorial-macros.md doc/version_info.html \ doc/tutorial-macros.html: tutorial-macros.md doc/version_info.html doc/rust.css \
doc/rust.css doc/favicon.inc
@$(call E, pandoc: $@) @$(call E, pandoc: $@)
$(Q)$(CFG_NODE) $(S)doc/prep.js --highlight $< | \ $(Q)$(CFG_NODE) $(S)doc/prep.js --highlight $< | \
$(CFG_PANDOC) --standalone --toc \ $(CFG_PANDOC) $(HTML_OPTS) --output=$@
--section-divs --number-sections \
--from=markdown --to=html5 --css=rust.css \
--include-before-body=doc/version_info.html \
--output=$@
DOCS += doc/tutorial-container.html DOCS += doc/tutorial-container.html
doc/tutorial-container.html: tutorial-container.md doc/version_info.html doc/rust.css doc/tutorial-container.html: tutorial-container.md doc/version_info.html doc/rust.css \
doc/favicon.inc
@$(call E, pandoc: $@) @$(call E, pandoc: $@)
$(Q)$(CFG_NODE) $(S)doc/prep.js --highlight $< | \ $(Q)$(CFG_NODE) $(S)doc/prep.js --highlight $< | \
$(CFG_PANDOC) --standalone --toc \ $(CFG_PANDOC) $(HTML_OPTS) --output=$@
--section-divs --number-sections \
--from=markdown --to=html5 --css=rust.css \
--include-before-body=doc/version_info.html \
--output=$@
DOCS += doc/tutorial-ffi.html DOCS += doc/tutorial-ffi.html
doc/tutorial-ffi.html: tutorial-ffi.md doc/version_info.html doc/rust.css doc/tutorial-ffi.html: tutorial-ffi.md doc/version_info.html doc/rust.css \
doc/favicon.inc
@$(call E, pandoc: $@) @$(call E, pandoc: $@)
$(Q)$(CFG_NODE) $(S)doc/prep.js --highlight $< | \ $(Q)$(CFG_NODE) $(S)doc/prep.js --highlight $< | \
$(CFG_PANDOC) --standalone --toc \ $(CFG_PANDOC) $(HTML_OPTS) --output=$@
--section-divs --number-sections \
--from=markdown --to=html5 --css=rust.css \
--include-before-body=doc/version_info.html \
--output=$@
DOCS += doc/tutorial-borrowed-ptr.html DOCS += doc/tutorial-borrowed-ptr.html
doc/tutorial-borrowed-ptr.html: tutorial-borrowed-ptr.md doc/version_info.html doc/rust.css doc/tutorial-borrowed-ptr.html: tutorial-borrowed-ptr.md doc/version_info.html doc/rust.css \
doc/favicon.inc
@$(call E, pandoc: $@) @$(call E, pandoc: $@)
$(Q)$(CFG_NODE) $(S)doc/prep.js --highlight $< | \ $(Q)$(CFG_NODE) $(S)doc/prep.js --highlight $< | \
$(CFG_PANDOC) --standalone --toc \ $(CFG_PANDOC) $(HTML_OPTS) --output=$@
--section-divs --number-sections \
--from=markdown --to=html5 --css=rust.css \
--include-before-body=doc/version_info.html \
--output=$@
DOCS += doc/tutorial-tasks.html DOCS += doc/tutorial-tasks.html
doc/tutorial-tasks.html: tutorial-tasks.md doc/version_info.html doc/rust.css doc/tutorial-tasks.html: tutorial-tasks.md doc/version_info.html doc/rust.css \
doc/favicon.inc
@$(call E, pandoc: $@) @$(call E, pandoc: $@)
$(Q)$(CFG_NODE) $(S)doc/prep.js --highlight $< | \ $(Q)$(CFG_NODE) $(S)doc/prep.js --highlight $< | \
$(CFG_PANDOC) --standalone --toc \ $(CFG_PANDOC) $(HTML_OPTS) --output=$@
--section-divs --number-sections \
--from=markdown --to=html5 --css=rust.css \
--include-before-body=doc/version_info.html \
--output=$@
DOCS += doc/tutorial-conditions.html DOCS += doc/tutorial-conditions.html
doc/tutorial-conditions.html: tutorial-conditions.md doc/version_info.html doc/rust.css doc/tutorial-conditions.html: tutorial-conditions.md doc/version_info.html doc/rust.css \
doc/favicon.inc
@$(call E, pandoc: $@) @$(call E, pandoc: $@)
$(Q)$(CFG_NODE) $(S)doc/prep.js --highlight $< | \ $(Q)$(CFG_NODE) $(S)doc/prep.js --highlight $< | \
$(CFG_PANDOC) --standalone --toc \ $(CFG_PANDOC) $(HTML_OPTS) --output=$@
--section-divs --number-sections \
--from=markdown --to=html5 --css=rust.css \
--include-before-body=doc/version_info.html \
--output=$@
DOCS += doc/tutorial-rustpkg.html DOCS += doc/tutorial-rustpkg.html
doc/tutorial-rustpkg.html: tutorial-rustpkg.md doc/version_info.html doc/rust.css doc/tutorial-rustpkg.html: tutorial-rustpkg.md doc/version_info.html doc/rust.css \
doc/favicon.inc
@$(call E, pandoc: $@) @$(call E, pandoc: $@)
$(Q)$(CFG_NODE) $(S)doc/prep.js --highlight $< | \ $(Q)$(CFG_NODE) $(S)doc/prep.js --highlight $< | \
$(CFG_PANDOC) --standalone --toc \ $(CFG_PANDOC) $(HTML_OPTS) --output=$@
--section-divs --number-sections \
--from=markdown --to=html5 --css=rust.css \
--include-before-body=doc/version_info.html \
--output=$@
ifeq ($(CFG_PDFLATEX),) ifeq ($(CFG_PDFLATEX),)
$(info cfg: no pdflatex found, omitting doc/rust.pdf) $(info cfg: no pdflatex found, omitting doc/rust.pdf)

View File

@ -43,7 +43,13 @@ h2 code, h3 code, h4 code {
} }
code, pre, h1.fqn { code, pre, h1.fqn {
font: 15px Monaco, Menlo, "Inconsolata", Consolas, "Courier New", monospace; font-family: Menlo, Monaco, Consolas, "Inconsolata", "Courier New", monospace;
}
code, pre {
color: #333;
}
pre {
font-size: 15px;
} }
h1.fqn { h1.fqn {
font-size: 26px; font-size: 26px;
@ -215,6 +221,7 @@ nav, .content {
a { a {
text-decoration: none; text-decoration: none;
color: #000; color: #000;
background: transparent;
} }
.content a, .block a.current { font-weight: bold; } .content a, .block a.current { font-weight: bold; }