diff options
author | Ian Jackson <ijackson@chiark.greenend.org.uk> | 2023-11-07 12:04:04 +0000 |
---|---|---|
committer | Ian Jackson <ijackson@chiark.greenend.org.uk> | 2023-11-07 12:25:27 +0000 |
commit | f645dba5b493ac7e6d73fc7f11363761b6e372e0 (patch) | |
tree | 3a87a8cf73f1f687bded61ebe42a2c6b7d85f785 | |
parent | 897072238d84a8609b07905548dd7ff1602f568d (diff) | |
download | torspec-f645dba5b493ac7e6d73fc7f11363761b6e372e0.tar.gz torspec-f645dba5b493ac7e6d73fc7f11363761b6e372e0.zip |
linklint: Add link checking script
-rw-r--r-- | .gitignore | 3 | ||||
-rwxr-xr-x | bin/check_links | 40 |
2 files changed, 43 insertions, 0 deletions
@@ -14,3 +14,6 @@ # mdbook outputs /html + +# bin/check_links output +/html.link-check diff --git a/bin/check_links b/bin/check_links new file mode 100755 index 0000000..890ac30 --- /dev/null +++ b/bin/check_links @@ -0,0 +1,40 @@ +#!/bin/bash +# +# Check rustdoc HTML links and anchors +# bin/build_html must have been run first. +# +# Adapted from +# https://gitlab.torproject.org/Diziet/rust-derive-adhoc/-/blob/main/maint/check-doc-links?ref_type=heads + +set -e +set -o pipefail + +# nailing-cargo --no-nail --- bin/build_html +# nailing-cargo --preclean=no --- bin/check_links + +chk_dir=html.link-check + +rm -rf html.link-check +cp -al html $chk_dir + +# Fix up https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=425632 + +find $chk_dir -name \*.html -print0 | +xargs -0r -- perl -i~ -pe ' + s{\bid=("[^"]+")[^<>]*\>}{$&<a name=$1>}g; +' + +linklint -out linklint.errors -error -root $chk_dir / + +cat linklint.errors + +set +e +grep ERROR linklint.errors +rc=$? +set -e + +case $rc in +0) echo >&2 '** found linkcheck errors **'; exit 1;; +1) ;; +*) echo >&2 "linkcheck failed $rc"; exit 1;; +esac |