···7788## Performance
991010-`mdbook-rustdoc-links` itself doesn't need much processing power, but it invokes
1010+The preprocessor itself doesn't need much processing power, but it invokes
1111rust-analyzer, which does a full scan of your workspace. The larger your workspace is,
1212the longer mdBook will have to wait for the preprocessor. This is the source of the
1313majority of the run time.
+3-5
docs/src/permalinks/configuration.md
···2233This page lists all options for the preprocessor.
4455-For use in `book.toml`, configure under the `[preprocessor.link-forever]` table using
66-the keys below, for example:
55+Configure options in the `[preprocessor.permalinks]` table using the keys below, for
66+example:
7788```toml
99-[preprocessor.link-forever]
99+[preprocessor.permalinks]
1010always-link = [".rs"]
1111```
1212-1313-<link-forever-options>(autogenerated)</link-forever-options>
+11-51
docs/src/permalinks/continuous-integration.md
···11# Continuous integration
2233-This page gives information and tips for using `mdbook-link-forever` in a continuous
44-integration (CI) environment.
55-66-The preprocessor behaves differently in terms of logging, error handling, etc., when it
77-detects it is running in CI.
88-99-<details class="toc" open>
1010- <summary>Sections</summary>
1111-1212-- [Detecting CI](#detecting-ci)
1313-- [Linking to Git tags](#linking-to-git-tags)
1414-- [Logging](#logging)
1515-- [Error handling](#error-handling)
1616-1717-</details>
33+The preprocessor optimizes some behaviors for continuous integration (CI) environments,
44+in terms of error handling, logging, etc.
185196## Detecting CI
2072121-To determine whether it is running in CI, the preprocessor honors the `CI` environment
2222-variable. Specifically:
2323-2424-- If `CI` is set to `"true"`, then it is considered in CI[^ci-true];
2525-- Otherwise, it is considered not in CI.
2626-2727-Most major CI/CD services, such as [GitHub Actions][github-actions-ci] and [GitLab
2828-CI/CD][gitlab-ci], automatically configure this variable for you.
88+{{#include ../snippets/detecting-ci.md}}
2993010## Linking to Git tags
31113232-The preprocessor supports both tags and commit SHAs when generating permalinks. The use
3333-of tags is contingent on HEAD being tagged in local Git at build time. You should ensure
3434-that tags are present when building in CI, or the preprocessor will fallback to using
3535-the full SHA (it would still be a permalink, just that it will be more verbose).
1212+The preprocessor supports both tags and commit hashes when generating permalinks. **The
1313+use of tags is contingent on HEAD being tagged in local Git at build time.**
1414+1515+You should ensure that tags are present locally when building in CI, otherwise the
1616+preprocessor will fallback to using the full commit hash. The resulting permalinks will
1717+function the same, but they will be more verbose.
36183719For example, in [GitHub Actions][actions/checkout], you can use:
3820···46284729## Logging
48304949-By default, the preprocessor shows a progress spinner when it is running.
5050-5151-When running in CI, progress is instead printed as logs (using [log] and
5252-[env_logger])[^stderr].
5353-5454-You can control logging levels using the [`RUST_LOG`] environment variable.
3131+{{#include ../snippets/logging.md}}
55325633## Error handling
57345858-By default, when the preprocessor encounters any non-fatal issues, such as when a link
5959-fails to resolve, it prints them as warnings but continues to run. This is so that your
6060-book continues to build via `mdbook serve` while you make edits.
6161-6262-When running in CI, all such warnings are promoted to errors. The preprocessor will exit
6363-with a non-zero status code when there are warnings, which will fail your build. This
6464-prevents outdated or incorrect links from being accidentally deployed.
6565-6666-You can explicitly control this behavior using the
6767-[`fail-on-warnings`](configuration.md#fail-on-warnings) option.
6868-6969-[^ci-true]:
7070- Specifically, when `CI` is anything other than `""`, `"0"`, or `"false"`. The logic
7171- is encapsulated in the [`is_ci`][crate::error::is_ci] function.
7272-7373-[^stderr]:
7474- Specifically, when stderr is redirected to something that isn't a terminal, such as
7575- a file.
3535+{{#include ../snippets/error-handling.md}}
76367737<!-- prettier-ignore-start -->
7838
+18-9
docs/src/permalinks/features.md
···2222> like [path completions][vscode-path-completions] and [link
2323> validation][link-validation].
24242525-Permalinks are **versioned using the tag name or hash** of the commit from which the
2626-book was built. Your links remain consistent with their source commit even as content in
2727-your repository changes over time.
2828-2929-URL fragments are preserved. For example, you may use fragments to link to specific
2525+**URL fragments** are preserved. For example, you may use fragments to link to specific
3026lines, if your Git hosting provider supports it:
31273228> ```md
···3834> [preprocess its style sheet](../../app/build/build.ts#L13-25).
39354036By default, links to files under your book's `src/` directory are not converted, since
4141-mdBook already [copies them to build output][mdbook-src-build], but this is configurable
3737+mdBook already [copies them to build output][mdbook-src-build]. This is configurable
4238using the [`always-link`](configuration.md#always-link) option.
3939+4040+## Versioning
4141+4242+Permalinks are **versioned using the tag name or hash** of the commit from which the
4343+book was built. Your links remain consistent with their source commit even as content in
4444+your repository changes over time.
43454446## Repo URL auto-discovery
4547···5456> For Git remotes, both HTTP URLs and "scp-like" URIs (`git@github.com:org/repo.git`)
5557> are supported.
56585959+Currently, the preprocessor automatically uses repo URLs from the following providers:
6060+6161+- GitHub, `https://github.com/*`
6262+5763Alternatively, you may configure a custom URL format using the
5864[`repo-url-template`](configuration.md#repo-url-template) option.
5965···6571- a `raw` URL that directly serves the file's content, suitable for embedding or
6672 downloading
67736868-The preprocessor detects whether a path is used within a clickable link or an image and
6969-selects the most appropriate type of URL to use. For example, the following snippet
7070-creates an image wrapped in a clickable link which opens the image's page on GitHub:
7474+The preprocessor detects the context in which a link appears and selects the most
7575+appropriate type of URL to use: `tree` if it is a clickable link, or `raw` if it is for
7676+an image.
7777+7878+For example, the following snippet creates an image wrapped in a clickable link which
7979+opens the image's page on GitHub:
71807281> ```md
7382> [![Minato City][minato-city]][minato-city]
+1-1
docs/src/permalinks/getting-started.md
···47474848## Next steps
49495050+- See the list of [features](features.md) in detail.
5051- Check out [available configuration options](configuration.md).
5151- <!-- TODO: including options to ... -->
5252- Learn about [known issues and limitations](known-issues.md).
53535454<!-- prettier-ignore-start -->
+7-1
docs/src/permalinks/index.md
···20202121## Overview
22222323-<!-- TODO: -->
2323+- Create [permalinks](features.md#permalinks) by file path.
2424+- Links are [pinned to the tag or commit](features.md#versioning) that is checked out at
2525+ build time.
2626+- Links are [validated](features.md#link-validation) during build. Receive warnings when
2727+ a linked file become missing.
2828+- Repository URLs are [autoconfigured for GitHub](features.md#repo-url-auto-discovery),
2929+ or you can use a [custom URL scheme](configuration.md#repo-url-template).
24302531## License
2632
+5-5
docs/src/permalinks/known-issues.md
···2233## Working with `{{#include}}`
4455-Linking by relative paths may not make sense when the links are in files that are
66-embedded using mdBook's `{{#include}}` directive.
55+Linking by relative paths may not work when the links are in files that are embedded
66+using mdBook's `{{#include}}` directive.
7788-See [Working with `{{#include}}`](working-with-include.md) for some possible
99-workarounds.
88+See [More ways to link](more-ways-to-link.md) for some possible workarounds.
1091110## Links in HTML
12111313-Links in HTML (`href` and `src`) are currently neither transformed nor checked.
1212+URLs in HTML (`href` and `src`) are currently unsupported. They are neither checked nor
1313+transformed.
+7-7
docs/src/permalinks/more-ways-to-link.md
···88- Furthermore, the included document may also be intended for additional platforms,
99 where path-based links are not supported.
10101111-The preprocessor supports some alternative link formats for such scenarios.
1111+For such cases, the preprocessor supports some alternative link formats.
12121313```mermaid
1414stateDiagram-v2
···38383939> For example, if `chapters/1.md` includes `shared/info.md`, and `shared/info.md`
4040> contains a link to `./image.png` (i.e. `shared/image.png`), then the preprocessor can
4141-> only resolve `./image.png` starting from `chapters/1.md` (i.e. `chapters/image.png`),
4242-> which is incorrect.
4141+> only resolve `./image.png` starting from `chapters/1.md`, which becomes
4242+> `chapters/image.png`, which is incorrect.
43434444Instead of using relative paths, you may use paths that **start with a `/`**. Paths that
4545start with a `/` are resolved **relative to the root of your repository**:
···5555## Using URLs
56565757In some situations, you cannot link using paths, and must fallback to full URLs. For
5858-example, you would like to reuse your package's `README.md` as your book's home page,
5858+example, you may want to reuse your package's `README.md` for your book's home page,
5959where the `README.md` is also published to crates.io, where path-based links will become
6060invalid.
6161···83838484### Using URLs to your book
85858686-Finally, you can link to a page or file within your book using full URLs and the
8787-preprocessor will validate that the corresponding file is accessible.
8686+You can link to a page or file within your book using full URLs and the preprocessor
8787+will validate that the corresponding file is accessible.
88888989To enable validation of book URLs, you must specify the URL prefix at which you will
9090deploy your book via the [`book-url`](configuration.md#book-url) option:
91919292```toml
9393[preprocessor.permalinks]
9494-book-url = "https://example.org/"
9494+book-url = "https://example.org/book/"
9595```
96969797For each link that begins with this prefix, the preprocessor tests whether a matching
+3-37
docs/src/rustdoc-links/continuous-integration.md
···5566## Detecting CI
7788-To determine whether it is running in a CI environment, the preprocessor honors the `CI`
99-environment variable. Specifically:
1010-1111-- If `CI` is set to `"true"`, then it is considered in CI[^ci-true];
1212-- Otherwise, it is considered not in CI.
1313-1414-Providers such as [GitHub Actions][github-actions-ci] and [GitLab CI/CD][gitlab-ci] have
1515-this variable configured by default.
88+{{#include ../snippets/detecting-ci.md}}
1691710## Installing rust-analyzer
1811···35283629## Logging
37303838-<!-- TODO: -->
3939-4040-By default, the preprocessor shows a progress spinner when it is running.
4141-4242-When running in CI, progress is instead printed as logs (using [log] and
4343-[env_logger])[^stderr].
4444-4545-You can control logging levels using the [`RUST_LOG`] environment variable.
3131+{{#include ../snippets/logging.md}}
46324733## Error handling
48344949-When running locally, when the preprocessor encounters any non-fatal issues, such as
5050-when a link fails to resolve, it prints them as warnings but continues to run. This is
5151-so that your book continues to build via `mdbook serve` while you make edits.
5252-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.
5656-5757-You can explicitly control this behavior using the
5858-[`fail-on-warnings`](configuration.md#fail-on-warnings) option.
3535+{{#include ../snippets/error-handling.md}}
59366037[^ra-on-path]:
6138 You may alternatively specify a command to use for rust-analyzer via the
6239 [`rust-analyzer`](configuration.md#rust-analyzer) configuration option.
63406464-[^ci-true]:
6565- Specifically, when `CI` is anything other than `""`, `"0"`, or `"false"`. The logic
6666- is encapsulated in the [`is_ci`][crate::error::is_ci] function.
6767-6868-[^stderr]:
6969- Specifically, when stderr is redirected to something that isn't a terminal, such as
7070- a file.
7171-7241<!-- prettier-ignore-start -->
73427474-[`RUST_LOG`]: https://docs.rs/env_logger/latest/env_logger/#enabling-logging
7543[dtolnay/rust-toolchain]: https://github.com/dtolnay/rust-toolchain
7676-[github-actions-ci]: https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/store-information-in-variables#default-environment-variables
7777-[gitlab-ci]: https://docs.gitlab.com/ci/variables/predefined_variables/
7844[rustup-ra]: https://rust-analyzer.github.io/book/rust_analyzer_binary.html#rustup
79458046<!-- prettier-ignore-end -->
+1-1
docs/src/rustdoc-links/index.md
···1818collections. [^1]
1919```
20202121-... and you will get:
2121+... and you get:
22222323<figure class="fig-text">
2424
+1-1
docs/src/rustdoc-links/known-issues.md
···2233## Performance
4455-`mdbook-rustdoc-links` itself doesn't need much processing power, but it invokes
55+The preprocessor 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.
+19
docs/src/snippets/detecting-ci.md
···11+To determine whether it is running in a CI environment, the preprocessor honors the `CI`
22+environment variable. Specifically:
33+44+- If `CI` is set to `"true"`, then it is considered in CI[^ci-true];
55+- Otherwise, it is considered not in CI.
66+77+Providers such as [GitHub Actions][github-actions-ci] and [GitLab CI/CD][gitlab-ci] have
88+this variable configured by default.
99+1010+[^ci-true]:
1111+ Specifically, when `CI` is anything other than `""`, `"0"`, or `"false"`. The logic
1212+ is encapsulated in the [`is_ci`][crate::error::is_ci] function.
1313+1414+<!-- prettier-ignore-start -->
1515+1616+[github-actions-ci]: https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/store-information-in-variables#default-environment-variables
1717+[gitlab-ci]: https://docs.gitlab.com/ci/variables/predefined_variables/
1818+1919+<!-- prettier-ignore-end -->
+10
docs/src/snippets/error-handling.md
···11+When running locally, when the preprocessor encounters any non-fatal issues, such as
22+when a link fails to resolve, it prints them as warnings but continues to run. This is
33+so that your book continues to build via `mdbook serve` while you make edits.
44+55+**When running in CI, all such warnings are promoted to errors by default.** The
66+preprocessor will exit with a non-zero status code which will fail your build. This is
77+to prevent outdated or incorrect links from being accidentally deployed.
88+99+You can explicitly control this behavior using the
1010+[`fail-on-warnings`](configuration.md#fail-on-warnings) option.
+18
docs/src/snippets/logging.md
···11+<!-- TODO: -->
22+33+By default, the preprocessor shows a progress spinner when it is running.
44+55+When running in CI, progress is instead printed as logs (using [log] and
66+[env_logger])[^stderr].
77+88+You can control logging levels using the [`RUST_LOG`] environment variable.
99+1010+[^stderr]:
1111+ Specifically, when stderr is redirected to something that isn't a terminal, such as
1212+ a file.
1313+1414+<!-- prettier-ignore-start -->
1515+1616+[`RUST_LOG`]: https://docs.rs/env_logger/latest/env_logger/#enabling-logging
1717+1818+<!-- prettier-ignore-end -->