Skip to content

Commit b1dd06e

Browse files
committed
BUG: Fix docs build broken link check bug
1 parent be1d8be commit b1dd06e

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

.github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,4 @@ jobs:
5353
run: time catchsegv python -m backtesting.test
5454

5555
- if: matrix.test-type == 'docs'
56-
run: time catchsegv doc/build.sh
56+
run: time catchsegv bash doc/build.sh

doc/build.sh

+8-3
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,15 @@ echo
7171
echo 'Testing for broken links'
7272
echo
7373
pushd "$BUILDROOT" >/dev/null
74+
tree .
7475
WEBSITE='https://kernc\.github\.io/backtesting\.py'
7576
grep -PR '<a .*?href=' |
7677
sed -E "s/:.*?<a .*?href=([\"'])(.*?)/\t\2/g" |
7778
tr "\"'" '#' |
7879
cut -d'#' -f1 |
7980
sort -u -t$'\t' -k 2 |
8081
sort -u |
82+
tee >(cat 1>&2) |
8183
python -c '
8284
import sys
8385
from urllib.parse import urljoin
@@ -90,9 +92,12 @@ for line in sys.stdin.readlines():
9092
grep -v $'\t''$' |
9193
while read -r line; do
9294
while IFS=$'\t' read -r file url; do
93-
url=$(python -c 'import html, sys; print(html.unescape(sys.argv[-1]))' "$url")
94-
[ -f "$url" ] ||
95-
curl --silent --fail --retry 5 --retry-delay 5 --user-agent 'Mozilla/5.0 Firefox 61' "$url" >/dev/null 2>&1 ||
95+
target_file="$(python -c 'import html, sys; print(html.unescape(sys.argv[-1]))' "$url")"
96+
echo "$target_file"
97+
if [ -f "$target_file" ]; then continue; fi
98+
99+
url="${url// /%20}"
100+
curl --silent --fail --retry 5 --retry-delay 5 --user-agent 'Mozilla/5.0 Firefox 61' "$url" >/dev/null 2>&1 ||
96101
die "broken link in $file: $url"
97102
done
98103
done

0 commit comments

Comments
 (0)