Skip to content

Commit f006ea9

Browse files
committed
Extract all links from paragraphs
1 parent f15206a commit f006ea9

12 files changed

+122
-80
lines changed

_src/container-attrs.md

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -51,23 +51,24 @@
5151
- ##### `#[serde(tag = "type")]` {#tag}
5252

5353
On an enum: Use the internally tagged enum representation, with the given tag.
54-
See [enum representations](enum-representations.md) for details on this
55-
representation.
54+
See [enum representations] for details on this representation.
5655

5756
On a struct with named fields: Serialize the struct's name (or value of
5857
`serde(rename)`) as a field with the given key, in front of all the real
5958
fields of the struct.
6059

60+
[enum representations]: enum-representations.md
61+
6162
- ##### `#[serde(tag = "t", content = "c")]` {#tag--content}
6263

6364
Use the adjacently tagged enum representation for this enum, with the given
64-
field names for the tag and content. See [enum
65-
representations](enum-representations.md) for details on this representation.
65+
field names for the tag and content. See [enum representations] for details on
66+
this representation.
6667

6768
- ##### `#[serde(untagged)]` {#untagged}
6869

69-
Use the untagged enum representation for this enum. See [enum
70-
representations](enum-representations.md) for details on this representation.
70+
Use the untagged enum representation for this enum. See [enum representations]
71+
for details on this representation.
7172

7273
- ##### `#[serde(variant_identifier)]` {#variant_identifier}
7374

@@ -78,11 +79,14 @@
7879

7980
- ##### `#[serde(field_identifier)]` {#field_identifier}
8081

