From ccfbad0ae35ee6f324a4064d0e6bd5079be05615 Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Wed, 18 Dec 2024 09:21:21 -0800 Subject: [PATCH 1/3] 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: From cdb0047f76798df6cf7e006cbcae6eea5a4a1f59 Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Wed, 18 Dec 2024 09:34:38 -0800 Subject: [PATCH 2/3] single regex --- .lychee.toml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.lychee.toml b/.lychee.toml index 5360e2720..335ceabc3 100644 --- a/.lychee.toml +++ b/.lychee.toml @@ -2,8 +2,7 @@ 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+$" + "^https://github.com/open-telemetry/opentelemetry-proto/(pull|issue)/\\d+$" ] # better to be safe and avoid failures From 0227817c0d8a217e12188e33fff348e19c3fe62b Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Tue, 7 Jan 2025 16:51:16 -0800 Subject: [PATCH 3/3] Fix lychee (markdown link check) toml config --- .lychee.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.lychee.toml b/.lychee.toml index 335ceabc3..b65d0579b 100644 --- a/.lychee.toml +++ b/.lychee.toml @@ -1,9 +1,9 @@ -include-fragments = true +include_fragments = true -exclude = [ +exclude = [ # excluding links to pull requests and issues is done for performance "^https://github.com/open-telemetry/opentelemetry-proto/(pull|issue)/\\d+$" ] # better to be safe and avoid failures -max-retries = 6 +max_retries = 6