From ccfbad0ae35ee6f324a4064d0e6bd5079be05615 Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Wed, 18 Dec 2024 09:21:21 -0800 Subject: [PATCH] Add cross-file anchor link check (use lychee for markdown link checking) --- .lychee.toml | 10 ++++++++++ .markdown_link_check_config.json | 22 ---------------------- Makefile | 12 +++++++----- 3 files changed, 17 insertions(+), 27 deletions(-) create mode 100644 .lychee.toml delete mode 100644 .markdown_link_check_config.json diff --git a/.lychee.toml b/.lychee.toml new file mode 100644 index 000000000..5360e2720 --- /dev/null +++ b/.lychee.toml @@ -0,0 +1,10 @@ +include-fragments = true + +exclude = [ + # excluding links to pull requests and issues is done for performance + "^https://github.com/open-telemetry/opentelemetry-proto/pull/\\d+$", + "^https://github.com/open-telemetry/opentelemetry-proto/issue/\\d+$" +] + +# better to be safe and avoid failures +max-retries = 6 diff --git a/.markdown_link_check_config.json b/.markdown_link_check_config.json deleted file mode 100644 index f8cf2cdd0..000000000 --- a/.markdown_link_check_config.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "ignorePatterns": [ - { - "pattern": "^https://github\\.com/open-telemetry/opentelemetry-specification/(issues|pull)" - } - ], - "replacementPatterns": [ - { - "pattern": "^/", - "replacement": "{{BASEURL}}/" - }, - { - "pattern": "^https://github.com/open-telemetry/opentelemetry-proto/(blob|tree)/[^/]+/docs/", - "replacement": "LINK-CHECK-ERROR-USE-LOCAL-PATH-TO-DOC-PAGE-NOT-EXTERNAL-URL/" - } - ], - "retryOn429": true, - "aliveStatusCodes": [ - 200, - 403 - ] -} diff --git a/Makefile b/Makefile index 4f52d69f2..75be19adb 100644 --- a/Makefile +++ b/Makefile @@ -170,11 +170,13 @@ ALL_DOCS := $(shell find . -type f -name '*.md' -not -path './.github/*' -not -p .PHONY: markdown-link-check markdown-link-check: - @if ! npm ls markdown-link-check; then npm install; fi - @for f in $(ALL_DOCS); do \ - npx --no -- markdown-link-check --quiet --config .markdown_link_check_config.json $$f \ - || exit 1; \ - done + docker run --rm \ + --mount 'type=bind,source=$(PWD),target=/home/repo' \ + lycheeverse/lychee \ + --config home/repo/.lychee.toml \ + --root-dir /home/repo \ + -v \ + home/repo .PHONY: markdownlint markdownlint: