Skip to content

Commit

Permalink
chore(crate): add pub engine
Browse files Browse the repository at this point in the history
  • Loading branch information
j-mendez committed Oct 15, 2023
1 parent 70d2a20 commit 2bac9a8
Show file tree
Hide file tree
Showing 12 changed files with 24 additions and 40 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ The Rust web accessibility engine.

```toml
[dependencies]
accessibility-rs = "^0.0.26"
accessibility-rs = "^0.0.30"
```

```rs
Expand Down
4 changes: 2 additions & 2 deletions accessibility-rs/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
[package]
name = "accessibility-rs"
version = "0.0.26"
version = "0.0.30"
authors = ["The A11yWatch Project Developers", "Jeff Mendez <[email protected]>"]
edition = "2021"
license = "MIT OR Apache-2.0"
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 = []
Expand Down
25 changes: 0 additions & 25 deletions accessibility-rs/README.md

This file was deleted.

6 changes: 3 additions & 3 deletions accessibility-rs/src/engine/audit/wcag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Issue> {
// TODO: push rules found to MAP that are different across nodes to combine the selectors
let mut issues: Vec<Issue> = Vec::new();
Expand Down
2 changes: 1 addition & 1 deletion accessibility-rs/src/engine/rules/techniques.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use strum_macros::IntoStaticStr;
#[derive(PartialOrd, Ord, std::cmp::Eq, PartialEq, Hash, Debug, IntoStaticStr)]
/// techniques for WCAG <https://www.w3.org/TR/WCAG20-TECHS/>
pub enum Techniques {
/// <https://www.w3.org/TR/WCAG20-TECHS/H25.html>
/// <https://www.w3.org/TR/WCAG20-TECHS/H25>
H25,
/// <https://www.w3.org/TR/WCAG20-TECHS/H32.html>
H32,
Expand Down
1 change: 1 addition & 0 deletions accessibility-rs/src/engine/rules/utils/mod.rs
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/// utilities for node extracting
pub mod nodes;
3 changes: 1 addition & 2 deletions accessibility-rs/src/engine/rules/wcag_rule_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Rule>> =
vec![
("html", Vec::from([
Expand Down
2 changes: 2 additions & 0 deletions accessibility-rs/src/engine/styles/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ use selectors::parser::SelectorParseErrorKind;
// UnknownUnit(CowRcStr<'i>),
// }

/// rule parsing errors
pub enum RuleParseErrorKind<'i> {
/// selector parse error
Selector(SelectorParseErrorKind<'i>),
}

Expand Down
8 changes: 7 additions & 1 deletion accessibility-rs/src/engine/styles/rules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,30 @@ 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<Simple>,
/// a css block parsed
block: Arc<String>,
},
}

/// css parser
pub struct Parser;

impl<'i> selectors::parser::Parser<'i> for Parser {
type Impl = Simple;
type Error = RuleParseErrorKind<'i>;
}

/// css selector list
pub type SelectorList = selectors::SelectorList<Simple>;
// pub type Selector = selectors::parser::Selector<Simple>;

/// css rules parser
pub struct RulesParser;

impl<'i> QualifiedRuleParser<'i> for RulesParser {
Expand Down Expand Up @@ -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>;
}
1 change: 1 addition & 0 deletions accessibility-rs/src/i18n/locales.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ pub struct Messages {
hi: M,
}

/// the languages for auditing results
pub enum Langs {
/// english
En,
Expand Down
8 changes: 4 additions & 4 deletions accessibility-rs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -92,5 +92,5 @@ pub fn audit(config: AuditConfig) -> Vec<Issue> {
config.bounding_box,
config.locale,
);
engine::audit::wcag::WCAG3AA::audit(&auditor)
engine::audit::wcag::WCAGAAA::audit(&auditor)
}

0 comments on commit 2bac9a8

Please sign in to comment.