mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 16:24:46 +00:00
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:
commit
49c6ae10cb
1
doc/favicon.inc
Normal file
1
doc/favicon.inc
Normal file
@ -0,0 +1 @@
|
||||
<link rel="shortcut icon" href="http://www.rust-lang.org/favicon.ico" />
|
@ -4,4 +4,9 @@
|
||||
display: block;
|
||||
padding-left: 2em;
|
||||
}
|
||||
#influences blockquote p:last-child {
|
||||
display: block;
|
||||
line-height: 1.428571429;
|
||||
color: #999999;
|
||||
}
|
||||
</style>
|
11
doc/rust.css
11
doc/rust.css
@ -2,7 +2,7 @@
|
||||
* Copyright 2013 The Rust Project Developers. See the COPYRIGHT
|
||||
* file at the top-level directory of this distribution and at
|
||||
* 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
|
||||
* http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
@ -93,6 +93,7 @@ p {
|
||||
a {
|
||||
text-decoration: none;
|
||||
color: #428BCA;
|
||||
background: transparent;
|
||||
}
|
||||
a:hover, a:focus {
|
||||
color: #2A6496;
|
||||
@ -114,7 +115,7 @@ h5 a:link, h5 a:visited {color: black;}
|
||||
/* Code
|
||||
========================================================================== */
|
||||
pre, code {
|
||||
font-family: Monaco, Menlo, Consolas, "Courier New", monospace;
|
||||
font-family: Menlo, Monaco, Consolas, "Courier New", monospace;
|
||||
border-radius: 4px;
|
||||
}
|
||||
pre {
|
||||
@ -141,7 +142,7 @@ pre code {
|
||||
color: inherit;
|
||||
white-space: pre-wrap;
|
||||
background-color: transparent;
|
||||
border: 0;
|
||||
border-radius: 0;
|
||||
}
|
||||
|
||||
/* Code highlighting */
|
||||
@ -158,7 +159,7 @@ pre code {
|
||||
.cm-s-default span.cm-string {color: #a11;}
|
||||
.cm-s-default span.cm-string-2 {color: #f50;}
|
||||
.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-builtin {color: #30a;}
|
||||
.cm-s-default span.cm-bracket {color: #cc7;}
|
||||
@ -187,7 +188,7 @@ pre code {
|
||||
}
|
||||
#versioninfo a.hash {
|
||||
color: gray;
|
||||
font-size: 60%;
|
||||
font-size: 70%;
|
||||
}
|
||||
|
||||
blockquote {
|
||||
|
@ -210,10 +210,10 @@ solves the problem.
|
||||
|
||||
# Macro argument pattern matching
|
||||
|
||||
Now consider code like the following:
|
||||
|
||||
## Motivation
|
||||
|
||||
Now consider code like the following:
|
||||
|
||||
~~~~
|
||||
# enum t1 { good_1(t2, uint), bad_1 };
|
||||
# pub struct t2 { body: t3 }
|
||||
|
@ -27,7 +27,6 @@ $ rustc main.rs
|
||||
main.rs:1:0: 1:17 error: can't find crate for `hello`
|
||||
main.rs:1 extern mod hello;
|
||||
^~~~~~~~~~~~~~~~~
|
||||
|
||||
~~~~
|
||||
|
||||
This makes sense, as we haven't gotten it from anywhere yet! Luckily for us,
|
||||
|
@ -804,7 +804,7 @@ confusing numbers that correspond to different units.
|
||||
We've already seen several function definitions. Like all other static
|
||||
declarations, such as `type`, functions can be declared both at the
|
||||
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
|
||||
list of `expr: type` pairs separated by commas. An arrow `->`
|
||||
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
|
||||
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
|
||||
`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}
|
||||
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
|
||||
@ -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
|
||||
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
|
||||
@ -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.
|
||||
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.
|
||||
This enables you to, eg, pick a a crate based on it's version number, or to link an library under an
|
||||
different name. For example, this two mod statements would both accept and select the crate define above:
|
||||
This enables you to, e.g., pick a crate based on its version number, or link a library under a
|
||||
different name. For example, these two `mod` statements would both accept and select the crate define above:
|
||||
|
||||
~~~~ {.xfail-test}
|
||||
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,
|
||||
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;
|
||||
|
||||
fn main() {
|
||||
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.");
|
||||
}
|
||||
~~~
|
||||
|
151
mk/docs.mk
151
mk/docs.mk
@ -15,6 +15,10 @@
|
||||
DOCS :=
|
||||
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
|
||||
@ -28,6 +32,10 @@ doc/manual.inc: manual.inc
|
||||
@$(call E, cp: $@)
|
||||
$(Q)cp -a $< $@ 2> /dev/null
|
||||
|
||||
doc/favicon.inc: favicon.inc
|
||||
@$(call E, cp: $@)
|
||||
$(Q)cp -a $< $@ 2> /dev/null
|
||||
|
||||
ifeq ($(CFG_PANDOC),)
|
||||
$(info cfg: no pandoc found, omitting docs)
|
||||
NO_DOCS = 1
|
||||
@ -41,86 +49,49 @@ endif
|
||||
ifneq ($(NO_DOCS),1)
|
||||
|
||||
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: $@)
|
||||
$(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=$@
|
||||
$(CFG_PANDOC) $(HTML_OPTS) --include-in-header=doc/manual.inc --output=$@
|
||||
|
||||
DOCS += doc/rust.tex
|
||||
doc/rust.tex: rust.md doc/version.md
|
||||
@$(call E, pandoc: $@)
|
||||
$(Q)$(CFG_NODE) $(S)doc/prep.js $< | \
|
||||
"$(CFG_PANDOC)" \
|
||||
--standalone --toc \
|
||||
--number-sections \
|
||||
--include-before-body=doc/version.md \
|
||||
--from=markdown --to=latex \
|
||||
--output=$@
|
||||
$(CFG_PANDOC) $(TEX_OPTS) --output=$@
|
||||
|
||||
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: $@)
|
||||
$(Q)$(CFG_NODE) $(S)doc/prep.js --highlight $< | \
|
||||
"$(CFG_PANDOC)" \
|
||||
--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=$@
|
||||
$(CFG_PANDOC) $(EPUB_OPTS) --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
|
||||
doc/tutorial.tex: tutorial.md doc/version.md
|
||||
@$(call E, pandoc: $@)
|
||||
$(Q)$(CFG_NODE) $(S)doc/prep.js $< | \
|
||||
"$(CFG_PANDOC)" \
|
||||
--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=$@
|
||||
$(CFG_PANDOC) $(TEX_OPTS) --output=$@
|
||||
|
||||
DOCS += doc/tutorial.epub
|
||||
doc/tutorial.epub: 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=epub --css=rust.css \
|
||||
--include-before-body=doc/version_info.html \
|
||||
--output=$@
|
||||
$(CFG_PANDOC) $(EPUB_OPTS) --output=$@
|
||||
|
||||
|
||||
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=$@
|
||||
|
||||
DOCS += doc/tutorial-macros.html
|
||||
doc/tutorial-macros.html: tutorial-macros.md doc/version_info.html \
|
||||
doc/rust.css
|
||||
doc/tutorial-macros.html: tutorial-macros.md doc/version_info.html doc/rust.css \
|
||||
doc/favicon.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-before-body=doc/version_info.html \
|
||||
--output=$@
|
||||
$(CFG_PANDOC) $(HTML_OPTS) --output=$@
|
||||
|
||||
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: $@)
|
||||
$(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=$@
|
||||
$(CFG_PANDOC) $(HTML_OPTS) --output=$@
|
||||
|
||||
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: $@)
|
||||
$(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=$@
|
||||
$(CFG_PANDOC) $(HTML_OPTS) --output=$@
|
||||
|
||||
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: $@)
|
||||
$(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=$@
|
||||
$(CFG_PANDOC) $(HTML_OPTS) --output=$@
|
||||
|
||||
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: $@)
|
||||
$(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=$@
|
||||
$(CFG_PANDOC) $(HTML_OPTS) --output=$@
|
||||
|
||||
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: $@)
|
||||
$(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=$@
|
||||
$(CFG_PANDOC) $(HTML_OPTS) --output=$@
|
||||
|
||||
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: $@)
|
||||
$(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=$@
|
||||
$(CFG_PANDOC) $(HTML_OPTS) --output=$@
|
||||
|
||||
ifeq ($(CFG_PDFLATEX),)
|
||||
$(info cfg: no pdflatex found, omitting doc/rust.pdf)
|
||||
|
@ -43,7 +43,13 @@ h2 code, h3 code, h4 code {
|
||||
}
|
||||
|
||||
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 {
|
||||
font-size: 26px;
|
||||
@ -215,6 +221,7 @@ nav, .content {
|
||||
a {
|
||||
text-decoration: none;
|
||||
color: #000;
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
.content a, .block a.current { font-weight: bold; }
|
||||
|
Loading…
Reference in New Issue
Block a user