Skip to content

Commit 7541f82

Browse files
committed
Fix dead links in the guide and reorganize
1 parent 483fca9 commit 7541f82

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+112
-669
lines changed

mk/docs.mk

+2-3
Original file line numberDiff line numberDiff line change
@@ -275,9 +275,8 @@ endif
275275
docs: $(DOC_TARGETS)
276276
compiler-docs: $(COMPILER_DOC_TARGETS)
277277

278-
trpl: tmp/trpl.ok
278+
trpl: doc/book/index.html
279279

280-
tmp/trpl.ok: $(RUSTBOOK_EXE) $(wildcard $(S)/src/doc/trpl/*.md)
280+
doc/book/index.html: $(RUSTBOOK_EXE) $(wildcard $(S)/src/doc/trpl/*.md)
281281
$(Q)rm -rf doc/book
282282
$(Q)$(RUSTBOOK) build $(S)src/doc/trpl doc/book
283-
$(Q)touch $@

mk/tests.mk

+2-2
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,8 @@ endef
156156

157157
$(foreach doc,$(DOCS), \
158158
$(eval $(call DOCTEST,md-$(doc),$(S)src/doc/$(doc).md)))
159-
$(foreach file,$(wildcard $(S)src/doc/trpl/src/*), \
160-
$(eval $(call DOCTEST,$(file:$(S)src/doc/trpl/src/%.md=trpl-%),$(file))))
159+
$(foreach file,$(wildcard $(S)src/doc/trpl/*.md), \
160+
$(eval $(call DOCTEST,$(file:$(S)src/doc/trpl/%.md=trpl-%),$(file))))
161161

162162
######################################################################
163163
# Main test targets

src/doc/trpl/SUMMARY.md

+34-33
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,36 @@
11
# Summary
22

3-
* [I: The Basics](src/basic.md)
4-
* [Installing Rust](src/installing-rust.md)
5-
* [Hello, world!](src/hello-world.md)
6-
* [Hello, Cargo!](src/hello-cargo.md)
7-
* [Variable Bindings](src/variable-bindings.md)
8-
* [If](src/if.md)
9-
* [Functions](src/functions.md)
10-
* [Comments](src/comments.md)
11-
* [Compound Data Types](src/compound-data-types.md)
12-
* [Match](src/match.md)
13-
* [Looping](src/looping.md)
14-
* [Strings](src/strings.md)
15-
* [Arrays, Vectors, and Slices](src/arrays-vectors-and-slices.md)
16-
* [Standard Input](src/standard-input.md)
17-
* [Guessing Game](src/guessing-game.md)
18-
* [II: Intermedite Rust](src/intermediate.md)
19-
* [Crates and Modules](src/crates-and-modules.md)
20-
* [Testing](src/testing.md)
21-
* [Pointers](src/pointers.md)
22-
* [Patterns](src/patterns.md)
23-
* [Method Syntax](src/method-syntax.md)
24-
* [Closures](src/closures.md)
25-
* [Iterators](src/iterators.md)
26-
* [Generics](src/generics.md)
27-
* [Traits](src/traits.md)
28-
* [Tasks](src/tasks.md)
29-
* [Error Handling](src/error-handling.md)
30-
* [III: Advanced Topics](src/advanced.md)
31-
* [FFI](src/ffi.md)
32-
* [Unsafe Code](src/unsafe.md)
33-
* [Macros](src/macros.md)
34-
* [Compiler Plugins](src/plugins.md)
35-
* [Conclusion](src/conclusion.md)
3+
* [I: The Basics](basic.md)
4+
* [Installing Rust](installing-rust.md)
5+
* [Hello, world!](hello-world.md)
6+
* [Hello, Cargo!](hello-cargo.md)
7+
* [Variable Bindings](variable-bindings.md)
8+
* [If](if.md)
9+
* [Functions](functions.md)
10+
* [Comments](comments.md)
11+
* [Compound Data Types](compound-data-types.md)
12+
* [Match](match.md)
13+
* [Looping](looping.md)
14+
* [Strings](strings.md)
15+
* [Arrays, Vectors, and Slices](arrays-vectors-and-slices.md)
16+
* [Standard Input](standard-input.md)
17+
* [Guessing Game](guessing-game.md)
18+
* [II: Intermediate Rust](intermediate.md)
19+
* [Crates and Modules](crates-and-modules.md)
20+
* [Testing](testing.md)
21+
* [Pointers](pointers.md)
22+
* [Ownership](ownership.md)
23+
* [Patterns](patterns.md)
24+
* [Method Syntax](method-syntax.md)
25+
* [Closures](closures.md)
26+
* [Iterators](iterators.md)
27+
* [Generics](generics.md)
28+
* [Traits](traits.md)
29+
* [Tasks](tasks.md)
30+
* [Error Handling](error-handling.md)
31+
* [III: Advanced Topics](advanced.md)
32+
* [FFI](ffi.md)
33+
* [Unsafe Code](unsafe.md)
34+
* [Macros](macros.md)
35+
* [Compiler Plugins](plugins.md)
36+
* [Conclusion](conclusion.md)
File renamed without changes.

src/doc/trpl/src/arrays-vectors-and-slices.md renamed to src/doc/trpl/arrays-vectors-and-slices.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Arrays, Vectors, and Slices
1+
% Arrays, Vectors, and Slices
22

33
Like many programming languages, Rust has list types to represent a sequence of
44
things. The most basic is the **array**, a fixed-size list of elements of the
@@ -48,7 +48,7 @@ errant access is the source of many bugs in other systems programming
4848
languages.
4949

5050
A **vector** is a dynamic or "growable" array, implemented as the standard
51-
library type [`Vec<T>`](std/vec/) (we'll talk about what the `<T>` means
51+
library type [`Vec<T>`](../std/vec/) (we'll talk about what the `<T>` means
5252
later). Vectors are to arrays what `String` is to `&str`. You can create them
5353
with the `vec!` macro:
5454

File renamed without changes.

src/doc/trpl/src/closures.md renamed to src/doc/trpl/closures.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Closures
1+
% Closures
22

33
So far, we've made lots of functions in Rust, but we've given them all names.
44
Rust also allows us to create anonymous functions. Rust's anonymous

src/doc/trpl/src/comments.md renamed to src/doc/trpl/comments.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Comments
1+
% Comments
22

33
Now that we have some functions, it's a good idea to learn about comments.
44
Comments are notes that you leave to other programmers to help explain things
@@ -42,5 +42,5 @@ fn hello(name: &str) {
4242
When writing doc comments, adding sections for any arguments, return values,
4343
and providing some examples of usage is very, very helpful.
4444

45-
You can use the [`rustdoc`](rustdoc.html) tool to generate HTML documentation
45+
You can use the [`rustdoc`](../rustdoc.html) tool to generate HTML documentation
4646
from these doc comments.

src/doc/trpl/src/compound-data-types.md renamed to src/doc/trpl/compound-data-types.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Compound Data Types
1+
% Compound Data Types
22

33
Rust, like many programming languages, has a number of different data types
44
that are built-in. You've already done some simple work with integers and
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/doc/trpl/src/functions.md renamed to src/doc/trpl/functions.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Functions
1+
% Functions
22

33
You've already seen one function so far, the `main` function:
44

File renamed without changes.

src/doc/trpl/src/guessing-game.md renamed to src/doc/trpl/guessing-game.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Guessing Game
1+
% Guessing Game
22

33
Okay! We've got the basics of Rust down. Let's write a bigger program.
44

@@ -108,12 +108,12 @@ we do know that Rust has random number generation, but we don't know how to
108108
use it.
109109

110110
Enter the docs. Rust has a page specifically to document the standard library.
111-
You can find that page [here](std/index.html). There's a lot of information on
111+
You can find that page [here](../std/index.html). There's a lot of information on
112112
that page, but the best part is the search bar. Right up at the top, there's
113113
a box that you can enter in a search term. The search is pretty primitive
114114
right now, but is getting better all the time. If you type 'random' in that
115-
box, the page will update to [this one](std/index.html?search=random). The very
116-
first result is a link to [`std::rand::random`](std/rand/fn.random.html). If we
115+
box, the page will update to [this one](../std/index.html?search=random). The very
116+
first result is a link to [`std::rand::random`](../std/rand/fn.random.html). If we
117117
click on that result, we'll be taken to its documentation page.
118118

119119
This page shows us a few things: the type signature of the function, some

src/doc/trpl/src/hello-cargo.md renamed to src/doc/trpl/hello-cargo.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Hello, Cargo!
1+
% Hello, Cargo!
22

33
[Cargo](http://crates.io) is a tool that Rustaceans use to help manage their
44
Rust projects. Cargo is currently in an alpha state, just like Rust, and so it

src/doc/trpl/src/hello-world.md renamed to src/doc/trpl/hello-world.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Hello, world!
1+
% Hello, world!
22

33
Now that you have Rust installed, let's write your first Rust program. It's
44
traditional to make your first program in any new language one that prints the

src/doc/trpl/src/if.md renamed to src/doc/trpl/if.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# `if`
1+
% `if`
22

33
Rust's take on `if` is not particularly complex, but it's much more like the
44
`if` you'll find in a dynamically typed language than in a more traditional

src/doc/trpl/src/installing-rust.md renamed to src/doc/trpl/installing-rust.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Installing Rust
1+
% Installing Rust
22

33
The first step to using Rust is to install it! There are a number of ways to
44
install Rust, but the easiest is to use the `rustup` script. If you're on
File renamed without changes.

src/doc/trpl/src/iterators.md renamed to src/doc/trpl/iterators.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -336,4 +336,4 @@ can help you with. There are a number of really useful iterators, and you can
336336
write your own as well. Iterators provide a safe, efficient way to manipulate
337337
all kinds of lists. They're a little unusual at first, but if you play with
338338
them, you'll get hooked. For a full list of the different iterators and
339-
consumers, check out the [iterator module documentation](std/iter/index.html).
339+
consumers, check out the [iterator module documentation](../std/iter/index.html).

src/doc/trpl/src/looping.md renamed to src/doc/trpl/looping.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Looping
1+
% Looping
22

33
Looping is the last basic construct that we haven't learned yet in Rust. Rust has
44
two main looping constructs: `for` and `while`.

src/doc/trpl/src/macros.md renamed to src/doc/trpl/macros.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ When this library is loaded with `#[use_macros] extern crate`, only `m2` will
507507
be imported.
508508

509509
The Rust Reference has a [listing of macro-related
510-
attributes](reference.html#macro--and-plugin-related-attributes).
510+
attributes](../reference.html#macro--and-plugin-related-attributes).
511511

512512
# The variable `$crate`
513513

@@ -567,7 +567,7 @@ intermediate states out, and passing the flag `--pretty expanded` as a
567567
command-line argument to the compiler will show the result of expansion.
568568

569569
If Rust's macro system can't do what you need, you may want to write a
570-
[compiler plugin](guide-plugin.html) instead. Compared to `macro_rules!`
570+
[compiler plugin](plugin.html) instead. Compared to `macro_rules!`
571571
macros, this is significantly more work, the interfaces are much less stable,
572572
and the warnings about debugging apply ten-fold. In exchange you get the
573573
flexibility of running arbitrary Rust code within the compiler. Syntax

src/doc/trpl/src/match.md renamed to src/doc/trpl/match.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Match
1+
% Match
22

33
Often, a simple `if`/`else` isn't enough, because you have more than two
44
possible options. Also, `else` conditions can get incredibly complicated, so
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/doc/trpl/src/plugins.md renamed to src/doc/trpl/plugins.md

+23-24
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,20 @@
55
<p>
66
<b>Warning:</b> Plugins are an advanced, unstable feature! For many details,
77
the only available documentation is the <a
8-
href="syntax/index.html"><code>libsyntax</code></a> and <a
9-
href="rustc/index.html"><code>librustc</code></a> API docs, or even the source
8+
href="../syntax/index.html"><code>libsyntax</code></a> and <a
9+
href="../rustc/index.html"><code>librustc</code></a> API docs, or even the source
1010
code itself. These internal compiler APIs are also subject to change at any
1111
time.
1212
</p>
1313

1414
<p>
1515
For defining new syntax it is often much easier to use Rust's <a
16-
href="guide-macros.html">built-in macro system</a>.
16+
href="macros.html">built-in macro system</a>.
1717
</p>
1818

1919
<p style="margin-bottom: 0">
2020
The code in this document uses language features not covered in the Rust
21-
Guide. See the <a href="reference.html">Reference Manual</a> for more
21+
Guide. See the <a href="../reference.html">Reference Manual</a> for more
2222
information.
2323
</p>
2424

@@ -32,19 +32,19 @@ extend the compiler's behavior with new syntax extensions, lint checks, etc.
3232
A plugin is a dynamic library crate with a designated "registrar" function that
3333
registers extensions with `rustc`. Other crates can use these extensions by
3434
loading the plugin crate with `#[plugin] extern crate`. See the
35-
[`rustc::plugin`](rustc/plugin/index.html) documentation for more about the
35+
[`rustc::plugin`](../rustc/plugin/index.html) documentation for more about the
3636
mechanics of defining and loading a plugin.
3737

3838
Arguments passed as `#[plugin=...]` or `#[plugin(...)]` are not interpreted by
3939
rustc itself. They are provided to the plugin through the `Registry`'s [`args`
40-
method](rustc/plugin/registry/struct.Registry.html#method.args).
40+
method](../rustc/plugin/registry/struct.Registry.html#method.args).
4141

4242
# Syntax extensions
4343

4444
Plugins can extend Rust's syntax in various ways. One kind of syntax extension
4545
is the procedural macro. These are invoked the same way as [ordinary
46-
macros](guide-macros.html), but the expansion is performed by arbitrary Rust
47-
code that manipulates [syntax trees](syntax/ast/index.html) at
46+
macros](macros.html), but the expansion is performed by arbitrary Rust
47+
code that manipulates [syntax trees](../syntax/ast/index.html) at
4848
compile time.
4949

5050
Let's write a plugin
@@ -126,14 +126,13 @@ The advantages over a simple `fn(&str) -> uint` are:
126126
a way to define new literal syntax for any data type.
127127

128128
In addition to procedural macros, you can define new
129-
[`deriving`](reference.html#deriving)-like attributes and other kinds of
129+
[`deriving`](../reference.html#deriving)-like attributes and other kinds of
130130
extensions. See
131-
[`Registry::register_syntax_extension`](rustc/plugin/registry/struct.Registry.html#method.register_syntax_extension)
131+
[`Registry::register_syntax_extension`](../rustc/plugin/registry/struct.Registry.html#method.register_syntax_extension)
132132
and the [`SyntaxExtension`
133133
enum](http://doc.rust-lang.org/syntax/ext/base/enum.SyntaxExtension.html). For
134134
a more involved macro example, see
135-
[`src/libregex_macros/lib.rs`](https://github.com/rust-lang/rust/blob/master/src/libregex_macros/lib.rs)
136-
in the Rust distribution.
135+
[`regex_macros`](https://github.com/rust-lang/regex/blob/master/regex_macros/src/lib.rs).
137136

138137

139138
## Tips and tricks
@@ -147,7 +146,7 @@ variables of the same name (but different syntax contexts) are in play
147146
in the same scope. In this case `--pretty expanded,hygiene` will tell
148147
you about the syntax contexts.
149148

150-
You can use [`syntax::parse`](syntax/parse/index.html) to turn token trees into
149+
You can use [`syntax::parse`](../syntax/parse/index.html) to turn token trees into
151150
higher-level syntax elements like expressions:
152151

153152
```ignore
@@ -163,31 +162,31 @@ Looking through [`libsyntax` parser
163162
code](https://github.com/rust-lang/rust/blob/master/src/libsyntax/parse/parser.rs)
164163
will give you a feel for how the parsing infrastructure works.
165164

166-
Keep the [`Span`s](syntax/codemap/struct.Span.html) of
165+
Keep the [`Span`s](../syntax/codemap/struct.Span.html) of
167166
everything you parse, for better error reporting. You can wrap
168-
[`Spanned`](syntax/codemap/struct.Spanned.html) around
167+
[`Spanned`](../syntax/codemap/struct.Spanned.html) around
169168
your custom data structures.
170169

171170
Calling
172-
[`ExtCtxt::span_fatal`](syntax/ext/base/struct.ExtCtxt.html#method.span_fatal)
171+
[`ExtCtxt::span_fatal`](../syntax/ext/base/struct.ExtCtxt.html#method.span_fatal)
173172
will immediately abort compilation. It's better to instead call
174-
[`ExtCtxt::span_err`](syntax/ext/base/struct.ExtCtxt.html#method.span_err)
173+
[`ExtCtxt::span_err`](../syntax/ext/base/struct.ExtCtxt.html#method.span_err)
175174
and return
176-
[`DummyResult`](syntax/ext/base/struct.DummyResult.html),
175+
[`DummyResult`](../syntax/ext/base/struct.DummyResult.html),
177176
so that the compiler can continue and find further errors.
178177

179178
The example above produced an integer literal using
180-
[`AstBuilder::expr_uint`](syntax/ext/build/trait.AstBuilder.html#tymethod.expr_uint).
179+
[`AstBuilder::expr_uint`](../syntax/ext/build/trait.AstBuilder.html#tymethod.expr_uint).
181180
As an alternative to the `AstBuilder` trait, `libsyntax` provides a set of
182-
[quasiquote macros](syntax/ext/quote/index.html). They are undocumented and
181+
[quasiquote macros](../syntax/ext/quote/index.html). They are undocumented and
183182
very rough around the edges. However, the implementation may be a good
184183
starting point for an improved quasiquote as an ordinary plugin library.
185184

186185

187186
# Lint plugins
188187

189188
Plugins can extend [Rust's lint
190-
infrastructure](reference.html#lint-check-attributes) with additional checks for
189+
infrastructure](../reference.html#lint-check-attributes) with additional checks for
191190
code style, safety, etc. You can see
192191
[`src/test/auxiliary/lint_plugin_test.rs`](https://github.com/rust-lang/rust/blob/master/src/test/auxiliary/lint_plugin_test.rs)
193192
for a full example, the core of which is reproduced here:
@@ -236,11 +235,11 @@ foo.rs:4 fn lintme() { }
236235
The components of a lint plugin are:
237236

238237
* one or more `declare_lint!` invocations, which define static
239-
[`Lint`](rustc/lint/struct.Lint.html) structs;
238+
[`Lint`](../rustc/lint/struct.Lint.html) structs;
240239

241240
* a struct holding any state needed by the lint pass (here, none);
242241

243-
* a [`LintPass`](rustc/lint/trait.LintPass.html)
242+
* a [`LintPass`](../rustc/lint/trait.LintPass.html)
244243
implementation defining how to check each syntax element. A single
245244
`LintPass` may call `span_lint` for several different `Lint`s, but should
246245
register them all through the `get_lints` method.
@@ -252,7 +251,7 @@ mostly use the same infrastructure as lint plugins, and provide examples of how
252251
to access type information.
253252

254253
Lints defined by plugins are controlled by the usual [attributes and compiler
255-
flags](reference.html#lint-check-attributes), e.g. `#[allow(test_lint)]` or
254+
flags](../reference.html#lint-check-attributes), e.g. `#[allow(test_lint)]` or
256255
`-A test-lint`. These identifiers are derived from the first argument to
257256
`declare_lint!`, with appropriate case and punctuation conversion.
258257

src/doc/trpl/src/pointers.md renamed to src/doc/trpl/pointers.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ test.rs:4 let y = &x;
409409

410410
As you might guess, this kind of analysis is complex for a human, and therefore
411411
hard for a computer, too! There is an entire [guide devoted to references, ownership,
412-
and lifetimes](guide-ownership.html) that goes into this topic in
412+
and lifetimes](ownership.html) that goes into this topic in
413413
great detail, so if you want the full details, check that out.
414414

415415
## Best practices
@@ -542,7 +542,7 @@ with some improvements:
542542
4. Rust enforces that no other writeable pointers alias to this heap memory,
543543
which means writing to an invalid pointer is not possible.
544544

545-
See the section on references or the [ownership guide](guide-ownership.html)
545+
See the section on references or the [ownership guide](ownership.html)
546546
for more detail on how lifetimes work.
547547

548548
Using boxes and references together is very common. For example:
@@ -780,6 +780,6 @@ Here's a quick rundown of Rust's pointer types:
780780

781781
# Related resources
782782

783-
* [API documentation for Box](std/boxed/index.html)
784-
* [Ownership guide](guide-ownership.html)
783+
* [API documentation for Box](../std/boxed/index.html)
784+
* [Ownership guide](ownership.html)
785785
* [Cyclone paper on regions](http://www.cs.umd.edu/projects/cyclone/papers/cyclone-regions.pdf), which inspired Rust's lifetime system

0 commit comments

Comments
 (0)