mod configuration; mod geometry; mod patterns; mod renderer; mod shapes; mod smart_positioning; mod stage_type; mod utils; // Re-export parser types pub use wmap_parser::{ Component, Dependency, Evolution, Group, Inertia, Map, Note, Shape, Stage, StageData, }; // Re-export our types pub use configuration::{ Colors, Configuration, Fonts, LineHeights, Opacity, Options, Sizes, Theme, }; pub use stage_type::StageType; use thiserror::Error; use cairo::ImageSurface; /// Error types for rendering #[derive(Debug, Error)] pub enum RenderError { #[error("Cairo rendering error: {0}")] Cairo(String), #[error("Invalid configuration: {0}")] InvalidConfig(String), #[error("Concave hull calculation failed")] GeometryError, #[error("IO error: {0}")] Io(#[from] std::io::Error), } impl From for RenderError { fn from(err: cairo::Error) -> Self { RenderError::Cairo(err.to_string()) } } impl From for RenderError { fn from(err: cairo::IoError) -> Self { RenderError::Cairo(err.to_string()) } } /// Renders a Wardley map to PNG format /// /// # Arguments /// /// * `map` - The parsed Wardley map /// * `stage_type` - The stage type to use for axis labels /// * `config` - Configuration options /// /// # Returns /// /// A vector of bytes containing the PNG image data pub fn render_to_png( map: &Map, stage_type: StageType, config: &Configuration, ) -> Result, RenderError> { renderer::render_to_png(map, stage_type, config) } /// Renders a Wardley map to SVG format /// /// # Arguments /// /// * `map` - The parsed Wardley map /// * `stage_type` - The stage type to use for axis labels /// * `config` - Configuration options /// /// # Returns /// /// A string containing the SVG data pub fn render_to_svg( map: &Map, stage_type: StageType, config: &Configuration, ) -> Result { renderer::render_to_svg(map, stage_type, config) } /// Renders a Wardley map to a cairo context. /// /// # Arguments /// /// * `map` - The parsed Wardley map /// * `stage_type` - The stage type to use for axis labels /// * `config` - Configuration options /// /// # Returns /// /// A string containing the SVG data pub fn render_to_surface( map: &Map, stage_type: StageType, config: &Configuration, ) -> Result { renderer::render_to_surface(map, stage_type, config) } #[cfg(test)] mod tests { use super::*; #[test] fn test_default_configuration() { let config = Configuration::default(); assert!(config.options.show_background); assert!(config.options.smart_label_positioning); } #[test] fn test_default_stage_type() { let stage = StageType::default(); assert_eq!(stage, StageType::Activities); } }