#!/usr/bin/env nu # Build Documentation Script # Nushell version of build-docs.sh # Generates cargo documentation with logo assets for RUSTELO def main [] { print $"(ansi blue)๐Ÿ“š Building RUSTELO documentation with logo assets...(ansi reset)" # Verify project structure - following configuration-driven approach validate_project_structure # Clean previous documentation build print $"(ansi blue)๐Ÿงน Cleaning previous documentation...(ansi reset)" try { cargo clean --doc } catch { print $"(ansi yellow)โš ๏ธ Failed to clean documentation, continuing...(ansi reset)" } # Build documentation print $"(ansi blue)๐Ÿ“– Generating cargo documentation...(ansi reset)" try { cargo doc --no-deps --lib --workspace --document-private-items print $"(ansi green)โœ… Documentation generated successfully(ansi reset)" } catch { print $"(ansi red)โŒ Failed to generate documentation(ansi reset)" exit 1 } # Copy logo assets copy_logo_assets # Display completion information show_completion_info } # Validate project structure before proceeding def validate_project_structure [] { # Check for Cargo.toml if not ("Cargo.toml" | path exists) { print $"(ansi red)โŒ Cargo.toml not found. Please run this script from the project root directory.(ansi reset)" exit 1 } # Check for logos directory if not ("logos" | path exists) { print $"(ansi red)โŒ logos directory not found. Please ensure the logos directory exists in the project root.(ansi reset)" exit 1 } print $"(ansi green)โœ… Project structure validated(ansi reset)" } # Copy logo assets to documentation output def copy_logo_assets [] { print $"(ansi blue)๐Ÿ–ผ๏ธ Copying logo assets to documentation output...(ansi reset)" # Check if documentation output exists if not ("target/doc" | path exists) { print $"(ansi red)โŒ Documentation output directory not found(ansi reset)" exit 1 } # Copy logos directory try { cp -r logos target/doc/ print $"(ansi green)โœ… Logo assets copied to target/doc/logos/(ansi reset)" } catch { print $"(ansi red)โŒ Failed to copy logo assets(ansi reset)" exit 1 } # Verify logos were copied successfully verify_logo_assets } # Verify logo assets were copied correctly def verify_logo_assets [] { let logos_dir = "target/doc/logos" if ($logos_dir | path exists) { let logo_files = (ls $logos_dir) if not ($logo_files | is-empty) { print $"(ansi green)โœ… Logo assets verified in documentation output(ansi reset)" print $"(ansi blue)๐Ÿ“ Available logo files:(ansi reset)" # Display logo files with better formatting $logo_files | each {|file| let size = $file.size print $" โ€ข ($file.name) - ($size)" } } else { print $"(ansi yellow)โš ๏ธ Logos directory exists but appears empty(ansi reset)" } } else { print $"(ansi yellow)โš ๏ธ Logo assets may not have been copied correctly(ansi reset)" } } # Show completion information and next steps def show_completion_info [] { print $"(ansi green)โœ… Documentation build complete!(ansi reset)" print "" print $"(ansi blue)๐Ÿ“„ Documentation available at: target/doc/index.html(ansi reset)" print $"(ansi blue)๐Ÿ–ผ๏ธ Logo assets available at: target/doc/logos/(ansi reset)" print "" print $"(ansi yellow)๐Ÿ’ก To view the documentation, run:(ansi reset)" print $" cargo doc --open" print "" # Show documentation size info if ("target/doc" | path exists) { let doc_size = (du target/doc | get apparent | first) print $"(ansi blue)๐Ÿ“Š Documentation size: ($doc_size)(ansi reset)" } }