toolkit for mdBook [mirror of my GitHub repo] docs.tonywu.dev/mdbookkit/
permalinks rust-analyzer mdbook
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

docs: clean up

+116 -119
+3 -4
crates/mdbookkit/tests/snaps/rustdoc_link/supported-syntax.snap
··· 78 78 > ```md 79 79 > | Phantom type | variance of `T` | 80 80 > | :------------------------------------------------- | :---------------- | 81 - > | [`&'a mut T`][std::marker::PhantomData<&'a mut T>] | **inv**ariant | 81 + > | [`&'a mut T`][std::marker::PhantomData<&'a mut T>] | **in**variant | 82 82 > | [`fn(T)`][std::marker::PhantomData<fn(T)>] | **contra**variant | 83 83 > ``` 84 84 > 85 85 > | Phantom type | variance of `T` | 86 86 > | :------------------------------------------------- | :---------------- | 87 - > | [`&'a mut T`](https://doc.rust-lang.org/stable/core/marker/struct.PhantomData.html "std::marker::PhantomData<&'a mut T>") | **inv**ariant | 87 + > | [`&'a mut T`](https://doc.rust-lang.org/stable/core/marker/struct.PhantomData.html "std::marker::PhantomData<&'a mut T>") | **in**variant | 88 88 > | [`fn(T)`](https://doc.rust-lang.org/stable/core/marker/struct.PhantomData.html "std::marker::PhantomData<fn(T)>") | **contra**variant | 89 89 90 90 This includes if you use turbofish: ··· 163 163 > [`std::vec`], [`mod@std::vec`], and [`macro@std::vec`] all link to the `vec` _module_. 164 164 > ``` 165 165 > 166 - > [`std::vec`](https://doc.rust-lang.org/stable/alloc/vec/index.html "std::vec"), [`mod@std::vec`](https://doc.rust-lang.org/stable/alloc/vec/index.html "mod@std::vec"), and [`macro@std::vec`](https://doc.rust-lang.org/stable/alloc/vec/index.html "macro@std::vec") all link to the `vec` > 167 - > _module_. 166 + > [`std::vec`](https://doc.rust-lang.org/stable/alloc/vec/index.html "std::vec"), [`mod@std::vec`](https://doc.rust-lang.org/stable/alloc/vec/index.html "mod@std::vec"), and [`macro@std::vec`](https://doc.rust-lang.org/stable/alloc/vec/index.html "macro@std::vec") all link to the `vec` _module_. 168 167 169 168 Currently, duplicate names in Rust are allowed only if they correspond to items in 170 169 different [namespaces], for example, between macros and modules, and between struct
+106 -107
crates/mdbookkit/tests/snaps/rustdoc_link/supported-syntax.stderr.snap
··· 47 47 74 │ > ```md 48 48 75 │ > | Phantom type | variance of `T` | 49 49 76 │ > | :------------------------------------------------- | :---------------- | 50 - 77 │ > | [`&'a mut T`][std::marker::PhantomData<&'a mut T>] | **inv**ariant | 50 + 77 │ > | [`&'a mut T`][std::marker::PhantomData<&'a mut T>] | **in**variant | 51 51 78 │ > | [`fn(T)`][std::marker::PhantomData<fn(T)>] | **contra**variant | 52 52 79 │ > ``` 53 53 80 │ > 54 54 81 │ > | Phantom type | variance of `T` | 55 55 82 │ > | :------------------------------------------------- | :---------------- | 56 - 83 │ > | [`&'a mut T`][std::marker::PhantomData<&'a mut T>] | **inv**ariant | 56 + 83 │ > | [`&'a mut T`][std::marker::PhantomData<&'a mut T>] | **in**variant | 57 57 · ─────────────────────────┬──────────────────────── 58 58 · ╰── https://doc.rust-lang.org/stable/core/marker/struct.PhantomData.html 59 59 84 │ > | [`fn(T)`][std::marker::PhantomData<fn(T)>] | **contra**variant | ··· 160 160 159 │ > [`std::vec`], [`mod@std::vec`], and [`macro@std::vec`] all link to the `vec` _module_. 161 161 160 │ > ``` 162 162 161 │ > 163 - 162 │ > [`std::vec`], [`mod@std::vec`], and [`macro@std::vec`] all link to the `vec` > 163 + 162 │ > [`std::vec`], [`mod@std::vec`], and [`macro@std::vec`] all link to the `vec` _module_. 164 164 · ──────┬───── ────────┬─────── ─────────┬──────── 165 165 · │ │ ╰── https://doc.rust-lang.org/stable/alloc/vec/index.html 166 166 · │ ╰── https://doc.rust-lang.org/stable/alloc/vec/index.html 167 167 · ╰── https://doc.rust-lang.org/stable/alloc/vec/index.html 168 - 163 │ > _module_. 169 - 164 │ 170 - 165 │ Currently, duplicate names in Rust are allowed only if they correspond to items in 171 - 166 │ different [namespaces], for example, between macros and modules, and between struct 172 - 167 │ fields and methods — this is mostly covered by the function and macro syntax, described 173 - 168 │ [above](#functions-and-macros). 174 - 169 │ 175 - 170 │ If you encounter items that must be disambiguated using rustdoc's disambiguator syntax, 176 - 171 │ other than [the "special types" listed below](#special-types), please [file an 177 - 172 │ issue][gh-issues]! 178 - 173 │ 179 - 174 │ ## Special types 180 - 175 │ 181 - 176 │ > [!WARNING] 182 - 177 │ 183 - 178 │ There is **no support** on types whose syntax is not a path; they are currently not 184 - 179 │ parsed at all: 185 - 180 │ 186 - 181 │ > references `&T`, slices `[T]`, arrays `[T; N]`, tuples `(T1, T2)`, pointers like 187 - 182 │ > `*const T`, trait objects like `dyn Any`, and the never type `!` 188 - 183 │ 189 - 184 │ Note that such types can still be used as generic params, just not as standalone types. 190 - 185 │ 191 - 186 │ ## Struct fields 192 - 187 │ 193 - 188 │ > [!WARNING] 194 - 189 │ 195 - 190 │ Linking to struct fields is **not supported** yet. This is **incompatible** with 196 - 191 │ rustdoc. 197 - 192 │ 198 - 193 │ ## Markdown link syntax 199 - 194 │ 200 - 195 │ All Markdown link formats supported by rustdoc are supported: 201 - 196 │ 202 - 197 │ Linking with URL inlined: 203 - 198 │ 204 - 199 │ > ```md 205 - 200 │ > [The Option type](std::option::Option) 206 - 201 │ > ``` 207 - 202 │ > 208 - 203 │ > [The Option type](std::option::Option) 168 + 163 │ 169 + 164 │ Currently, duplicate names in Rust are allowed only if they correspond to items in 170 + 165 │ different [namespaces], for example, between macros and modules, and between struct 171 + 166 │ fields and methods — this is mostly covered by the function and macro syntax, described 172 + 167 │ [above](#functions-and-macros). 173 + 168 │ 174 + 169 │ If you encounter items that must be disambiguated using rustdoc's disambiguator syntax, 175 + 170 │ other than [the "special types" listed below](#special-types), please [file an 176 + 171 │ issue][gh-issues]! 177 + 172 │ 178 + 173 │ ## Special types 179 + 174 │ 180 + 175 │ > [!WARNING] 181 + 176 │ 182 + 177 │ There is **no support** on types whose syntax is not a path; they are currently not 183 + 178 │ parsed at all: 184 + 179 │ 185 + 180 │ > references `&T`, slices `[T]`, arrays `[T; N]`, tuples `(T1, T2)`, pointers like 186 + 181 │ > `*const T`, trait objects like `dyn Any`, and the never type `!` 187 + 182 │ 188 + 183 │ Note that such types can still be used as generic params, just not as standalone types. 189 + 184 │ 190 + 185 │ ## Struct fields 191 + 186 │ 192 + 187 │ > [!WARNING] 193 + 188 │ 194 + 189 │ Linking to struct fields is **not supported** yet. This is **incompatible** with 195 + 190 │ rustdoc. 196 + 191 │ 197 + 192 │ ## Markdown link syntax 198 + 193 │ 199 + 194 │ All Markdown link formats supported by rustdoc are supported: 200 + 195 │ 201 + 196 │ Linking with URL inlined: 202 + 197 │ 203 + 198 │ > ```md 204 + 199 │ > [The Option type](std::option::Option) 205 + 200 │ > ``` 206 + 201 │ > 207 + 202 │ > [The Option type](std::option::Option) 209 208 · ───────────────────┬────────────────── 210 209 · ╰── https://doc.rust-lang.org/stable/core/option/enum.Option.html 211 - 204 │ 212 - 205 │ Linking with reusable references: 213 - 206 │ 214 - 207 │ > ```md 215 - 208 │ > [The Option type][option-type] 216 - 209 │ > 217 - 210 │ > [option-type]: std::option::Option 218 - 211 │ > ``` 219 - 212 │ > 220 - 213 │ > [The Option type][option-type] 210 + 203 │ 211 + 204 │ Linking with reusable references: 212 + 205 │ 213 + 206 │ > ```md 214 + 207 │ > [The Option type][option-type] 215 + 208 │ > 216 + 209 │ > [option-type]: std::option::Option 217 + 210 │ > ``` 218 + 211 │ > 219 + 212 │ > [The Option type][option-type] 221 220 · ───────────────┬────────────── 222 221 · ╰── https://doc.rust-lang.org/stable/core/option/enum.Option.html 223 - 214 │ > 224 - 215 │ > [option-type]: std::option::Option 225 - 216 │ 226 - 217 │ Reference-style links `[text][id]` without a corresponding `[id]: name` part will be 227 - 218 │ treated the same as inline-style links `[text](id)`: 228 - 219 │ 229 - 220 │ > ```md 230 - 221 │ > [The Option type][std::option::Option] 231 - 222 │ > ``` 232 - 223 │ > 233 - 224 │ > [The Option type][std::option::Option] 222 + 213 │ > 223 + 214 │ > [option-type]: std::option::Option 224 + 215 │ 225 + 216 │ Reference-style links `[text][id]` without a corresponding `[id]: name` part will be 226 + 217 │ treated the same as inline-style links `[text](id)`: 227 + 218 │ 228 + 219 │ > ```md 229 + 220 │ > [The Option type][std::option::Option] 230 + 221 │ > ``` 231 + 222 │ > 232 + 223 │ > [The Option type][std::option::Option] 234 233 · ───────────────────┬────────────────── 235 234 · ╰── https://doc.rust-lang.org/stable/core/option/enum.Option.html 236 - 225 │ 237 - 226 │ Shortcuts are supported, and can contain inline markups: 238 - 227 │ 239 - 228 │ > ```md 240 - 229 │ > You can create a [`Vec`] with [**`Vec::new`**], or by using the [_`vec!`_][^2] macro. 241 - 230 │ > ``` 242 - 231 │ > 243 - 232 │ > You can create a [`Vec`] with [**`Vec::new`**], or by using the [_`vec!`_][^2] macro. 235 + 224 │ 236 + 225 │ Shortcuts are supported, and can contain inline markups: 237 + 226 │ 238 + 227 │ > ```md 239 + 228 │ > You can create a [`Vec`] with [**`Vec::new`**], or by using the [_`vec!`_][^2] macro. 240 + 229 │ > ``` 241 + 230 │ > 242 + 231 │ > You can create a [`Vec`] with [**`Vec::new`**], or by using the [_`vec!`_][^2] macro. 244 243 · ───┬─── ────────┬─────── ─────┬──── 245 244 · │ │ ╰── https://doc.rust-lang.org/stable/alloc/macros/macro.vec.html 246 245 · │ ╰── https://doc.rust-lang.org/stable/alloc/vec/struct.Vec.html#method.new 247 246 · ╰── https://doc.rust-lang.org/stable/alloc/vec/struct.Vec.html 248 - 233 │ 249 - 234 │ (The items must still be resolvable; in this case `Vec` and `vec!` come from the 250 - 235 │ prelude.) 251 - 236 │ 252 - 237 │ ## Linking to page sections 253 - 238 │ 254 - 239 │ To link to a known section on a page, use a URL fragment, just like a normal link. This 255 - 240 │ is _compatible_ with rustdoc. 256 - 241 │ 257 - 242 │ <!-- prettier-ignore-start --> 258 - 243 │ 259 - 244 │ > ```md 260 - 245 │ > [When Should You Use Which Collection?][std::collections#when-should-you-use-which-collection] 261 - 246 │ > ``` 262 - 247 │ > 263 - 248 │ > [When Should You Use Which Collection?][std::collections#when-should-you-use-which-collection] 247 + 232 │ 248 + 233 │ (The items must still be resolvable; in this case `Vec` and `vec!` come from the 249 + 234 │ prelude.) 250 + 235 │ 251 + 236 │ ## Linking to page sections 252 + 237 │ 253 + 238 │ To link to a known section on a page, use a URL fragment, just like a normal link. This 254 + 239 │ is _compatible_ with rustdoc. 255 + 240 │ 256 + 241 │ <!-- prettier-ignore-start --> 257 + 242 │ 258 + 243 │ > ```md 259 + 244 │ > [When Should You Use Which Collection?][std::collections#when-should-you-use-which-collection] 260 + 245 │ > ``` 261 + 246 │ > 262 + 247 │ > [When Should You Use Which Collection?][std::collections#when-should-you-use-which-collection] 264 263 · ───────────────────────────────────────────────┬────────────────────────────────────────────── 265 264 · ╰── https://doc.rust-lang.org/stable/std/collections/index.html 266 - 249 │ 267 - 250 │ <!-- prettier-ignore-end --> 268 - 251 │ 269 - 252 │ --- 270 - 253 │ 271 - 254 │ [^1]: 272 - 255 │ rust-analyzer's ability to generate links for enum variants like `Option::Some` was 273 - 256 │ improved only somewhat recently: before 274 - 257 │ [#19246](https://github.com/rust-lang/rust-analyzer/pull/19246), links for variants 275 - 258 │ and associated items may only point to the types themselves. If linking to such 276 - 259 │ items doesn't seem to work for you, be sure to upgrade to a newer rust-analyzer 277 - 260 │ first! 278 - 261 │ 279 - 262 │ [^2]: 280 - 263 │ As of rust-analyzer <ra-version>(version)</ra-version>, links generated for macros 281 - 264 │ don't always work. Examples include [`std::format!`] (seen above) and 265 + 248 │ 266 + 249 │ <!-- prettier-ignore-end --> 267 + 250 │ 268 + 251 │ --- 269 + 252 │ 270 + 253 │ [^1]: 271 + 254 │ rust-analyzer's ability to generate links for enum variants like `Option::Some` was 272 + 255 │ improved only somewhat recently: before 273 + 256 │ [#19246](https://github.com/rust-lang/rust-analyzer/pull/19246), links for variants 274 + 257 │ and associated items may only point to the types themselves. If linking to such 275 + 258 │ items doesn't seem to work for you, be sure to upgrade to a newer rust-analyzer 276 + 259 │ first! 277 + 260 │ 278 + 261 │ [^2]: 279 + 262 │ As of rust-analyzer <ra-version>(version)</ra-version>, links generated for macros 280 + 263 │ don't always work. Examples include [`std::format!`] (seen above) and 282 281 · ────────┬─────── 283 282 · ╰── https://doc.rust-lang.org/stable/alloc/macros/macro.format.html 284 - 265 │ [`tokio::main!`]. For more info, see [Known issues](known-issues.md#macros). 283 + 264 │ [`tokio::main!`]. For more info, see [Known issues](known-issues.md#macros). 285 284 · ────────┬─────── 286 285 · ╰── https://docs.rs/tokio-macros/2.5.0/tokio_macros/macro.main.html 287 - 266 │ 286 + 265 │ 288 287 ╰────
+3 -4
docs/src/rustdoc-link/supported-syntax.md
··· 74 74 > ```md 75 75 > | Phantom type | variance of `T` | 76 76 > | :------------------------------------------------- | :---------------- | 77 - > | [`&'a mut T`][std::marker::PhantomData<&'a mut T>] | **inv**ariant | 77 + > | [`&'a mut T`][std::marker::PhantomData<&'a mut T>] | **in**variant | 78 78 > | [`fn(T)`][std::marker::PhantomData<fn(T)>] | **contra**variant | 79 79 > ``` 80 80 > 81 81 > | Phantom type | variance of `T` | 82 82 > | :------------------------------------------------- | :---------------- | 83 - > | [`&'a mut T`][std::marker::PhantomData<&'a mut T>] | **inv**ariant | 83 + > | [`&'a mut T`][std::marker::PhantomData<&'a mut T>] | **in**variant | 84 84 > | [`fn(T)`][std::marker::PhantomData<fn(T)>] | **contra**variant | 85 85 86 86 This includes if you use turbofish: ··· 159 159 > [`std::vec`], [`mod@std::vec`], and [`macro@std::vec`] all link to the `vec` _module_. 160 160 > ``` 161 161 > 162 - > [`std::vec`], [`mod@std::vec`], and [`macro@std::vec`] all link to the `vec` > 163 - > _module_. 162 + > [`std::vec`], [`mod@std::vec`], and [`macro@std::vec`] all link to the `vec` _module_. 164 163 165 164 Currently, duplicate names in Rust are allowed only if they correspond to items in 166 165 different [namespaces], for example, between macros and modules, and between struct