Some checks failed
Test / test (push) Has been cancelled
Co-authored-by: Cursor <cursoragent@cursor.com>
112 lines
2.8 KiB
Bash
Executable File
112 lines
2.8 KiB
Bash
Executable File
#!/bin/bash
|
|
source ~/.bashrc
|
|
# Validate Documentation
|
|
# Checks for broken links, outdated content, and documentation issues
|
|
|
|
set -e
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
|
|
DOCS_DIR="$PROJECT_ROOT/docs"
|
|
|
|
# Colors
|
|
RED='\033[0;31m'
|
|
GREEN='\033[0;32m'
|
|
YELLOW='\033[1;33m'
|
|
NC='\033[0m'
|
|
|
|
log_info() {
|
|
echo -e "${GREEN}[INFO]${NC} $1"
|
|
}
|
|
|
|
log_warn() {
|
|
echo -e "${YELLOW}[WARN]${NC} $1"
|
|
}
|
|
|
|
log_error() {
|
|
echo -e "${RED}[ERROR]${NC} $1"
|
|
}
|
|
|
|
check_markdown_links() {
|
|
log_info "Checking markdown links..."
|
|
local errors=0
|
|
|
|
while IFS= read -r -d '' file; do
|
|
# Extract links from markdown files
|
|
while IFS= read -r line; do
|
|
if [[ $line =~ \[([^\]]+)\]\(([^)]+)\) ]]; then
|
|
link="${BASH_REMATCH[2]}"
|
|
# Skip external links
|
|
if [[ ! $link =~ ^https?:// ]]; then
|
|
# Remove anchor
|
|
link_file="${link%%#*}"
|
|
if [ -n "$link_file" ] && [ ! -f "$DOCS_DIR/$link_file" ] && [ ! -f "$(dirname "$file")/$link_file" ]; then
|
|
log_error "Broken link in $(basename "$file"): $link"
|
|
errors=$((errors + 1))
|
|
fi
|
|
fi
|
|
fi
|
|
done < "$file"
|
|
done < <(find "$DOCS_DIR" -name "*.md" -type f -print0)
|
|
|
|
if [ $errors -eq 0 ]; then
|
|
log_info "All markdown links are valid"
|
|
else
|
|
log_error "Found $errors broken link(s)"
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
check_missing_files() {
|
|
log_info "Checking for missing documentation files..."
|
|
local missing=0
|
|
|
|
# Check for expected files
|
|
expected_files=(
|
|
"getting-started/quick-start.md"
|
|
"getting-started/prerequisites.md"
|
|
"getting-started/installation.md"
|
|
"architecture/overview.md"
|
|
"deployment/deployment-guide.md"
|
|
)
|
|
|
|
for file in "${expected_files[@]}"; do
|
|
if [ ! -f "$DOCS_DIR/$file" ]; then
|
|
log_warn "Missing expected file: $file"
|
|
missing=$((missing + 1))
|
|
fi
|
|
done
|
|
|
|
if [ $missing -eq 0 ]; then
|
|
log_info "All expected documentation files exist"
|
|
else
|
|
log_warn "Found $missing missing file(s)"
|
|
fi
|
|
}
|
|
|
|
check_index() {
|
|
log_info "Checking documentation index..."
|
|
if [ ! -f "$DOCS_DIR/INDEX.md" ]; then
|
|
log_error "Documentation index (INDEX.md) not found"
|
|
log_info "Run ./scripts/docs/generate-docs-index.sh to generate it"
|
|
return 1
|
|
else
|
|
log_info "Documentation index exists"
|
|
fi
|
|
}
|
|
|
|
main() {
|
|
log_info "Validating documentation..."
|
|
echo ""
|
|
|
|
check_index
|
|
check_missing_files
|
|
check_markdown_links
|
|
|
|
echo ""
|
|
log_info "Documentation validation complete"
|
|
}
|
|
|
|
main "$@"
|
|
|