diff --git a/Cargo.lock b/Cargo.lock index 13614e6..523d7fe 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,7 +4,7 @@ version = 3 [[package]] name = "accessibility-rs" -version = "0.0.10" +version = "0.0.12" dependencies = [ "accessibility-scraper", "accessibility-tree", diff --git a/accessibility-rs/Cargo.toml b/accessibility-rs/Cargo.toml index 816a42b..c40bbc7 100644 --- a/accessibility-rs/Cargo.toml +++ b/accessibility-rs/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "accessibility-rs" -version = "0.0.10" +version = "0.0.12" authors = ["The A11yWatch Project Developers", "Jeff Mendez "] edition = "2021" license = "MIT OR Apache-2.0" @@ -8,7 +8,7 @@ description = "Incredibly fast and precise universal web accessibility engine fo repository = "https://github.com/a11ywatch/accessibility-rs" categories = ["accessibility"] documentation = "https://docs.rs/accessibility-rs" -include = ["/src", "LICENSE_MIT", "LICENSE_APACHE"] +include = ["/src", "LICENSE_MIT", "LICENSE_APACHE", "locales"] [features] default = [] diff --git a/accessibility-rs/src/lib.rs b/accessibility-rs/src/lib.rs index f8eea50..daa5e21 100644 --- a/accessibility-rs/src/lib.rs +++ b/accessibility-rs/src/lib.rs @@ -48,28 +48,28 @@ pub use crate::engine::audit::auditor::Auditor; pub use crate::engine::issue::Issue; pub use accessibility_scraper::ElementRef; -i18n!(); +i18n!("locales"); /// configs for the audit #[derive(Default)] -pub struct AuditConfig { +pub struct AuditConfig<'a> { /// the html source code - pub html: &'static str, + pub html: &'a str, /// the css rules to apply - pub css: &'static str, + pub css: &'a str, /// extract bounding box of elements pub bounding_box: bool, /// the locale of the audit translations - pub locale: &'static str, + pub locale: &'a str, } -impl AuditConfig { +impl<'a> AuditConfig<'a> { /// a new audit configuration pub fn new( - html: &'static str, - css: &'static str, + html: &'a str, + css: &'a str, bounding_box: bool, - locale: &'static str, + locale: &'a str, ) -> Self { AuditConfig { html, @@ -89,7 +89,7 @@ impl AuditConfig { } /// audit a web page passing the html and css rules. -pub fn audit(config: &AuditConfig) -> Vec { +pub fn audit(config: AuditConfig) -> Vec { let document = accessibility_scraper::Html::parse_document(config.html); let mut nth_index_cache = selectors::NthIndexCache::from(Default::default()); let auditor = Auditor::new( diff --git a/accessibility-rs/tests/integration_test.rs b/accessibility-rs/tests/integration_test.rs index 5b27699..5fe7141 100644 --- a/accessibility-rs/tests/integration_test.rs +++ b/accessibility-rs/tests/integration_test.rs @@ -6,7 +6,7 @@ use mocks::mock; #[test] fn _audit() { - let _ = accessibility_rs::audit(&AuditConfig::new( + let _ = accessibility_rs::audit(AuditConfig::new( mock::MOCK_WEBSITE_HTML, &mock::MOCK_CSS_RULES, false, diff --git a/accessibility-rs/tests/unit/meta.rs b/accessibility-rs/tests/unit/meta.rs index 335158e..efef707 100644 --- a/accessibility-rs/tests/unit/meta.rs +++ b/accessibility-rs/tests/unit/meta.rs @@ -7,7 +7,7 @@ use crate::mocks::mock; #[test] /// missing title element fn _audit_missing_title() { - let audit = accessibility_rs::audit(&AuditConfig::basic(mock::MOCK_WEBSITE_HTML)); + let audit = accessibility_rs::audit(AuditConfig::basic(mock::MOCK_WEBSITE_HTML)); let mut valid = true; for x in &audit { @@ -23,7 +23,7 @@ fn _audit_missing_title() { #[test] /// meta refresh redirect fn _audit_meta_refresh() { - let audit = accessibility_rs::audit(&AuditConfig::basic( + let audit = accessibility_rs::audit(AuditConfig::basic( r###" Do not use this! @@ -51,7 +51,7 @@ fn _audit_meta_refresh() { assert_eq!(valid, false); - let audit = accessibility_rs::audit(&AuditConfig::basic( + let audit = accessibility_rs::audit(AuditConfig::basic( r###" HTML Techniques for WCAG 2.0 @@ -76,7 +76,7 @@ fn _audit_meta_refresh() { #[test] /// no blink elements fn _audit_blink_found() { - let audit = accessibility_rs::audit(&AuditConfig::basic( + let audit = accessibility_rs::audit(AuditConfig::basic( r###" Do not use this! @@ -101,7 +101,7 @@ fn _audit_blink_found() { #[test] /// iframe missing title fn _iframe_missing_title() { - let audit = accessibility_rs::audit(&AuditConfig { + let audit = accessibility_rs::audit(AuditConfig { html: r###" A simple frameset document @@ -149,7 +149,7 @@ fn _iframe_missing_title() { false, "en", ); - let audit = accessibility_rs::audit(&config); + let audit = accessibility_rs::audit(config); let mut valid = true; for x in &audit { @@ -175,7 +175,7 @@ fn _iframe_missing_title() { "en", ); - let audit = accessibility_rs::audit(&config); + let audit = accessibility_rs::audit(config); let mut valid = true; for x in &audit {