···11# Caching
2233-By default, `mdbook-rustdoc-link` spawns a fresh `rust-analyzer` process every time it
44-runs. rust-analyzer must then reindex your entire project before being able to resolve
55-links.
33+By default, the preprocessor spawns a fresh `rust-analyzer` process every time it runs.
44+rust-analyzer must then reindex your entire project before being able to resolve links.
6576This makes the `mdbook serve` command significantly less responsive, which gets worse if
87your project contains a large number of dependencies. It is as if for every live reload,
···13121413## Enabling caching
15141616-In `book.toml`, in the `[preprocessor.rustdoc-link]` table, set
1515+In `book.toml`, in the `[preprocessor.rustdoc-links]` table, set
1716[`cache-dir`](configuration.md#cache-dir) to the relative path of a directory of your
1817choice, _outside_ of your book's `build-dir`, for example:
19182019```toml
2121-[preprocessor.rustdoc-link]
2020+[preprocessor.rustdoc-links]
2221cache-dir = "cache"
2322# You could also point to an arbitrary directory in target/
2423```
···102101`rust-analyzer` instance per cargo workspace."
103102104103In theory, in an IDE setting (e.g. with VS Code), one could setup the IDE and
105105-`mdbook-rustdoc-link` to both connect to the same `ra-multiplex` server. Then the
104104+`mdbook-rustdoc-links` to both connect to the same `ra-multiplex` server. Then the
106105preprocessor doesn't need to wait for cache priming (the cache is already warm from IDE
107106use). Changes in the workspace could also be reflected in subsequent builds without the
108107preprocessor being aware of them (because the IDE is doing the synchronizing).
-20
docs/src/rustdoc-link/configuration.md
···11-# Configuration
22-33-This page lists all options for the preprocessor.
44-55-For use in `book.toml`, configure under the `[preprocessor.rustdoc-link]` table using
66-the keys below, for example:
77-88-```toml
99-[preprocessor.rustdoc-link]
1010-rust-analyzer = "path/to/rust-analyzer --option ..."
1111-```
1212-1313-For use [on the command line](standalone-usage.md), use the keys as long arguments, for
1414-example:
1515-1616-```bash
1717-mdbook-rustdoc-link markdown --rust-analyzer "..."
1818-```
1919-2020-<rustdoc-link-options>(autogenerated)</rustdoc-link-options>
···11# Continuous integration
2233-This page gives information and tips for using `mdbook-rustdoc-link` in a continuous
44-integration (CI) environment. The preprocessor optimizes some behaviors for CI, in terms
55-of error handling, logging, etc.
33+The preprocessor optimizes some behaviors for continuous integration (CI) environments,
44+in terms of error handling, logging, etc.
6576## Detecting CI
87···5150when a link fails to resolve, it prints them as warnings but continues to run. This is
5251so that your book continues to build via `mdbook serve` while you make edits.
53525454-When running in CI, all such warnings are promoted to errors. The preprocessor will exit
5555-with a non-zero status code which will fail your build. This is to prevent outdated or
5656-incorrect links from being accidentally deployed.
5353+**When running in CI, all such warnings are promoted to errors by default.** The
5454+preprocessor will exit with a non-zero status code which will fail your build. This is
5555+to prevent outdated or incorrect links from being accidentally deployed.
57565857You can explicitly control this behavior using the
5958[`fail-on-warnings`](configuration.md#fail-on-warnings) option.
···14142. Install the preprocessor:
15151616 ```
1717- cargo install mdbookkit --features rustdoc-link
1717+ cargo install mdbook-rustdoc-links
1818 ```
19192020 Alternatively, you may obtain precompiled binaries from [GitHub
···3030[book]
3131title = "My Book"
32323333-[preprocessor.rustdoc-link]
3434-# mdBook will run `mdbook-rustdoc-link`
3333+[preprocessor.rustdoc-links]
3434+# mdBook will execute the command `mdbook-rustdoc-links`
3535after = ["links"]
3636# mdBook will run this preprocessor after the default `links` preprocessor.
3737# This is recommended. It allows the preprocessor to see text embedded
···74747575> [!TIP]
7676>
7777-> `mdbook-rustdoc-link` makes use of rust-analyzer's ["Open Docs"][open-docs] feature,
7777+> `mdbook-rustdoc-links` makes use of rust-analyzer's ["Open Docs"][open-docs] feature,
7878> which resolves links to documentation given a symbol.
7979>
8080> Items from `std` will generate links to <https://doc.rust-lang.org>, while items from
···33<div class="hidden">
4455**For best results, view this page at
66-<https://tonywu6.github.io/mdbookkit/rustdoc-link>.**
66+<https://tonywu6.github.io/mdbookkit/rustdoc-links>.**
7788</div>
99···45454646For **writing documentation** —
47474848-- To learn more about how the preprocessor resolves items into links, including
4949- [feature-gated items](name-resolution.md#feature-gated-items), see
5050- [Name resolution](name-resolution.md).
5151-- To learn how to link to additional items such as
4848+- [Supported syntax](supported-syntax.md): Full list of link syntax with examples. Know
4949+ how to link to additional items such as
5250 [functions, macros](supported-syntax.md#functions-and-macros), and
5353- [implementors](supported-syntax.md#implementors-and-fully-qualified-syntax), see
5454- [Supported syntax](supported-syntax.md).
5151+ [implementors](supported-syntax.md#implementors-and-fully-qualified-syntax).
5252+- [Name resolution](name-resolution.md): Understand how the preprocessor find Rust
5353+ items, including
5454+ [when items are gated behind features](name-resolution.md#feature-gated-items).
55555656For **making the preprocessor work with your project** —
57575858-- If you use [Cargo workspaces][workspaces], see specific instructions in
5959- [Workspace layout](workspace-layout.md).
6060-- If you are working on a large project, and processing is taking a long time, see the
6161- discussion in [Caching](caching.md).
5858+- [Workspace layout](workspace-layout.md): Setup and options suitable for [Cargo
5959+ workspaces][workspaces].
6060+- [Caching](caching.md): If you are working on a large project and processing is taking
6161+ a long time.
62626363For **additional usage information** —
64646565-- You can use this as a standalone command line tool: see
6666- [Standalone usage](standalone-usage.md).
6767-- For tips on using this in CI, see [Continuous integration](continuous-integration.md).
6868-- For all available options and how to set them, see [Configuration](configuration.md).
6969-- Finally, review [Known issues](known-issues.md) and limitations.
6565+- [Standalone usage](standalone-usage.md): Use the preprocessor as a standalone command
6666+ line tool.
6767+- [Continuous integration](continuous-integration.md): Information for running the
6868+ preprocessor in CI environments, including
6969+ [logging](continuous-integration.md#logging) and
7070+ [failing a build when there are bad links](continuous-integration.md#error-handling).
7171+- [Configuration](configuration.md): List of available options.
7272+- [Known issues](known-issues.md) and limitations.
70737174Happy linking!
7275
···2233## Performance
4455-`mdbook-rustdoc-link` itself doesn't need much processing power, but it invokes
55+`mdbook-rustdoc-links` itself doesn't need much processing power, but it invokes
66rust-analyzer, which does a full scan of your workspace. The larger your workspace is,
77the longer mdBook will have to wait for the preprocessor. This is the source of the
88majority of the run time.
···4040 - The correct link is
4141 [https://docs.rs/tokio-macros/2.5.0/tokio_macros/~~macro~~attr.main.html][tokio::main]
42424343-### Trait items
4343+### Implemented items with the same name
44444545Rust allows methods to have the same name if they are from different traits, and types
4646can implement the same trait multiple times if the trait is generic. All such methods
···7878## Sites other than docs.rs
79798080Currently, items from crates other than `std` always generate links that point to
8181-<https://docs.rs>. `mdbook-rustdoc-link` does not yet support configuring alternative
8282-URL prefixes.
8181+<https://docs.rs>. The preprocessor does not yet support configuring alternative URL
8282+prefixes.
83838484## Wrong line numbers in diagnostics
8585···96969797This is an unfortunate limitation with mdBook's preprocessor architecture. Preprocessors
9898are run sequentially, with the next preprocessor receiving Markdown source rendered by
9999-the previous one. If preprocessors running before `mdbook-rustdoc-link` modify Markdown
9999+the previous one. If preprocessors running before the preprocessor modify Markdown
100100source in such ways that shift lines around, then the line numbers will look incorrect.
101101102102Unless mdBook somehow gains [source map][sourcemap] support, this problem is unlikely to
···2121- You do want at least some reference links. It could quickly become cumbersome to find
2222 and copy the correct links by hand, and even more so to maintain them over time.
23232424-`mdbook-rustdoc-link` is the tooling answer to these problems. _Effortless, correct, and
2525-good practice — choose all three!_
2424+`mdbook-rustdoc-links` is the tooling answer to these problems. _Effortless, correct,
2525+and good practice — choose all three!_
26262727> [!TIP]
2828>
···11# Standalone usage
2233-You can use `mdbook-rustdoc-link` as a standalone Markdown processor via the `markdown`
33+You can use `mdbook-rustdoc-links` as a standalone Markdown processor via the `markdown`
44subcommand: send your Markdown through stdin, and receive the result through stdout, for
55example:
6677```bash
88-mdbook-rustdoc-link markdown < README.md
88+mdbook-rustdoc-links markdown < README.md
99```
10101111The command accepts as arguments all [options](configuration.md) configurable in
1212`book.toml`, such as [`--cache-dir`](configuration.md#cache-dir). Run
1313-`mdbook-rustdoc-link markdown --help` to see them.
1313+`mdbook-rustdoc-links markdown --help` to see them.
14141515<figure id="media-open-docs">
1616- <img src="media/standalone-usage.png" alt="example using mdbook-rustdoc-link as a command line tool">
1616+ <img src="media/standalone-usage.png" alt="example using mdbook-rustdoc-links as a command line tool">
1717</figure>
18181919<style>
···33<div class="hidden">
4455**For best results, view this page at
66-<https://tonywu6.github.io/mdbookkit/rustdoc-link/supported-syntax>.**
66+<https://tonywu6.github.io/mdbookkit/rustdoc-links/supported-syntax>.**
7788</div>
99
···21212222## Using the `manifest-dir` option
23232424-In your `book.toml`, in the `[preprocessor.rustdoc-link]` table, set the
2424+In your `book.toml`, in the `[preprocessor.rustdoc-links]` table, set the
2525[`manifest-dir`](configuration.md#manifest-dir) option to the relative path to a member
2626package.
2727···4343Then in your `book.toml`:
44444545```toml
4646-[preprocessor.rustdoc-link]
4646+[preprocessor.rustdoc-links]
4747manifest-dir = "../crates/fancy-crate"
4848```
4949
+18
docs/src/rustdoc-links/configuration.md
···11+# Configuration
22+33+This page lists all options for the preprocessor.
44+55+Configure options in the `[preprocessor.rustdoc-links]` table using the keys below, for
66+example:
77+88+```toml
99+[preprocessor.rustdoc-links]
1010+rust-analyzer = "path/to/rust-analyzer --option ..."
1111+```
1212+1313+For use [on the command line](standalone-usage.md), specify options via arguments, for
1414+example:
1515+1616+```bash
1717+mdbook-rustdoc-links markdown --rust-analyzer "..."
1818+```