diff --git a/Cargo.lock b/Cargo.lock index 61ea736..ca84ab8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,7 +4,7 @@ version = 3 [[package]] name = "accessibility-rs" -version = "0.0.26" +version = "0.0.30" dependencies = [ "accessibility-scraper", "accessibility-tree", diff --git a/README.md b/README.md index 3d4d172..a538f48 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ The Rust web accessibility engine. ```toml [dependencies] -accessibility-rs = "^0.0.26" +accessibility-rs = "^0.0.30" ``` ```rs diff --git a/accessibility-rs/Cargo.toml b/accessibility-rs/Cargo.toml index 283dc54..11cf7ea 100644 --- a/accessibility-rs/Cargo.toml +++ b/accessibility-rs/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "accessibility-rs" -version = "0.0.26" +version = "0.0.30" authors = ["The A11yWatch Project Developers", "Jeff Mendez "] edition = "2021" license = "MIT OR Apache-2.0" @@ -8,7 +8,7 @@ description = "Web accessibility engine for Rust." repository = "https://github.com/a11ywatch/accessibility-rs" categories = ["accessibility"] documentation = "https://docs.rs/accessibility-rs" -include = ["/src", "../LICENSE_MIT", "../LICENSE_APACHE", "README.md", "locales"] +include = ["/src", "../LICENSE_MIT", "../LICENSE_APACHE", "../README.md", "locales"] [features] default = [] diff --git a/accessibility-rs/README.md b/accessibility-rs/README.md deleted file mode 100644 index 155f571..0000000 --- a/accessibility-rs/README.md +++ /dev/null @@ -1,25 +0,0 @@ -# accessibility-rs - -The Rust web accessibility engine. - -## Usage - -```toml -[dependencies] -accessibility-rs = "^0.0.26" -``` - -```rs -use accessibility_rs::{audit, AuditConfig}; -// pass in raw html and css if coming from a headless browser -let audit = accessibility_rs::audit(&AuditConfig::new(&html, &css, false, "en")); -``` - -### License - -This project is licensed under either of - - * Apache License, Version 2.0, ([LICENSE_APACHE](../LICENSE_APACHE) or - https://www.apache.org/licenses/LICENSE-2.0) - * MIT license ([LICENSE_MIT](../LICENSE_MIT) or - https://opensource.org/licenses/MIT) \ No newline at end of file diff --git a/accessibility-rs/src/engine/audit/wcag.rs b/accessibility-rs/src/engine/audit/wcag.rs index 44388ae..5543fee 100644 --- a/accessibility-rs/src/engine/audit/wcag.rs +++ b/accessibility-rs/src/engine/audit/wcag.rs @@ -5,11 +5,11 @@ use crate::Auditor; /// baseline for all rules #[derive(Default)] -pub struct WCAG3AA; +pub struct WCAGAAA; /// wcag rules to test for -impl WCAG3AA { - /// init the rules +impl WCAGAAA { + /// audit html against WCAGAAA standards pub fn audit(auditor: &Auditor<'_>) -> Vec { // TODO: push rules found to MAP that are different across nodes to combine the selectors let mut issues: Vec = Vec::new(); diff --git a/accessibility-rs/src/engine/rules/techniques.rs b/accessibility-rs/src/engine/rules/techniques.rs index 347d0e3..e2c0ca5 100644 --- a/accessibility-rs/src/engine/rules/techniques.rs +++ b/accessibility-rs/src/engine/rules/techniques.rs @@ -3,7 +3,7 @@ use strum_macros::IntoStaticStr; #[derive(PartialOrd, Ord, std::cmp::Eq, PartialEq, Hash, Debug, IntoStaticStr)] /// techniques for WCAG pub enum Techniques { - /// + /// H25, /// H32, diff --git a/accessibility-rs/src/engine/rules/utils/mod.rs b/accessibility-rs/src/engine/rules/utils/mod.rs index 69e3fea..61a4ec0 100644 --- a/accessibility-rs/src/engine/rules/utils/mod.rs +++ b/accessibility-rs/src/engine/rules/utils/mod.rs @@ -1 +1,2 @@ +/// utilities for node extracting pub mod nodes; diff --git a/accessibility-rs/src/engine/rules/wcag_rule_map.rs b/accessibility-rs/src/engine/rules/wcag_rule_map.rs index 09f50ef..b72df7c 100644 --- a/accessibility-rs/src/engine/rules/wcag_rule_map.rs +++ b/accessibility-rs/src/engine/rules/wcag_rule_map.rs @@ -11,9 +11,8 @@ use std::collections::BTreeMap; use std::collections::HashMap; use std::ops::Add; -// todo: validate each element and add a shape that can prevent repitiion lazy_static! { - /// a list of rules that should be applied for WCAG1 A-AAA + /// a list of rules that should be applied for WCAG2.0 A-AAA pub static ref RULES_A: BTreeMap<&'static str, Vec> = vec![ ("html", Vec::from([ diff --git a/accessibility-rs/src/engine/styles/errors.rs b/accessibility-rs/src/engine/styles/errors.rs index 3114816..2fbd252 100644 --- a/accessibility-rs/src/engine/styles/errors.rs +++ b/accessibility-rs/src/engine/styles/errors.rs @@ -8,7 +8,9 @@ use selectors::parser::SelectorParseErrorKind; // UnknownUnit(CowRcStr<'i>), // } +/// rule parsing errors pub enum RuleParseErrorKind<'i> { + /// selector parse error Selector(SelectorParseErrorKind<'i>), } diff --git a/accessibility-rs/src/engine/styles/rules.rs b/accessibility-rs/src/engine/styles/rules.rs index 2f96bdf..7b5497b 100644 --- a/accessibility-rs/src/engine/styles/rules.rs +++ b/accessibility-rs/src/engine/styles/rules.rs @@ -4,13 +4,18 @@ use cssparser::{AtRuleParser, ParseError, QualifiedRuleParser}; use std::sync::Arc; #[derive(Debug)] +/// Css rules to match selectors pub enum CssRule { + /// the style rules for css StyleRule { + /// css selectors list with selector trait selectors: selectors::SelectorList, + /// a css block parsed block: Arc, }, } +/// css parser pub struct Parser; impl<'i> selectors::parser::Parser<'i> for Parser { @@ -18,9 +23,11 @@ impl<'i> selectors::parser::Parser<'i> for Parser { type Error = RuleParseErrorKind<'i>; } +/// css selector list pub type SelectorList = selectors::SelectorList; // pub type Selector = selectors::parser::Selector; +/// css rules parser pub struct RulesParser; impl<'i> QualifiedRuleParser<'i> for RulesParser { @@ -51,7 +58,6 @@ impl<'i> QualifiedRuleParser<'i> for RulesParser { impl<'i> AtRuleParser<'i> for RulesParser { type PreludeBlock = (); type PreludeNoBlock = (); - type AtRule = CssRule; type Error = RuleParseErrorKind<'i>; } diff --git a/accessibility-rs/src/i18n/locales.rs b/accessibility-rs/src/i18n/locales.rs index ecc6337..8f2e3bd 100644 --- a/accessibility-rs/src/i18n/locales.rs +++ b/accessibility-rs/src/i18n/locales.rs @@ -25,6 +25,7 @@ pub struct Messages { hi: M, } +/// the languages for auditing results pub enum Langs { /// english En, diff --git a/accessibility-rs/src/lib.rs b/accessibility-rs/src/lib.rs index 879d25b..f4b0bb7 100644 --- a/accessibility-rs/src/lib.rs +++ b/accessibility-rs/src/lib.rs @@ -37,10 +37,10 @@ extern crate lazy_static; #[macro_use] extern crate rust_i18n; -/// the main engine for audits. -mod engine; +/// the main engine for accessibility auditing. +pub mod engine; /// locales for translations. -mod i18n; +pub mod i18n; use crate::engine::audit::auditor::Auditor; use crate::engine::issue::Issue; @@ -92,5 +92,5 @@ pub fn audit(config: AuditConfig) -> Vec { config.bounding_box, config.locale, ); - engine::audit::wcag::WCAG3AA::audit(&auditor) + engine::audit::wcag::WCAGAAA::audit(&auditor) }