Skip to content

Commit f5a64a6

Browse files
committed
Auto merge of #28499 - semmaz:doc-anchor-fix, r=steveklabnik
This changes how rustic generate `id` and `href` attributes for section header anchor. Now they are more github-like. Also fixes breakage in docs caused by this and broken links in "Error Handling" section of book. r? @steveklabnik cc @alexcrichton
2 parents aed5c3a + 09c1ce1 commit f5a64a6

File tree

5 files changed

+93
-80
lines changed

5 files changed

+93
-80
lines changed

src/doc/style/errors/ergonomics.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ fn write_info(info: &Info) -> Result<(), IoError> {
5757
```
5858

5959
See
60-
[the `result` module documentation](https://doc.rust-lang.org/stable/std/result/index.html#the-try!-macro)
60+
[the `result` module documentation](https://doc.rust-lang.org/stable/std/result/index.html#the-try-macro)
6161
for more details.
6262

6363
### The `Result`-`impl` pattern [FIXME]

src/doc/style/features/traits/generics.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ explicitly implement to be used by this generic function.
2727
* _Inference_. Since the type parameters to generic functions can usually be
2828
inferred, generic functions can help cut down on verbosity in code where
2929
explicit conversions or other method calls would usually be necessary. See the
30-
[overloading/implicits use case](#use-case:-limited-overloading-and/or-implicit-conversions)
30+
[overloading/implicits use case](#use-case-limited-overloading-andor-implicit-conversions)
3131
below.
3232
* _Precise types_. Because generics give a _name_ to the specific type
3333
implementing a trait, it is possible to be precise about places where that
@@ -51,7 +51,7 @@ explicitly implement to be used by this generic function.
5151
a `Vec<T>` contains elements of a single concrete type (and, indeed, the
5252
vector representation is specialized to lay these out in line). Sometimes
5353
heterogeneous collections are useful; see
54-
[trait objects](#use-case:-trait-objects) below.
54+
[trait objects](#use-case-trait-objects) below.
5555
* _Signature verbosity_. Heavy use of generics can bloat function signatures.
5656
**[Ed. note]** This problem may be mitigated by some language improvements; stay tuned.
5757

src/doc/trpl/error-handling.md

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -24,28 +24,28 @@ systems may want to jump around.
2424
* [The Basics](#the-basics)
2525
* [Unwrapping explained](#unwrapping-explained)
2626
* [The `Option` type](#the-option-type)
27-
* [Composing `Option<T>` values](#composing-option<t>-values)
27+
* [Composing `Option<T>` values](#composing-optiont-values)
2828
* [The `Result` type](#the-result-type)
2929
* [Parsing integers](#parsing-integers)
3030
* [The `Result` type alias idiom](#the-result-type-alias-idiom)
31-
* [A brief interlude: unwrapping isn't evil](#a-brief-interlude:-unwrapping-isn't-evil)
31+
* [A brief interlude: unwrapping isn't evil](#a-brief-interlude-unwrapping-isn't-evil)
3232
* [Working with multiple error types](#working-with-multiple-error-types)
3333
* [Composing `Option` and `Result`](#composing-option-and-result)
3434
* [The limits of combinators](#the-limits-of-combinators)
3535
* [Early returns](#early-returns)
36-
* [The `try!` macro](#the-try!-macro)
36+
* [The `try!` macro](#the-try-macro)
3737
* [Defining your own error type](#defining-your-own-error-type)
3838
* [Standard library traits used for error handling](#standard-library-traits-used-for-error-handling)
3939
* [The `Error` trait](#the-error-trait)
4040
* [The `From` trait](#the-from-trait)
41-
* [The real `try!` macro](#the-real-try!-macro)
41+
* [The real `try!` macro](#the-real-try-macro)
4242
* [Composing custom error types](#composing-custom-error-types)
4343
* [Advice for library writers](#advice-for-library-writers)
44-
* [Case study: A program to read population data](#case-study:-a-program-to-read-population-data)
44+
* [Case study: A program to read population data](#case-study-a-program-to-read-population-data)
4545
* [Initial setup](#initial-setup)
4646
* [Argument parsing](#argument-parsing)
4747
* [Writing the logic](#writing-the-logic)
48-
* [Error handling with `Box<Error>`](#error-handling-with-box%3Cerror%3E)
48+
* [Error handling with `Box<Error>`](#error-handling-with-boxerror)
4949
* [Reading from stdin](#reading-from-stdin)
5050
* [Error handling with a custom type](#error-handling-with-a-custom-type)
5151
* [Adding functionality](#adding-functionality)
@@ -87,7 +87,7 @@ thread '<main>' panicked at 'Invalid number: 11', src/bin/panic-simple.rs:5
8787
Here's another example that is slightly less contrived. A program that accepts
8888
an integer as an argument, doubles it and prints it.
8989

90-
<a name="code-unwrap-double"></a>
90+
<span id="code-unwrap-double"></span>
9191

9292
```rust,should_panic
9393
use std::env;
@@ -139,7 +139,7 @@ system is an important concept because it will cause the compiler to force the
139139
programmer to handle that absence. Let's take a look at an example that tries
140140
to find a character in a string:
141141

142-
<a name="code-option-ex-string-find"></a>
142+
<span id="code-option-ex-string-find"></span>
143143

144144
```rust
145145
// Searches `haystack` for the Unicode character `needle`. If one is found, the
@@ -186,7 +186,7 @@ But wait, what about `unwrap` used in [`unwrap-double`](#code-unwrap-double)?
186186
There was no case analysis there! Instead, the case analysis was put inside the
187187
`unwrap` method for you. You could define it yourself if you want:
188188

189-
<a name="code-option-def-unwrap"></a>
189+
<span id="code-option-def-unwrap"></span>
190190

191191
```rust
192192
enum Option<T> {
@@ -253,7 +253,7 @@ option is `None`, in which case, just return `None`.
253253
Rust has parametric polymorphism, so it is very easy to define a combinator
254254
that abstracts this pattern:
255255

256-
<a name="code-option-map"></a>
256+
<span id="code-option-map"></span>
257257

258258
```rust
259259
fn map<F, T, A>(option: Option<T>, f: F) -> Option<A> where F: FnOnce(T) -> A {
@@ -394,7 +394,7 @@ remove choices because they will panic if `Option<T>` is `None`.
394394
The `Result` type is also
395395
[defined in the standard library][6]:
396396

397-
<a name="code-result-def-1"></a>
397+
<span id="code-result-def"></span>
398398

399399
```rust
400400
enum Result<T, E> {
@@ -562,7 +562,7 @@ combinators that affect only the error type, such as
562562
### The `Result` type alias idiom
563563

564564
In the standard library, you may frequently see types like
565-
`Result<i32>`. But wait, [we defined `Result`](#code-result-def-1) to
565+
`Result<i32>`. But wait, [we defined `Result`](#code-result-def) to
566566
have two type parameters. How can we get away with only specifying
567567
one? The key is to define a `Result` type alias that *fixes* one of
568568
the type parameters to a particular type. Usually the fixed type is
@@ -672,7 +672,7 @@ with both an `Option` and a `Result`, the solution is *usually* to convert the
672672
(from `env::args()`) means the user didn't invoke the program correctly. We
673673
could just use a `String` to describe the error. Let's try:
674674

675-
<a name="code-error-double-string"></a>
675+
<span id="code-error-double-string"></span>
676676

677677
```rust
678678
use std::env;
@@ -906,7 +906,7 @@ seen above.
906906

907907
Here is a simplified definition of a `try!` macro:
908908

909-
<a nama name="code-try-def-simple"></a>
909+
<span id="code-try-def-simple"></span>
910910

911911
```rust
912912
macro_rules! try {
@@ -1168,7 +1168,7 @@ The `std::convert::From` trait is
11681168
[defined in the standard
11691169
library](../std/convert/trait.From.html):
11701170

1171-
<a name="code-from-def"></a>
1171+
<span id="code-from-def"></span>
11721172

11731173
```rust
11741174
trait From<T> {
@@ -1250,7 +1250,7 @@ macro_rules! try {
12501250
This is not its real definition. Its real definition is
12511251
[in the standard library](../std/macro.try!.html):
12521252

1253-
<a name="code-try-def"></a>
1253+
<span id="code-try-def"></span>
12541254

12551255
```rust
12561256
macro_rules! try {
@@ -1515,7 +1515,7 @@ and [`rustc-serialize`](https://crates.io/crates/rustc-serialize) crates.
15151515

15161516
We're not going to spend a lot of time on setting up a project with
15171517
Cargo because it is already covered well in [the Cargo
1518-
chapter](../book/hello-cargo) and [Cargo's documentation][14].
1518+
chapter](../book/hello-cargo.html) and [Cargo's documentation][14].
15191519

15201520
To get started from scratch, run `cargo new --bin city-pop` and make sure your
15211521
`Cargo.toml` looks something like this:
@@ -1573,7 +1573,7 @@ fn main() {
15731573
15741574
let mut opts = Options::new();
15751575
opts.optflag("h", "help", "Show this usage message.");
1576-
1576+
15771577
let matches = match opts.parse(&args[1..]) {
15781578
Ok(m) => { m }
15791579
Err(e) => { panic!(e.to_string()) }
@@ -1584,7 +1584,7 @@ fn main() {
15841584
}
15851585
let data_path = args[1].clone();
15861586
let city = args[2].clone();
1587-
1587+
15881588
// Do stuff with information
15891589
}
15901590
```
@@ -1647,27 +1647,27 @@ fn main() {
16471647
16481648
let mut opts = Options::new();
16491649
opts.optflag("h", "help", "Show this usage message.");
1650-
1650+
16511651
let matches = match opts.parse(&args[1..]) {
16521652
Ok(m) => { m }
16531653
Err(e) => { panic!(e.to_string()) }
16541654
};
1655-
1655+
16561656
if matches.opt_present("h") {
16571657
print_usage(&program, opts);
16581658
return;
16591659
}
1660-
1660+
16611661
let data_file = args[1].clone();
16621662
let data_path = Path::new(&data_file);
16631663
let city = args[2].clone();
1664-
1664+
16651665
let file = fs::File::open(data_path).unwrap();
16661666
let mut rdr = csv::Reader::from_reader(file);
1667-
1667+
16681668
for row in rdr.decode::<Row>() {
16691669
let row = row.unwrap();
1670-
1670+
16711671
if row.city == city {
16721672
println!("{}, {}: {:?}",
16731673
row.city, row.country,
@@ -1773,7 +1773,7 @@ fn main() {
17731773
print_usage(&program, opts);
17741774
return;
17751775
}
1776-
1776+
17771777
let data_file = args[1].clone();
17781778
let data_path = Path::new(&data_file);
17791779
let city = args[2].clone();
@@ -1882,7 +1882,7 @@ opts.optflag("h", "help", "Show this usage message.");
18821882
...
18831883
let file = matches.opt_str("f");
18841884
let data_file = file.as_ref().map(Path::new);
1885-
1885+
18861886
let city = if !matches.free.is_empty() {
18871887
matches.free[0].clone()
18881888
} else {

0 commit comments

Comments
 (0)