mirror of
https://github.com/alexhopeoconnor/arduino-home-assistant.git
synced 2026-10-04 02:48:13 +10:00
28 lines
1.1 KiB
Bash
Executable File
28 lines
1.1 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
required=(
|
|
README.md CHANGELOG.md
|
|
docs/README.md docs/getting-started.md docs/device-and-discovery.md docs/mqtt-usage.md docs/entities.md
|
|
examples/README.md
|
|
)
|
|
|
|
for path in "${required[@]}"; do
|
|
[[ -f "$root/$path" ]] || { echo "Missing required documentation: $path" >&2; exit 1; }
|
|
done
|
|
|
|
while IFS= read -r -d '' markdown; do
|
|
while IFS= read -r target; do
|
|
[[ -z "$target" || "$target" == \#* || "$target" == http://* || "$target" == https://* || "$target" == mailto:* ]] && continue
|
|
target="${target%%#*}"
|
|
case "$target" in
|
|
/*) candidate="$root/${target#/}" ;;
|
|
*) candidate="$(dirname "$markdown")/$target" ;;
|
|
esac
|
|
[[ -e "$candidate" ]] || { echo "Broken relative link in ${markdown#$root/}: $target" >&2; exit 1; }
|
|
done < <(sed -nE 's/.*\]\(([^ )]+)( "[^"]*")?\).*/\1/p' "$markdown")
|
|
done < <(find "$root" -path "$root/.git" -prune -o -name '*.md' -type f -print0)
|
|
|
|
echo "Documentation links and required files passed"
|