81-
Identical to [`variant_identifier`](#variant_identifier), but also allows for
82-
the last variant to be a newtype variant, which will be used if none of the
83-
other variants match (similar to [`#[serde(other)]`](variant-attrs.md#other)).
84-
Like `variant_identifier`, this forces the enum to always be represented as a
85-
string, regardless of the underlying data format's representation of enums.
82+
Identical to [`variant_identifier`], but also allows for the last variant to
83+
be a newtype variant, which will be used if none of the other variants match
84+
(similar to [`#[serde(other)]`]). Like `variant_identifier`, this forces the
85+
enum to always be represented as a string, regardless of the underlying data
86+
format's representation of enums.
87+
88+
[`variant_identifier`]: #variant_identifier
89+
[`#[serde(other)`]: variant-attrs.md#other
8690

8791
- ##### `#[serde(bound = "T: MyTrait")]` {#bound}
8892

@@ -110,8 +114,9 @@
110114

111115
- ##### `#[serde(remote = "...")]` {#remote}
112116

113-
This is used for deriving `Serialize` and `Deserialize` for [remote
114-
types](remote-derive.md).
117+
This is used for deriving `Serialize` and `Deserialize` for [remote types].
118+
119+
[remote types]: remote-derive.md
115120

116121
- ##### `#[serde(transparent)]` {#transparent}
117122

_src/custom-date-format.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
# Date in a custom format
22

3-
This uses the [`chrono`](https://github.com/chronotope/chrono) crate to
4-
serialize and deserialize JSON data containing a custom date format. The `with`
5-
attribute is used to provide the logic for handling the custom representation.
3+
This uses the [`chrono`] crate to serialize and deserialize JSON data containing
4+
a custom date format. The `with` attribute is used to provide the logic for
5+
handling the custom representation.
6+
7+
[`chrono`]: https://github.com/chronotope/chrono
68

79
!PLAYGROUND 2ef7c347c76b030fe7e8c59ce9efccd3
810
```rust

_src/custom-serialization.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
# Custom serialization
22

3-
Serde's [derive macro](derive.md) through `#[derive(Serialize, Deserialize)]`
4-
provides reasonable default serialization behavior for structs and enums and it
5-
can be customized to some extent using [attributes](attributes.md). For unusual
6-
needs, Serde allows full customization of the serialization behavior by manually
7-
implementing [`Serialize`] and [`Deserialize`] traits for your type.
8-
3+
Serde's [derive macro] through `#[derive(Serialize, Deserialize)]` provides
4+
reasonable default serialization behavior for structs and enums and it can be
5+
customized to some extent using [attributes]. For unusual needs, Serde allows
6+
full customization of the serialization behavior by manually implementing
7+
[`Serialize`] and [`Deserialize`] traits for your type.
8+
9+
[derive macro]: derive.md
10+
[attributes]: attributes.md
911
[`Serialize`]: https://docs.rs/serde/1/serde/ser/trait.Serialize.html
1012
[`Deserialize`]: https://docs.rs/serde/1/serde/de/trait.Deserialize.html
1113

_src/derive.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ would use to automatically derive implementations of the built-in `Clone`,
1212
`Copy`, `Debug`, or other traits. It is able to generate implementations for
1313
most structs and enums including ones with elaborate generic types or trait
1414
bounds. On rare occasions, for an especially convoluted type you may need to
15-
[implement the traits manually](custom-serialization.md).
15+
[implement the traits manually].
16+
17+
[implement the traits manually]: custom-serialization.md
1618

1719
These derives require a Rust compiler version 1.31 or newer.
1820

_src/deserialize-struct.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Manually implementing Deserialize for a struct
22

3-
Only when [derive](derive.md) is not getting the job done.
3+
Only when [derive] is not getting the job done.
4+
5+
[derive]: derive.md
46

57
The `Deserialize` impl below corresponds to the following struct:
68

@@ -14,9 +16,11 @@ struct Duration {
1416
# fn main() {}
1517
```
1618

17-
Deserializing a struct is somewhat more complicated than [deserializing a
18-
map](deserialize-map.md) in order to avoid allocating a String to hold the field
19-
names. Instead there is a `Field` enum which is deserialized from a `&str`.
19+
Deserializing a struct is somewhat more complicated than [deserializing a map]
20+
in order to avoid allocating a String to hold the field names. Instead there is
21+
a `Field` enum which is deserialized from a `&str`.
22+
23+
[deserializing a map]: deserialize-map.md
2024

2125
The implementation supports two possible ways that a struct may be represented
2226
by a data format: as a seq like in Postcard, and as a map like in JSON.

_src/examples.md

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
# Examples
22

33
**[Structs and enums in JSON](json.md)**: The representation chosen by
4-
[`serde_json`](https://github.com/serde-rs/json) for structs and enums. Other
5-
human-readable data formats are encouraged to follow an analogous approach where
6-
possible.
4+
[`serde_json`] for structs and enums. Other human-readable data formats are
5+
encouraged to follow an analogous approach where possible.
6+
7+
[`serde_json`]: https://github.com/serde-rs/json
78

89
**[Enum representations](enum-representations.md)**: Externally tagged,
910
internally tagged, adjacently tagged, and untagged ways of representing an enum
@@ -43,17 +44,21 @@ the `#[serde(rename)]` attribute.
4344
**[Discarding data](ignored-any.md)**: Using `IgnoredAny` to efficiently discard
4445
data from a deserializer.
4546

46-
**[Transcode one format into another](transcode.md)**: Use the
47-
[serde-transcode](https://github.com/sfackler/serde-transcode) crate to stream
48-
input in one format to output in another format efficiently.
47+
**[Transcode one format into another](transcode.md)**: Use the [serde-transcode]
48+
crate to stream input in one format to output in another format efficiently.
49+
50+
[serde-transcode]: https://github.com/sfackler/serde-transcode
4951

5052
**[Deserialize either a string or a struct](string-or-struct.md)**: The
51-
[`docker-compose.yml`](https://docs.docker.com/compose/compose-file/#/build)
52-
configuration file has a "build" key which can be either a string or a struct.
53+
[`docker-compose.yml`] configuration file has a "build" key which can be either
54+
a string or a struct.
55+
56+
[`docker-compose.yml`]: https://docs.docker.com/compose/compose-file/#/build
5357

5458
**[Convert error types](convert-error.md)**: Map a Serde error from some format
5559
into a Serde error for some other format using `Error::custom`.
5660

57-
**[Date in a custom format](custom-date-format.md)**: Handle a
58-
[`chrono`](https://github.com/chronotope/chrono) `DateTime` formatted with a
59-
custom string representation.
61+
**[Date in a custom format](custom-date-format.md)**: Handle a [`chrono`]
62+
`DateTime` formatted with a custom string representation.
63+
64+
[`chrono`]: https://github.com/chronotope/chrono

_src/field-attrs.md

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,17 @@
33
- ##### `#[serde(rename = "name")]` {#rename}
44

55
Serialize and deserialize this field with the given name instead of its Rust
6-
name. This is useful for [serializing fields as camelCase](attr-rename.md) or
7-
serializing fields with names that are reserved Rust keywords.
6+
name. This is useful for [serializing fields as camelCase] or serializing
7+
fields with names that are reserved Rust keywords.
88

99
Allows specifying independent names for serialization vs deserialization:
1010

1111
- `#[serde(rename(serialize = "ser_name"))]`
1212
- `#[serde(rename(deserialize = "de_name"))]`
1313
- `#[serde(rename(serialize = "ser_name", deserialize = "de_name"))]`
1414

15+
[serializing fields as camelCase]: attr-rename.md
16+
1517
- ##### `#[serde(alias = "name")]` {#alias}
1618

1719
Deserialize this field from the given name *or* from its Rust name. May be
@@ -35,8 +37,10 @@
3537
This removes one level of structure between the serialized representation and
3638
the Rust data structure representation. It can be used for factoring common
3739
keys into a shared structure, or for capturing remaining fields into a map
38-
with arbitrary string keys. The [struct flattening](attr-flatten.md) page
39-
provides some examples.
40+
with arbitrary string keys. The [struct flattening] page provides some
41+
examples.
42+
43+
[struct flattening]: attr-flatten.md
4044

4145
*Note:* this attribute is not supported in combination with structs that use
4246
[`deny_unknown_fields`]. Neither the outer nor inner flattened struct should
@@ -94,7 +98,9 @@
9498
- ##### `#[serde(borrow)]` and `#[serde(borrow = "'a + 'b + ...")]` {#borrow}
9599

96100
Borrow data for this field from the deserializer by using zero-copy
97-
deserialization. See [this example](lifetimes.md#borrowing-data-in-a-derived-impl).
101+
deserialization. See [this example][borrowing-data].
102+
103+
[borrowing-data]: lifetimes.md#borrowing-data-in-a-derived-impl
98104

99105
- ##### `#[serde(bound = "T: MyTrait")]` {#bound}
100106

@@ -109,5 +115,7 @@
109115

110116
- ##### `#[serde(getter = "...")]` {#getter}
111117

112-
This is used when deriving `Serialize` for a [remote type](remote-derive.md)
113-
that has one or more private fields.
118+
This is used when deriving `Serialize` for a [remote type] that has one or
119+
more private fields.
120+
121+
[remote type]: remote-derive.md

_src/json.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22

33
A Serde `Serializer` is responsible for selecting the convention by which Rust
44
structs and enums are represented in that format. Here are the conventions
5-
selected by the [`serde_json`](https://github.com/serde-rs/json) data format.
6-
For consistency, other human-readable formats are encouraged to develop
7-
analogous conventions where possible.
5+
selected by the [`serde_json`] data format. For consistency, other
6+
human-readable formats are encouraged to develop analogous conventions where
7+
possible.
8+
9+
[`serde_json`]: https://github.com/serde-rs/json
810

911
```rust
1012
# #![allow(dead_code, unused_variables)]

_src/string-or-struct.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
# Deserialize either a string or a struct
22

3-
The [`docker-compose.yml`](https://docs.docker.com/compose/compose-file/#/build)
4-
configuration file has a "build" key which can be either a string or a struct.
3+
The [`docker-compose.yml`] configuration file has a "build" key which can be
4+
either a string or a struct.
5+
6+
[`docker-compose.yml`]: https://docs.docker.com/compose/compose-file/#/build
57

68
```yaml
79
build: ./dir
@@ -19,9 +21,10 @@ The configuration file uses the same pattern in other places as well, typically
1921
where a previously existing string field has been expanded to handle more
2022
complex data.
2123
22-
We can use Rust's
23-
[`FromStr`](https://doc.rust-lang.org/std/str/trait.FromStr.html) trait and
24-
Serde's `deserialize_with` attribute to handle this pattern in a general way.
24+
We can use Rust's [`FromStr`] trait and Serde's `deserialize_with` attribute to
25+
handle this pattern in a general way.
26+
27+
[`FromStr`]: https://doc.rust-lang.org/std/str/trait.FromStr.html
2528

2629
```rust
2730
use std::collections::BTreeMap as Map;

_src/transcode.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
# Transcode one format into another
22

3-
The [`serde-transcode`](https://github.com/sfackler/serde-transcode) crate
4-
provides functionality to "transcode" from an arbitrary Serde `Deserializer` to
5-
an arbitrary Serde `Serializer` without needing to collect the entire input into
6-
an intermediate form in memory. This provides a fully general way to convert any
7-
self-describing Serde data format into any other Serde data format in a
8-
memory-efficient streaming way.
3+
The [`serde-transcode`] crate provides functionality to "transcode" from an
4+
arbitrary Serde `Deserializer` to an arbitrary Serde `Serializer` without
5+
needing to collect the entire input into an intermediate form in memory. This
6+
provides a fully general way to convert any self-describing Serde data format
7+
into any other Serde data format in a memory-efficient streaming way.
8+
9+
[`serde-transcode`]: https://github.com/sfackler/serde-transcode
910

1011
For example you could transcode a stream of JSON data into a stream of CBOR
1112
data, or transcode unformatted JSON into its pretty-printed form.
1213

13-
This example implements the equivalent of Go's
14-
[`json.Compact`](https://golang.org/pkg/encoding/json/#Compact) function which
14+
This example implements the equivalent of Go's [`json.Compact`] function which
1515
removes insignificant whitespace from a JSON string in a streaming way.
1616

17+
[`json.Compact`]: https://golang.org/pkg/encoding/json/#Compact
18+
1719
```rust
1820
use std::io;
1921

0 commit comments

Comments
 (0)