Add detailed definitions, pronunciations, usage examples, and related terms for key concepts in GLOSSARY.md. Update DBIS_Institutional_Book_Structure.md to include page numbers in the Table of Contents, List of Figures, and List of Tables, along with a Quick Navigation section for improved accessibility and organization.
This commit is contained in:
231
scripts/verify_cross_references.sh
Executable file
231
scripts/verify_cross_references.sh
Executable file
@@ -0,0 +1,231 @@
|
||||
#!/bin/bash
|
||||
# DBIS Cross-Reference Verification Script
|
||||
# Automated link verification and cross-reference checking
|
||||
|
||||
set -e
|
||||
|
||||
# Colors for output
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# Configuration
|
||||
PROJECT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
REPORT_FILE="${PROJECT_ROOT}/CROSS_REFERENCE_VERIFICATION_REPORT.md"
|
||||
BROKEN_LINKS=()
|
||||
MISSING_FILES=()
|
||||
INVALID_ANCHORS=()
|
||||
TOTAL_LINKS=0
|
||||
VALID_LINKS=0
|
||||
|
||||
echo "=========================================="
|
||||
echo "DBIS Cross-Reference Verification"
|
||||
echo "=========================================="
|
||||
echo ""
|
||||
|
||||
# Function to extract markdown links
|
||||
extract_links() {
|
||||
local file="$1"
|
||||
grep -oE '\[([^\]]+)\]\(([^)]+)\)' "$file" | while IFS= read -r link; do
|
||||
echo "$link"
|
||||
done
|
||||
}
|
||||
|
||||
# Function to verify file link
|
||||
verify_file_link() {
|
||||
local link_path="$1"
|
||||
local source_file="$2"
|
||||
local source_dir="$(dirname "$source_file")"
|
||||
|
||||
# Handle relative paths
|
||||
if [[ "$link_path" == /* ]]; then
|
||||
# Absolute path from project root
|
||||
full_path="${PROJECT_ROOT}${link_path}"
|
||||
elif [[ "$link_path" == ../* ]]; then
|
||||
# Relative path going up
|
||||
full_path="$(cd "$source_dir" && cd "$(dirname "$link_path")" && pwd)/$(basename "$link_path")"
|
||||
else
|
||||
# Relative path in same directory
|
||||
full_path="${source_dir}/${link_path}"
|
||||
fi
|
||||
|
||||
# Remove anchor if present
|
||||
file_path="${full_path%%#*}"
|
||||
|
||||
if [[ -f "$file_path" ]]; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to verify anchor
|
||||
verify_anchor() {
|
||||
local file_path="$1"
|
||||
local anchor="$2"
|
||||
|
||||
if [[ -z "$anchor" ]]; then
|
||||
return 0 # No anchor to verify
|
||||
fi
|
||||
|
||||
# Check if anchor exists in file (simplified check)
|
||||
if grep -q "^#*.*${anchor}" "$file_path" 2>/dev/null; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Main verification process
|
||||
echo "Scanning markdown files..."
|
||||
echo ""
|
||||
|
||||
find "$PROJECT_ROOT" -name "*.md" -type f | while IFS= read -r file; do
|
||||
# Skip certain directories
|
||||
if [[ "$file" == *"/node_modules/"* ]] || [[ "$file" == *"/.git/"* ]]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
relative_file="${file#$PROJECT_ROOT/}"
|
||||
|
||||
# Extract all links from file
|
||||
while IFS= read -r link_line; do
|
||||
if [[ -z "$link_line" ]]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
# Extract link text and path
|
||||
if [[ "$link_line" =~ \[([^\]]+)\]\(([^)]+)\) ]]; then
|
||||
link_text="${BASH_REMATCH[1]}"
|
||||
link_path="${BASH_REMATCH[2]}"
|
||||
|
||||
TOTAL_LINKS=$((TOTAL_LINKS + 1))
|
||||
|
||||
# Skip external links
|
||||
if [[ "$link_path" == http://* ]] || [[ "$link_path" == https://* ]] || [[ "$link_path" == mailto:* ]]; then
|
||||
VALID_LINKS=$((VALID_LINKS + 1))
|
||||
continue
|
||||
fi
|
||||
|
||||
# Split path and anchor
|
||||
if [[ "$link_path" == *"#"* ]]; then
|
||||
file_part="${link_path%%#*}"
|
||||
anchor_part="${link_path#*#}"
|
||||
else
|
||||
file_part="$link_path"
|
||||
anchor_part=""
|
||||
fi
|
||||
|
||||
# Verify file
|
||||
if verify_file_link "$file_part" "$file"; then
|
||||
# Get full file path
|
||||
source_dir="$(dirname "$file")"
|
||||
if [[ "$file_part" == /* ]]; then
|
||||
full_file_path="${PROJECT_ROOT}${file_part}"
|
||||
elif [[ "$file_part" == ../* ]]; then
|
||||
full_file_path="$(cd "$source_dir" && cd "$(dirname "$file_part")" && pwd)/$(basename "$file_part")"
|
||||
else
|
||||
full_file_path="${source_dir}/${file_part}"
|
||||
fi
|
||||
|
||||
# Verify anchor if present
|
||||
if [[ -n "$anchor_part" ]]; then
|
||||
if verify_anchor "$full_file_path" "$anchor_part"; then
|
||||
VALID_LINKS=$((VALID_LINKS + 1))
|
||||
else
|
||||
INVALID_ANCHORS+=("$relative_file -> $link_path (anchor: $anchor_part)")
|
||||
echo -e "${YELLOW}WARNING:${NC} Invalid anchor in $relative_file: $link_path"
|
||||
fi
|
||||
else
|
||||
VALID_LINKS=$((VALID_LINKS + 1))
|
||||
fi
|
||||
else
|
||||
BROKEN_LINKS+=("$relative_file -> $link_path")
|
||||
MISSING_FILES+=("$link_path")
|
||||
echo -e "${RED}ERROR:${NC} Broken link in $relative_file: $link_path"
|
||||
fi
|
||||
fi
|
||||
done < <(extract_links "$file")
|
||||
done
|
||||
|
||||
# Generate report
|
||||
echo ""
|
||||
echo "=========================================="
|
||||
echo "Verification Summary"
|
||||
echo "=========================================="
|
||||
echo ""
|
||||
echo "Total Links Found: $TOTAL_LINKS"
|
||||
echo "Valid Links: $VALID_LINKS"
|
||||
echo "Broken Links: ${#BROKEN_LINKS[@]}"
|
||||
echo "Invalid Anchors: ${#INVALID_ANCHORS[@]}"
|
||||
echo ""
|
||||
|
||||
# Create report file
|
||||
cat > "$REPORT_FILE" << EOF
|
||||
# CROSS-REFERENCE VERIFICATION REPORT
|
||||
## Automated Link Verification Results
|
||||
|
||||
**Generated:** $(date -u +"%Y-%m-%d %H:%M:%S UTC")
|
||||
**Project Root:** $PROJECT_ROOT
|
||||
|
||||
---
|
||||
|
||||
## SUMMARY
|
||||
|
||||
- **Total Links Scanned:** $TOTAL_LINKS
|
||||
- **Valid Links:** $VALID_LINKS
|
||||
- **Broken Links:** ${#BROKEN_LINKS[@]}
|
||||
- **Invalid Anchors:** ${#INVALID_ANCHORS[@]}
|
||||
- **Success Rate:** $(awk "BEGIN {printf \"%.2f\", ($VALID_LINKS/$TOTAL_LINKS)*100}")%
|
||||
|
||||
---
|
||||
|
||||
## BROKEN LINKS
|
||||
|
||||
EOF
|
||||
|
||||
if [[ ${#BROKEN_LINKS[@]} -eq 0 ]]; then
|
||||
echo "✅ No broken links found!" >> "$REPORT_FILE"
|
||||
else
|
||||
for link in "${BROKEN_LINKS[@]}"; do
|
||||
echo "- $link" >> "$REPORT_FILE"
|
||||
done
|
||||
fi
|
||||
|
||||
cat >> "$REPORT_FILE" << EOF
|
||||
|
||||
---
|
||||
|
||||
## INVALID ANCHORS
|
||||
|
||||
EOF
|
||||
|
||||
if [[ ${#INVALID_ANCHORS[@]} -eq 0 ]]; then
|
||||
echo "✅ No invalid anchors found!" >> "$REPORT_FILE"
|
||||
else
|
||||
for anchor in "${INVALID_ANCHORS[@]}"; do
|
||||
echo "- $anchor" >> "$REPORT_FILE"
|
||||
done
|
||||
fi
|
||||
|
||||
cat >> "$REPORT_FILE" << EOF
|
||||
|
||||
---
|
||||
|
||||
## RECOMMENDATIONS
|
||||
|
||||
1. Fix all broken links identified above
|
||||
2. Verify and correct invalid anchors
|
||||
3. Update cross-references in affected documents
|
||||
4. Re-run verification after fixes
|
||||
|
||||
---
|
||||
|
||||
**END OF VERIFICATION REPORT**
|
||||
EOF
|
||||
|
||||
echo "Report generated: $REPORT_FILE"
|
||||
echo ""
|
||||
echo -e "${GREEN}Verification complete!${NC}"
|
||||
|
||||
189
scripts/verify_cross_references_simple.sh
Executable file
189
scripts/verify_cross_references_simple.sh
Executable file
@@ -0,0 +1,189 @@
|
||||
#!/bin/bash
|
||||
# DBIS Cross-Reference Verification Script (Simplified)
|
||||
# Automated link verification and cross-reference checking
|
||||
|
||||
set -e
|
||||
|
||||
# Colors for output
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# Configuration
|
||||
PROJECT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
REPORT_FILE="${PROJECT_ROOT}/CROSS_REFERENCE_VERIFICATION_REPORT.md"
|
||||
BROKEN_LINKS_FILE="${PROJECT_ROOT}/BROKEN_LINKS.txt"
|
||||
TOTAL_LINKS=0
|
||||
VALID_LINKS=0
|
||||
BROKEN_COUNT=0
|
||||
|
||||
echo "=========================================="
|
||||
echo "DBIS Cross-Reference Verification"
|
||||
echo "=========================================="
|
||||
echo ""
|
||||
echo -e "${BLUE}Project Root:${NC} $PROJECT_ROOT"
|
||||
echo ""
|
||||
|
||||
# Initialize report
|
||||
cat > "$REPORT_FILE" << 'EOF'
|
||||
# CROSS-REFERENCE VERIFICATION REPORT
|
||||
## Automated Link Verification Results
|
||||
|
||||
**Generated:**
|
||||
**Project Root:**
|
||||
|
||||
---
|
||||
|
||||
## SUMMARY
|
||||
|
||||
- **Total Links Scanned:** 0
|
||||
- **Valid Links:** 0
|
||||
- **Broken Links:** 0
|
||||
- **Success Rate:** 0.00%
|
||||
|
||||
---
|
||||
|
||||
## BROKEN LINKS
|
||||
|
||||
EOF
|
||||
|
||||
# Function to check if file exists
|
||||
check_file_exists() {
|
||||
local file_path="$1"
|
||||
local source_file="$2"
|
||||
local source_dir="$(dirname "$source_file")"
|
||||
|
||||
# Handle different path types
|
||||
if [[ "$file_path" == http://* ]] || [[ "$file_path" == https://* ]] || [[ "$file_path" == mailto:* ]]; then
|
||||
return 0 # External links - skip for now
|
||||
fi
|
||||
|
||||
# Handle relative paths
|
||||
if [[ "$file_path" == /* ]]; then
|
||||
# Absolute path from project root
|
||||
full_path="${PROJECT_ROOT}${file_path}"
|
||||
elif [[ "$file_path" == ../* ]]; then
|
||||
# Relative path going up
|
||||
resolved_path="$(cd "$source_dir" && cd "$(dirname "$file_path")" 2>/dev/null && pwd)/$(basename "$file_path")"
|
||||
if [[ -f "$resolved_path" ]]; then
|
||||
return 0
|
||||
fi
|
||||
else
|
||||
# Relative path in same directory or subdirectory
|
||||
full_path="${source_dir}/${file_path}"
|
||||
fi
|
||||
|
||||
# Remove anchor if present
|
||||
file_only="${full_path%%#*}"
|
||||
|
||||
if [[ -f "$file_only" ]]; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Main verification process
|
||||
echo -e "${BLUE}Scanning markdown files...${NC}"
|
||||
echo ""
|
||||
|
||||
find "$PROJECT_ROOT" -name "*.md" -type f | while IFS= read -r file; do
|
||||
# Skip certain directories
|
||||
if [[ "$file" == *"/node_modules/"* ]] || [[ "$file" == *"/.git/"* ]] || [[ "$file" == *"/scripts/"* ]]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
relative_file="${file#$PROJECT_ROOT/}"
|
||||
|
||||
# Extract markdown links using grep
|
||||
grep -oE '\[([^\]]+)\]\(([^)]+)\)' "$file" 2>/dev/null | while IFS= read -r link_match; do
|
||||
# Extract the path part (between parentheses)
|
||||
link_path=$(echo "$link_match" | sed -n 's/.*(\(.*\))/\1/p')
|
||||
|
||||
if [[ -z "$link_path" ]]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
TOTAL_LINKS=$((TOTAL_LINKS + 1))
|
||||
|
||||
# Skip external links
|
||||
if [[ "$link_path" == http://* ]] || [[ "$link_path" == https://* ]] || [[ "$link_path" == mailto:* ]]; then
|
||||
VALID_LINKS=$((VALID_LINKS + 1))
|
||||
continue
|
||||
fi
|
||||
|
||||
# Check if file exists
|
||||
if check_file_exists "$link_path" "$file"; then
|
||||
VALID_LINKS=$((VALID_LINKS + 1))
|
||||
else
|
||||
BROKEN_COUNT=$((BROKEN_COUNT + 1))
|
||||
echo -e "${RED}✗${NC} $relative_file -> $link_path" | tee -a "$BROKEN_LINKS_FILE"
|
||||
fi
|
||||
done
|
||||
done
|
||||
|
||||
# Update report with summary
|
||||
{
|
||||
echo "**Generated:** $(date -u +"%Y-%m-%d %H:%M:%S UTC")"
|
||||
echo "**Project Root:** $PROJECT_ROOT"
|
||||
echo ""
|
||||
echo "---"
|
||||
echo ""
|
||||
echo "## SUMMARY"
|
||||
echo ""
|
||||
echo "- **Total Links Scanned:** $TOTAL_LINKS"
|
||||
echo "- **Valid Links:** $VALID_LINKS"
|
||||
echo "- **Broken Links:** $BROKEN_COUNT"
|
||||
if [[ $TOTAL_LINKS -gt 0 ]]; then
|
||||
SUCCESS_RATE=$(awk "BEGIN {printf \"%.2f\", ($VALID_LINKS/$TOTAL_LINKS)*100}")
|
||||
echo "- **Success Rate:** ${SUCCESS_RATE}%"
|
||||
else
|
||||
echo "- **Success Rate:** N/A"
|
||||
fi
|
||||
echo ""
|
||||
echo "---"
|
||||
echo ""
|
||||
echo "## BROKEN LINKS"
|
||||
echo ""
|
||||
if [[ -f "$BROKEN_LINKS_FILE" ]]; then
|
||||
cat "$BROKEN_LINKS_FILE"
|
||||
else
|
||||
echo "✅ No broken links found!"
|
||||
fi
|
||||
echo ""
|
||||
echo "---"
|
||||
echo ""
|
||||
echo "## RECOMMENDATIONS"
|
||||
echo ""
|
||||
echo "1. Fix all broken links identified above"
|
||||
echo "2. Verify and correct invalid paths"
|
||||
echo "3. Update cross-references in affected documents"
|
||||
echo "4. Re-run verification after fixes"
|
||||
echo ""
|
||||
echo "---"
|
||||
echo ""
|
||||
echo "**END OF VERIFICATION REPORT**"
|
||||
} > "$REPORT_FILE"
|
||||
|
||||
echo ""
|
||||
echo "=========================================="
|
||||
echo "Verification Summary"
|
||||
echo "=========================================="
|
||||
echo ""
|
||||
echo -e "${GREEN}Total Links Scanned:${NC} $TOTAL_LINKS"
|
||||
echo -e "${GREEN}Valid Links:${NC} $VALID_LINKS"
|
||||
echo -e "${RED}Broken Links:${NC} $BROKEN_COUNT"
|
||||
if [[ $TOTAL_LINKS -gt 0 ]]; then
|
||||
SUCCESS_RATE=$(awk "BEGIN {printf \"%.2f\", ($VALID_LINKS/$TOTAL_LINKS)*100}")
|
||||
echo -e "${BLUE}Success Rate:${NC} ${SUCCESS_RATE}%"
|
||||
fi
|
||||
echo ""
|
||||
echo -e "${BLUE}Report generated:${NC} $REPORT_FILE"
|
||||
if [[ -f "$BROKEN_LINKS_FILE" ]]; then
|
||||
echo -e "${BLUE}Broken links list:${NC} $BROKEN_LINKS_FILE"
|
||||
fi
|
||||
echo ""
|
||||
echo -e "${GREEN}✓ Verification complete!${NC}"
|
||||
|
||||
Reference in New Issue
Block a user