diff --git a/.github/workflows/docpages.yml b/.github/workflows/docpages.yml index 09cb071e..f84061f4 100644 --- a/.github/workflows/docpages.yml +++ b/.github/workflows/docpages.yml @@ -76,6 +76,26 @@ jobs: run: | just build-docs + - name: Check docs internal links + uses: lycheeverse/lychee-action@v2 + with: + args: >- + --config .lychee.toml --no-progress + --root-dir ${{ github.workspace }}/docs/content/docs + --fallback-extensions mdx,md --index-files index.mdx,index.md + 'docs/content/docs/**/*.mdx' docs/README.md README.md + fail: true + + - name: Check built docs links (including external) + uses: lycheeverse/lychee-action@v2 + with: + args: >- + --config .lychee.postbuild.toml --no-progress + --root-dir ${{ github.workspace }}/docs/out + --fallback-extensions html --index-files index.html + 'docs/out/**/*.html' + fail: true + - name: Setup Pages if: ${{ github.ref == 'refs/heads/main' }} uses: actions/configure-pages@v6.0.0 diff --git a/.lychee.postbuild.toml b/.lychee.postbuild.toml new file mode 100644 index 00000000..f92f48ff --- /dev/null +++ b/.lychee.postbuild.toml @@ -0,0 +1,11 @@ +# Post-build check over exported HTML with external links enabled. + +# Avoid noisy/generated dependency paths if ever passed as inputs. +exclude_path = ["docs/node_modules/**"] + +# Keep retries bounded while reducing transient external failures. +max_retries = 2 +timeout = 20 + +# Treat common external rate limiting as non-fatal for CI stability. +accept = [200, 429] diff --git a/.lychee.toml b/.lychee.toml new file mode 100644 index 00000000..27ab9bfd --- /dev/null +++ b/.lychee.toml @@ -0,0 +1,14 @@ +# Restrict checks to local repository links/anchors. +offline = true + +# Avoid traversing generated and dependency directories if they appear in inputs. +exclude_path = ["docs/out/**", "docs/node_modules/**"] + +# API docs are generated by `just gen-api`; skip this route in source-only checks. +# /benchmarks/* images live in docs/public/ and are served at runtime; they cannot be resolved as +# local file paths by lychee. +exclude = [ + "^/api(?:$|/)", + "file://.*/docs/content/docs/api(?:$|[#/])", + "^/benchmarks/", +] diff --git a/README.md b/README.md index cb1633fd..69dee6ae 100644 --- a/README.md +++ b/README.md @@ -156,8 +156,13 @@ executed from the notebooks in `docs/notebooks/`. Building the documentation lo ```bash just build-docs # output: docs/out/ just serve-docs # live-reloading dev server +just check-doc-links # checks internal docs links/anchors from source MDX +just check-doc-links-built # builds docs and checks exported HTML links (including external URLs) ``` +`just check-doc-links` requires [`lychee`](https://github.com/lycheeverse/lychee) +to be installed locally. + ### Keeping documentation up to date Any PR that changes behavior, public APIs, build/test commands, or repository paths diff --git a/docs/content/docs/benchmarks.mdx b/docs/content/docs/benchmarks.mdx index 86184e5e..c915e5b0 100644 --- a/docs/content/docs/benchmarks.mdx +++ b/docs/content/docs/benchmarks.mdx @@ -177,7 +177,7 @@ The end-to-end workflow is: #### 1. Choose the simulation settings -All simulation parameters live in [`settings.json`](settings.json) and are shared by every engine +All simulation parameters live in [`settings.json`](https://github.com/Algorithmiq/monoprop/blob/main/benches/third_party/pauli_prop/settings.json) and are shared by every engine (Python and Julia alike), so a single edit compares them all on an identical problem instance: | Key | Meaning | diff --git a/justfile b/justfile index 0120d0e8..4fbbc12c 100644 --- a/justfile +++ b/justfile @@ -189,6 +189,14 @@ doctest-docs: build-docs: docs-install gen-api doctest-py doctest-docs gen-notebooks cd {{ site }} && npm run build +# Check docs for broken internal links and anchors. +check-doc-links: + lychee --config .lychee.toml --root-dir "{{ project_source_dir }}/docs/content/docs" --fallback-extensions mdx,md --index-files index.mdx,index.md 'docs/content/docs/**/*.mdx' docs/README.md README.md + +# Build docs, then check exported HTML links (including external URLs). +check-doc-links-built: build-docs + lychee --config .lychee.postbuild.toml --root-dir "{{ project_source_dir }}/docs/out" --fallback-extensions html --index-files index.html 'docs/out/**/*.html' + # Serve the documentation locally with hot reloading. serve-docs: cd {{ site }} && npm run dev