ass_core/analysis/styles/
mod.rs

1//! ASS script style analysis and resolution
2//!
3//! Provides comprehensive style analysis capabilities including inheritance resolution,
4//! conflict detection, performance analysis, and validation. Designed for zero-copy
5//! efficiency with lifetime-generic references to original style definitions.
6//!
7//! # Features
8//!
9//! - **Style Resolution**: Compute effective styles from base definitions and overrides
10//! - **Inheritance Analysis**: Track style inheritance chains and detect circular references
11//! - **Conflict Detection**: Identify duplicate names, missing references, and conflicts
12//! - **Performance Assessment**: Analyze rendering complexity and optimization opportunities
13//! - **Validation**: Check property values, font availability, and spec compliance
14//! - **Zero-Copy Design**: Minimal allocations via lifetime-generic spans
15//!
16//! # Performance Targets
17//!
18//! - Style resolution: <1ms for typical scripts
19//! - Memory usage: ~200 bytes per resolved style
20//! - Analysis: <2ms for complete script style analysis
21//! - Caching: Efficient resolution with zero-copy references
22//!
23//! # Quick Start
24//!
25//! ```rust
26//! use ass_core::analysis::styles::{StyleAnalyzer, ResolvedStyle};
27//! use ass_core::parser::Script;
28//!
29//! let script_text = r#"
30//! [V4+ Styles]
31//! Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
32//! Style: Default,Arial,20,&H00FFFFFF,&H000000FF,&H00000000,&H00000000,0,0,0,0,100,100,0,0,1,2,0,2,10,10,10,1
33//! "#;
34//!
35//! let script = Script::parse(script_text)?;
36//! let analyzer = StyleAnalyzer::new(&script);
37//!
38//! if let Some(resolved) = analyzer.resolve_style("Default") {
39//!     println!("Font: {}, Size: {}", resolved.font_name(), resolved.font_size());
40//!     println!("Complexity: {}/100", resolved.complexity_score());
41//!     println!("Performance issues: {}", resolved.has_performance_issues());
42//! }
43//!
44//! // Validate all styles
45//! let issues = analyzer.validate_styles();
46//! for issue in issues {
47//!     println!("{}: {} in {}", issue.severity, issue.message, issue.field);
48//! }
49//!
50//! // Check for conflicts
51//! for conflict in analyzer.conflicts() {
52//!     println!("Conflict: {}", conflict.description);
53//! }
54//! # Ok::<(), Box<dyn std::error::Error>>(())
55//! ```
56//!
57//! # Module Organization
58//!
59//! - [`resolved_style`] - Fully resolved style representation with computed values
60//! - [`validation`] - Style validation, conflict detection, and issue reporting
61//! - [`analyzer`] - Main analysis interface orchestrating all style operations
62
63pub mod analyzer;
64pub mod resolved_style;
65pub mod validation;
66
67pub use analyzer::{PerformanceThresholds, StyleAnalysisConfig, StyleAnalyzer};
68pub use resolved_style::ResolvedStyle;
69pub use validation::{
70    ConflictType, StyleConflict, StyleInheritance, StyleValidationIssue, ValidationSeverity,
71};