Some checks failed
Test / test (push) Has been cancelled
Co-authored-by: Cursor <cursoragent@cursor.com>
150 lines
4.9 KiB
Bash
Executable File
150 lines
4.9 KiB
Bash
Executable File
#!/bin/bash
|
|
source ~/.bashrc
|
|
# Generate Documentation Index
|
|
# Auto-generates docs/INDEX.md from directory structure
|
|
|
|
set -e
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
|
|
DOCS_DIR="$PROJECT_ROOT/docs"
|
|
INDEX_FILE="$DOCS_DIR/INDEX.md"
|
|
|
|
# Colors
|
|
GREEN='\033[0;32m'
|
|
BLUE='\033[0;34m'
|
|
NC='\033[0m'
|
|
|
|
log_info() {
|
|
echo -e "${GREEN}[INFO]${NC} $1"
|
|
}
|
|
|
|
log_step() {
|
|
echo -e "${BLUE}[STEP]${NC} $1"
|
|
}
|
|
|
|
generate_index() {
|
|
log_info "Generating documentation index..."
|
|
|
|
cat > "$INDEX_FILE" << 'EOF'
|
|
# Documentation Index
|
|
|
|
This is the master index for all project documentation. Documentation is organized by purpose to make it easy to find what you need.
|
|
|
|
**Note**: This index is auto-generated. Run `./scripts/docs/generate-docs-index.sh` to regenerate.
|
|
|
|
EOF
|
|
|
|
# Getting Started
|
|
if [ -d "$DOCS_DIR/getting-started" ]; then
|
|
echo "## Getting Started" >> "$INDEX_FILE"
|
|
echo "" >> "$INDEX_FILE"
|
|
for file in "$DOCS_DIR/getting-started"/*.md; do
|
|
if [ -f "$file" ]; then
|
|
title=$(basename "$file" .md | sed 's/-/ /g' | awk '{for(i=1;i<=NF;i++)sub(/./,toupper(substr($i,1,1)),$i)}1')
|
|
filename=$(basename "$file")
|
|
echo "- [$title](getting-started/$filename)" >> "$INDEX_FILE"
|
|
fi
|
|
done
|
|
echo "" >> "$INDEX_FILE"
|
|
fi
|
|
|
|
# Architecture
|
|
if [ -d "$DOCS_DIR/architecture" ]; then
|
|
echo "## Architecture" >> "$INDEX_FILE"
|
|
echo "" >> "$INDEX_FILE"
|
|
for file in "$DOCS_DIR/architecture"/*.md; do
|
|
if [ -f "$file" ]; then
|
|
title=$(basename "$file" .md | sed 's/-/ /g' | awk '{for(i=1;i<=NF;i++)sub(/./,toupper(substr($i,1,1)),$i)}1')
|
|
filename=$(basename "$file")
|
|
echo "- [$title](architecture/$filename)" >> "$INDEX_FILE"
|
|
fi
|
|
done
|
|
echo "" >> "$INDEX_FILE"
|
|
fi
|
|
|
|
# Deployment
|
|
if [ -d "$DOCS_DIR/deployment" ]; then
|
|
echo "## Deployment" >> "$INDEX_FILE"
|
|
echo "" >> "$INDEX_FILE"
|
|
for file in "$DOCS_DIR/deployment"/*.md; do
|
|
if [ -f "$file" ]; then
|
|
title=$(basename "$file" .md | sed 's/-/ /g' | awk '{for(i=1;i<=NF;i++)sub(/./,toupper(substr($i,1,1)),$i)}1')
|
|
filename=$(basename "$file")
|
|
echo "- [$title](deployment/$filename)" >> "$INDEX_FILE"
|
|
fi
|
|
done
|
|
echo "" >> "$INDEX_FILE"
|
|
fi
|
|
|
|
# Operations
|
|
if [ -d "$DOCS_DIR/operations" ]; then
|
|
echo "## Operations" >> "$INDEX_FILE"
|
|
echo "" >> "$INDEX_FILE"
|
|
for file in "$DOCS_DIR/operations"/*.md; do
|
|
if [ -f "$file" ]; then
|
|
title=$(basename "$file" .md | sed 's/-/ /g' | awk '{for(i=1;i<=NF;i++)sub(/./,toupper(substr($i,1,1)),$i)}1')
|
|
filename=$(basename "$file")
|
|
echo "- [$title](operations/$filename)" >> "$INDEX_FILE"
|
|
fi
|
|
done
|
|
if [ -d "$DOCS_DIR/operations/runbooks" ]; then
|
|
echo "- [Runbooks](operations/runbooks/)" >> "$INDEX_FILE"
|
|
fi
|
|
echo "" >> "$INDEX_FILE"
|
|
fi
|
|
|
|
# Troubleshooting
|
|
if [ -d "$DOCS_DIR/troubleshooting" ]; then
|
|
echo "## Troubleshooting" >> "$INDEX_FILE"
|
|
echo "" >> "$INDEX_FILE"
|
|
for file in "$DOCS_DIR/troubleshooting"/*.md; do
|
|
if [ -f "$file" ]; then
|
|
title=$(basename "$file" .md | sed 's/-/ /g' | awk '{for(i=1;i<=NF;i++)sub(/./,toupper(substr($i,1,1)),$i)}1')
|
|
filename=$(basename "$file")
|
|
echo "- [$title](troubleshooting/$filename)" >> "$INDEX_FILE"
|
|
fi
|
|
done
|
|
echo "" >> "$INDEX_FILE"
|
|
fi
|
|
|
|
# Security
|
|
if [ -d "$DOCS_DIR/security" ]; then
|
|
echo "## Security" >> "$INDEX_FILE"
|
|
echo "" >> "$INDEX_FILE"
|
|
for file in "$DOCS_DIR/security"/*.md; do
|
|
if [ -f "$file" ]; then
|
|
title=$(basename "$file" .md | sed 's/-/ /g' | awk '{for(i=1;i<=NF;i++)sub(/./,toupper(substr($i,1,1)),$i)}1')
|
|
filename=$(basename "$file")
|
|
echo "- [$title](security/$filename)" >> "$INDEX_FILE"
|
|
fi
|
|
done
|
|
echo "" >> "$INDEX_FILE"
|
|
fi
|
|
|
|
# Reference
|
|
if [ -d "$DOCS_DIR/reference" ]; then
|
|
echo "## Reference" >> "$INDEX_FILE"
|
|
echo "" >> "$INDEX_FILE"
|
|
for file in "$DOCS_DIR/reference"/*.md; do
|
|
if [ -f "$file" ]; then
|
|
title=$(basename "$file" .md | sed 's/-/ /g' | awk '{for(i=1;i<=NF;i++)sub(/./,toupper(substr($i,1,1)),$i)}1')
|
|
filename=$(basename "$file")
|
|
echo "- [$title](reference/$filename)" >> "$INDEX_FILE"
|
|
fi
|
|
done
|
|
echo "" >> "$INDEX_FILE"
|
|
fi
|
|
|
|
log_info "Documentation index generated: $INDEX_FILE"
|
|
}
|
|
|
|
main() {
|
|
log_step "Generating documentation index..."
|
|
generate_index
|
|
log_info "Done!"
|
|
}
|
|
|
|
main "$@"
|
|
|