Skip to content

Commit 4415063

Browse files
authored
Merge pull request #4104 from grandixximo/docs/checkref-no-false-pass
docs: make HTML link checking actually run, and never false-pass
2 parents 64ee649 + 4a3e0d0 commit 4415063

3 files changed

Lines changed: 42 additions & 5 deletions

File tree

docs/src/Submakefile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -481,15 +481,19 @@ checkref: $(CHECKREF_TARGETS)
481481
# so it only re-runs when the HTML changes. .htmldoc-stamp is filtered out
482482
# of the args so the stamp file is not handed to the link checker.
483483
checkref_en: $(DOC_DIR)/.checkref-english-stamp
484+
# --warn-on-failure: link checking has been a silent no-op for a long time
485+
# (w3c-linkchecker disables file:// URIs), so the tree may carry accumulated
486+
# broken links. Report them without breaking the build for now; drop this
487+
# flag once the backlog is cleared so regressions fail the build again.
484488
$(DOC_DIR)/.checkref-english-stamp: $(DOC_TARGETS_HTML_EN) $(DOC_DIR)/html/index.html $(DOC_DIR)/html/gcode.html .htmldoc-stamp
485-
$(DOC_SRCDIR)/checkref English $(filter %.html,$^)
489+
$(DOC_SRCDIR)/checkref --warn-on-failure English $(filter %.html,$^)
486490
@touch $@
487491

488492
# Pattern rule for all languages
489493
checkref_%: $(DOC_DIR)/.checkref-%-stamp ;
490494
$(DOC_DIR)/.checkref-%-stamp: $$(DOC_TARGETS_HTML_$$(call uc,$$*)) \
491495
$$(DOC_DIR)/html/%/gcode.html .htmldoc-stamp
492-
$(DOC_SRCDIR)/checkref $(call lang_name,$*) $(filter %.html,$$^)
496+
$(DOC_SRCDIR)/checkref --warn-on-failure $(call lang_name,$*) $(filter %.html,$$^)
493497
@touch $@
494498

495499

docs/src/checkref

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,28 @@ fi
1717

1818

1919
BAD_LINKS=0
20+
CHECKED=0
21+
SKIPPED=0
2022
for F in "$@"; do
2123
OUT=.checklink.$LANGUAGE.$(basename "$F").tmp
2224
rm -f "$OUT"
23-
linuxcnc-checklink --quiet --exclude "(http|https|irc)://" "$F" 2>&1 | tee "$OUT"
25+
# --follow-file-links is required: recent w3c-linkchecker refuses file://
26+
# URIs by default, so without it checklink never inspects the local file
27+
# and validates nothing.
28+
linuxcnc-checklink --quiet --follow-file-links --exclude "(http|https|irc)://" "$F" 2>&1 | tee "$OUT"
29+
STATUS=${PIPESTATUS[0]}
30+
# Distinguish "checklink never inspected the file" from "checklink ran and
31+
# found problems". It exits 64 when it reports broken links, so a nonzero
32+
# exit is not itself a failure; only a shell exec failure (126/127) or an
33+
# explicit refusal to read the document means nothing was validated.
34+
if [ "$STATUS" -eq 126 ] || [ "$STATUS" -eq 127 ] || \
35+
grep -E -q "(Access to 'file' URIs has been disabled|checklink not configured)" "$OUT"; then
36+
echo "*** warning: linuxcnc-checklink could not validate $(basename "$F"); skipped" 1>&2
37+
SKIPPED=$((SKIPPED + 1))
38+
rm -f "$OUT"
39+
continue
40+
fi
41+
CHECKED=$((CHECKED + 1))
2442
if grep -E -q 'List of (broken links and other issues|duplicate and empty anchors)' "$OUT"; then
2543
BAD_LINKS=1
2644
fi
@@ -37,10 +55,22 @@ if [ $BAD_LINKS -eq 1 ]; then
3755
fi
3856
echo "***" 1>&2
3957
exit $RET_VAL
58+
elif [ $CHECKED -eq 0 ]; then
59+
# Nothing validated: warn instead of claiming success, but do not fail
60+
# the build (an unusable checklink is an environment problem).
61+
echo "***" 1>&2
62+
echo "*** warning: link checking skipped for $LANGUAGE docs;" 1>&2
63+
echo "*** linuxcnc-checklink validated no files ($SKIPPED skipped)." 1>&2
64+
echo "*** install w3c-linkchecker and re-run ./configure to enable it." 1>&2
65+
echo "***" 1>&2
4066
else
4167
echo "###"
4268
echo "### language: $LANGUAGE"
43-
echo "### all links are good!"
69+
if [ $SKIPPED -gt 0 ]; then
70+
echo "### checked links are good ($SKIPPED file(s) skipped)!"
71+
else
72+
echo "### all links are good!"
73+
fi
4474
echo "###"
4575
fi
4676

scripts/linuxcnc-checklink.in

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
#!/bin/sh
2-
exec "@CHECKLINK@" "$@"
2+
# Fail clearly if configure left @CHECKLINK@ empty, rather than with the
3+
# cryptic "exec: : Permission denied".
4+
CHECKLINK="@CHECKLINK@"
5+
exec "${CHECKLINK:?checklink not configured; install w3c-linkchecker and re-run ./configure}" "$@"

0 commit comments

Comments
 (0)