#!/bin/bash # Documentation Enhancement Script for Rustelo # This script adds logos and branding to cargo doc output exit # TODO: Requir fix positioning in pages and ensure proper alignment set -e # Colors for output RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' NC='\033[0m' # No Color # Configuration LOGO_DIR="logos" DOC_DIR="target/doc" LOGO_FILE="rustelo-imag.svg" LOGO_HORIZONTAL="rustelo_dev-logo-h.svg" # Function to print colored output print_status() { echo -e "${GREEN}[INFO]${NC} $1" } print_warning() { echo -e "${YELLOW}[WARN]${NC} $1" } print_error() { echo -e "${RED}[ERROR]${NC} $1" } # Check if cargo doc has been run check_doc_exists() { if [ ! -d "$DOC_DIR" ]; then print_error "Documentation directory not found. Run 'cargo doc' first." exit 1 fi } # Check if logos exist check_logos_exist() { if [ ! -f "$LOGO_DIR/$LOGO_FILE" ]; then print_error "Logo file not found: $LOGO_DIR/$LOGO_FILE" exit 1 fi if [ ! -f "$LOGO_DIR/$LOGO_HORIZONTAL" ]; then print_error "Horizontal logo file not found: $LOGO_DIR/$LOGO_HORIZONTAL" exit 1 fi } # Copy logos to doc directory copy_logos_to_doc() { print_status "Copying logos to documentation directory..." # Create logos directory in doc mkdir -p "$DOC_DIR/logos" # Copy all logo files cp "$LOGO_DIR"/*.svg "$DOC_DIR/logos/" print_status "Logos copied successfully" } # Add logo to main crate page enhance_main_page() { local crate_name="$1" local index_file="$DOC_DIR/$crate_name/index.html" if [ ! -f "$index_file" ]; then print_warning "Index file not found for crate: $crate_name" return fi print_status "Enhancing main page for crate: $crate_name" # Create a backup cp "$index_file" "$index_file.backup" # Add logo to the main heading sed -i.tmp 's|