-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathvalidate_links.sh
More file actions
executable file
·42 lines (31 loc) · 872 Bytes
/
validate_links.sh
File metadata and controls
executable file
·42 lines (31 loc) · 872 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/bin/bash
echo "Validating documentation links in README.md..."
echo ""
# Extract all markdown links (macOS compatible)
grep -E '\[.*\]\(.*\)' README.md | sed 's/.*\[\(.*\)\](\(.*\)).*/\2/' | grep -v "^http" | grep -v "^#" > /tmp/links.txt
broken_links=0
valid_links=0
echo "Checking documentation file links:"
echo ""
while read link; do
# Skip empty lines
[ -z "$link" ] && continue
# Remove anchors for file checking
file_path=${link%#*}
# Check if file exists
if [ -f "$file_path" ]; then
echo "✓ $link"
((valid_links++))
else
echo "✗ BROKEN: $link (file not found: $file_path)"
((broken_links++))
fi
done < /tmp/links.txt
echo ""
echo "Summary: $valid_links valid links, $broken_links broken links"
if [ $broken_links -gt 0 ]; then
echo ""
echo "Broken links found:"
fi
rm -f /tmp/links.txt
exit $broken_links