webpage_quality_analyzer 1.0.2

High-performance webpage quality analyzer with 115 comprehensive metrics - Rust library with WASM, C++, and Python bindings
Documentation
//! Output formatting macros for examples and demonstrations
//!
//! This module provides standardized macros to eliminate repetitive
//! println! patterns across examples and reduce code duplication.

/// Print a success message with score
#[macro_export]
macro_rules! print_score {
    ($label:expr, $score:expr) => {
        println!("{}: {:.1}/100", $label, $score);
    };
    ($label:expr, $score:expr, $verdict:expr) => {
        println!("{}: {:.1}/100 ({})", $label, $score, $verdict);
    };
}

/// Print an error message
#[macro_export]
macro_rules! print_error {
    ($label:expr, $error:expr) => {
        println!("{} failed: {}", $label, $error);
    };
}

/// Print a section header
#[macro_export]
macro_rules! print_section {
    ($title:expr) => {
        println!("\n🔥 {}", $title);
        println!("{}", "=".repeat($title.len() + 3));
    };
    ($icon:expr, $title:expr) => {
        println!("\n{} {}", $icon, $title);
        println!("{}", "-".repeat($title.len() + 3));
    };
}

/// Print a subsection header
#[macro_export]
macro_rules! print_subsection {
    ($title:expr) => {
        println!("\n📊 {}", $title);
        println!("{}", "-".repeat($title.len() + 5));
    };
}

/// Print completion message with summary
#[macro_export]
macro_rules! print_completion {
    ($message:expr) => {
        println!("\n{}", $message);
    };
    ($message:expr, $details:expr) => {
        println!("\n{}", $message);
        println!("\n📖 {}", $details);
    };
}

/// Print key takeaways
#[macro_export]
macro_rules! print_takeaways {
    ($($takeaway:expr),+) => {
        println!("\n💡 Key Takeaways:");
        $(
            println!("{}", $takeaway);
        )+
    };
}

/// Print analysis results with detailed breakdown
#[macro_export]
macro_rules! print_analysis_results {
    ($report:expr) => {
        println!("📊 Detailed Results:");
        println!(
            "   Overall Score: {:.1}/100 ({})",
            $report.score, $report.verdict
        );
    };
    ($report:expr, $show_details:expr) => {
        println!("📊 Detailed Results:");
        println!(
            "   Overall Score: {:.1}/100 ({})",
            $report.score, $report.verdict
        );
        if $show_details {
            println!();
            println!("📝 Content Analysis:");
            let content = &$report.metrics.html_analysis.content;
            println!("   Word Count: {}", content.word_count);
            println!(
                "   Reading Time: {:.1} minutes",
                content.reading_time_minutes
            );
            println!(
                "   Unique Word Ratio: {:.1}%",
                content.unique_word_ratio * 100.0
            );
        }
    };
}

/// Print profile comparison results
#[macro_export]
macro_rules! print_profile_results {
    ($profiles:expr, $html:expr, $url:expr) => {
        for profile in $profiles {
            match analyze_with_profile($url, Some($html), profile).await {
                Ok(report) => {
                    print_score!(
                        format!("Profile '{}'", profile),
                        report.score,
                        report.verdict
                    );
                }
                Err(e) => {
                    print_error!(format!("Profile '{}'", profile), e);
                }
            }
        }
    };
}

/// Print benchmark results
#[macro_export]
macro_rules! print_benchmark {
    ($name:expr, $duration:expr) => {
        println!("⏱️  {}: {:.2?}", $name, $duration);
    };
    ($name:expr, $duration:expr, $score:expr) => {
        println!("⏱️  {}: {:.2?} (Score: {:.1})", $name, $duration, $score);
    };
}

/// Print feature status
#[macro_export]
macro_rules! print_features {
    ($($feature:expr => $enabled:expr),+) => {
        println!("🔧 Features:");
        $(
            let status = if $enabled { "✅ Enabled" } else { "❌ Disabled" };
            println!("   {}: {}", $feature, status);
        )+
    };
}