Skip to content

Commit

Permalink
Opt into, rather than out of, linkcheck (#2180)
Browse files Browse the repository at this point in the history
This makes it less of a hassle to render the book locally.
  • Loading branch information
camelid authored Dec 30, 2024
1 parent 9677beb commit ad93c5f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
cargo install mdbook-mermaid --version ${{ env.MDBOOK_MERMAID_VERSION }}
- name: Check build
run: mdbook build
run: ENABLE_LINKCHECK=1 mdbook build

- name: Deploy to gh-pages
if: github.event_name == 'push'
Expand Down
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,14 @@ The build files are found in the `book/html` directory.

### Link Validations

We use `mdbook-linkcheck2` to validate URLs included in our documentation.
`linkcheck` will be run automatically when you build with the instructions in the section above.
We use `mdbook-linkcheck2` to validate URLs included in our documentation. Link
checking is **not** run by default locally, though it is in CI. To enable it
locally, set the environment variable `ENABLE_LINKCHECK=1` like in the
following example.

> [!NOTE]
> The link validation can be skipped by setting the following environment variable:
> `SKIP_LINKCHECK=1 mdbook ...`
```console
$ ENABLE_LINKCHECK=1 mdbook serve
```

### Table of Contents

Expand Down
2 changes: 1 addition & 1 deletion ci/linkcheck.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ set_github_token() {
jq '.config.output.linkcheck."http-headers"."github\\.com" = ["Authorization: Bearer $GITHUB_TOKEN"]'
}

if [ ! -z "$SKIP_LINKCHECK" ] ; then
if [ -z "$ENABLE_LINKCHECK" ] ; then
echo "Skipping link check."
exit 0
fi
Expand Down

0 comments on commit ad93c5f

Please sign in to comment.