@@ -894,143 +894,6 @@ runs:
894894 BROKEN_IMAGES=0
895895 TOTAL_REFS=0
896896
897- # 1. Check for references to deleted files
898- if [ "$DELETED_FILES_JSON" \!= "[]" ] && [ -n "$DELETED_FILES_JSON" ]; then
899- echo "Checking for references to deleted files..."
900-
901- # Extract deleted file list without extensions for matching
902- DELETED_FILES=$(echo "$DELETED_FILES_JSON" | jq -r '.[] | select(endswith(".md"))' | sed 's/\.md$//' | sort)
903-
904- if [ -n "$DELETED_FILES" ]; then
905- # For each deleted file, check if any existing files reference it
906- echo "$DELETED_FILES" | while read -r deleted_file; do
907- # Skip empty lines
908- [ -z "$deleted_file" ] && continue
909-
910- # Extract filename portion for matching
911- deleted_name=$(basename "$deleted_file")
912-
913- # Use grep to find references to this file across all docs
914- echo "Checking references to: $deleted_name"
915- REFS_TO_DELETED=$(grep -l -r --include="*.md" "\[$deleted_name\]" "$DOCS_DIR" 2>/dev/null || echo "")
916-
917- if [ -n "$REFS_TO_DELETED" ]; then
918- echo "::warning::Found references to deleted file '$deleted_name' in these files:"
919- echo "$REFS_TO_DELETED" | sed 's/^/ - /'
920- BROKEN_REFS=$((BROKEN_REFS + 1))
921- fi
922- done
923- fi
924- fi
925-
926- # 2. Check for broken internal links in changed files
927- if [ "$CHANGED_FILES_JSON" \!= "[]" ] && [ -n "$CHANGED_FILES_JSON" ]; then
928- echo "Checking for broken internal links in changed files..."
929-
930- echo "$CHANGED_FILES_JSON" | jq -r '.[]' | grep '\.md$' | while read -r file; do
931- # Skip empty lines
932- [ -z "$file" ] && continue
933-
934- # Extract all internal links with the [text](link) pattern
935- LINKS=$(grep -o -E '\[.+?\]\(\s*[^(http|https|mailto|#)][^)]+\s*\)' "$file" 2>/dev/null || echo "")
936-
937- if [ -n "$LINKS" ]; then
938- # For each link, check if the target exists
939- echo "$LINKS" | while read -r link_match; do
940- # Extract just the URL part from [text](url)
941- link_url=$(echo "$link_match" | sed -E 's/\[.+?\]\(\s*([^)]+)\s*\)/\1/')
942-
943- # Count total refs
944- TOTAL_REFS=$((TOTAL_REFS + 1))
945-
946- # Handle relative links correctly
947- if [[ "$link_url" == /* ]]; then
948- # Absolute path from repo root
949- link_path="$link_url"
950- else
951- # Relative path, get directory of current file
952- file_dir=$(dirname "$file")
953- link_path="$file_dir/$link_url"
954- fi
955-
956- # Remove any anchor fragment
957- link_path=$(echo "$link_path" | sed 's/#.*//')
958-
959- # Normalize path (add .md if missing)
960- if [[ \! "$link_path" =~ \.[a-zA-Z0-9]+$ ]]; then
961- link_path="${link_path}.md"
962- fi
963-
964- # Clean up the path (remove double slashes, etc.)
965- link_path=$(echo "$link_path" | sed 's@//@/@g' | sed 's@\./@/@g')
966-
967- # Check if the link target exists
968- if [ \! -f "$link_path" ]; then
969- echo "::warning::Broken link in $file: $link_match -> $link_path (file not found)"
970- BROKEN_REFS=$((BROKEN_REFS + 1))
971- fi
972- done
973- fi
974- done
975- fi
976-
977- # 3. Check for broken image references
978- if [ "$CHANGED_FILES_JSON" \!= "[]" ] && [ -n "$CHANGED_FILES_JSON" ]; then
979- echo "Checking for broken image references..."
980-
981- echo "$CHANGED_FILES_JSON" | jq -r '.[]' | grep '\.md$' | while read -r file; do
982- # Skip empty lines
983- [ -z "$file" ] && continue
984-
985- # Extract all image references with the \ pattern
986- IMAGES=$(grep -o -E '\!\[.+?\]\(\s*[^(http|https)][^)]+\s*\)' "$file" 2>/dev/null || echo "")
987-
988- if [ -n "$IMAGES" ]; then
989- # For each image, check if it exists
990- echo "$IMAGES" | while read -r img_match; do
991- # Extract just the URL part from \
992- img_url=$(echo "$img_match" | sed -E 's/\!\[.+?\]\(\s*([^)]+)\s*\)/\1/')
993-
994- # Handle relative paths correctly
995- if [[ "$img_url" == /* ]]; then
996- # Absolute path from repo root
997- img_path="$img_url"
998- else
999- # Relative path, get directory of current file
1000- file_dir=$(dirname "$file")
1001- img_path="$file_dir/$img_url"
1002- fi
1003-
1004- # Clean up the path
1005- img_path=$(echo "$img_path" | sed 's@//@/@g' | sed 's@\./@/@g')
1006-
1007- # Check if the image exists
1008- if [ \! -f "$img_path" ]; then
1009- echo "::warning::Broken image in $file: $img_match -> $img_path (file not found)"
1010- BROKEN_IMAGES=$((BROKEN_IMAGES + 1))
1011- fi
1012- done
1013- fi
1014- done
1015- fi
1016-
1017- # Determine status based on findings
1018- if [ $BROKEN_REFS -eq 0 ] && [ $BROKEN_IMAGES -eq 0 ]; then
1019- echo "No broken cross-references found\!"
1020- echo "status=success" >> $GITHUB_OUTPUT
1021- echo "message=No broken cross-references found ($TOTAL_REFS refs checked)" >> $GITHUB_OUTPUT
1022- else
1023- # Make this a warning, not an error, to still allow preview generation
1024- echo "status=warning" >> $GITHUB_OUTPUT
1025- echo "message=Found $BROKEN_REFS broken links and $BROKEN_IMAGES broken images" >> $GITHUB_OUTPUT
1026- echo "broken_refs=$BROKEN_REFS" >> $GITHUB_OUTPUT
1027- echo "broken_images=$BROKEN_IMAGES" >> $GITHUB_OUTPUT
1028- fi
1029- # Initialize results tracking
1030- BROKEN_REFS=0
1031- BROKEN_IMAGES=0
1032- TOTAL_REFS=0
1033-
1034897 # Set default value for DELETED_FILES_JSON if not provided
1035898 if [ -z "$DELETED_FILES_JSON" ]; then
1036899 DELETED_FILES_JSON="[]"
@@ -1452,6 +1315,29 @@ runs:
14521315 if [ -n "$RESULTS_ARRAY" ]; then
14531316 has_issues="true"
14541317 GH_COMMENT+="The detailed validation status is available in the \"Documentation Validation\" check in this PR. Common issues and solutions:\n\n"
1318+
1319+ # Add specific issues
1320+ GH_COMMENT+="### Detected Issues\n\n"
1321+
1322+ echo "$RESULTS_ARRAY" | while read -r result; do
1323+ name=$(echo "$result" | jq -r '.name')
1324+ guidance=$(echo "$result" | jq -r '.guidance')
1325+ fix_command=$(echo "$result" | jq -r '.fix_command')
1326+
1327+ GH_COMMENT+="#### $name\n\n"
1328+ GH_COMMENT+="$guidance\n\n"
1329+
1330+ if [ -n "$fix_command" ] && [ "$fix_command" != "null" ]; then
1331+ GH_COMMENT+="```bash\n$fix_command\n```\n\n"
1332+ fi
1333+ done
1334+ else
1335+ # Even when there are no issues, provide helpful guidance
1336+ GH_COMMENT+="All validation checks passed! ✅\n\n"
1337+ GH_COMMENT+="The detailed validation status is available in the \"Documentation Validation\" check in this PR. Common tasks:\n\n"
1338+ GH_COMMENT+="- **Check links**: Run \`pnpm run docs:check-links\` locally\n"
1339+ GH_COMMENT+="- **Format documents**: Run \`pnpm run docs:fix\` locally\n"
1340+ GH_COMMENT+="- **Preview changes**: Use the preview links above\n"
14551341 fi
14561342 else
14571343 # Default to showing help for error cases
@@ -1462,29 +1348,6 @@ runs:
14621348 GH_COMMENT+="- **Link issues**: Run \`pnpm run docs:check-links\` locally\n"
14631349 GH_COMMENT+="- **Style issues**: Run \`pnpm run docs:fix\` locally\n"
14641350 GH_COMMENT+="- **Cross-reference issues**: Check heading IDs and link references\n\n"
1465-
1466- # Add specific issues
1467- GH_COMMENT+="### Detected Issues\n\n"
1468-
1469- echo "$RESULTS_ARRAY" | while read -r result; do
1470- name=$(echo "$result" | jq -r '.name')
1471- guidance=$(echo "$result" | jq -r '.guidance')
1472- fix_command=$(echo "$result" | jq -r '.fix_command')
1473-
1474- GH_COMMENT+="#### $name\n\n"
1475- GH_COMMENT+="$guidance\n\n"
1476-
1477- if [ -n "$fix_command" ] && [ "$fix_command" != "null" ]; then
1478- GH_COMMENT+="```bash\n$fix_command\n```\n\n"
1479- fi
1480- done
1481- else
1482- # Even when there are no issues, provide helpful guidance
1483- GH_COMMENT+="All validation checks passed! ✅\n\n"
1484- GH_COMMENT+="The detailed validation status is available in the \"Documentation Validation\" check in this PR. Common tasks:\n\n"
1485- GH_COMMENT+="- **Check links**: Run \`pnpm run docs:check-links\` locally\n"
1486- GH_COMMENT+="- **Format documents**: Run \`pnpm run docs:fix\` locally\n"
1487- GH_COMMENT+="- **Preview changes**: Use the preview links above\n"
14881351 fi
14891352
14901353 GH_COMMENT+="</details>\n\n"
0 commit comments