Skip to content

Commit

Permalink
chore(config): add reference config auditing
Browse files Browse the repository at this point in the history
  • Loading branch information
j-mendez committed Jun 26, 2024
1 parent 8af7c56 commit 23bd18d
Show file tree
Hide file tree
Showing 20 changed files with 91 additions and 79 deletions.
14 changes: 7 additions & 7 deletions 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 Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ members = [
smallvec = "1"
selectors = "0.22.0"
cssparser = "0.27.0"
fast_html5ever = "0.26.1"
fast_html5ever = "0.26.6"
ego-tree = "0.6.2"
lazy_static = "1.4"
7 changes: 4 additions & 3 deletions 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.64"
accessibility-rs = "^0.1.0"
```

```rs
Expand All @@ -32,7 +32,7 @@ With the Tokio runtime.

```toml
[dependencies]
accessibility-rs = { version = "^0.0.64", features = ["tokio"]}
accessibility-rs = { version = "^0.1.0", features = ["tokio"]}
```

```rs
Expand Down Expand Up @@ -60,7 +60,7 @@ With the Spider full website crawling.

```toml
[dependencies]
accessibility-rs = { version = "^0.0.64", features = ["spider"]}
accessibility-rs = { version = "^0.1.0", features = ["spider"]}
```

```rs
Expand All @@ -87,6 +87,7 @@ async fn main() {
1. i18n support for multiple languages.
1. Re-creating layout tree to get element position coordinates.
1. Crawling full websites lightning-fast using [spider](https://github.com/spider-rs/spider).
1. Low-level built to be used as an engine in browsers.

## [Benchmarks](./benches/)

Expand Down
12 changes: 6 additions & 6 deletions accessibility-rs/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "accessibility-rs"
version = "0.0.64"
version = "0.1.3"
authors = ["The A11yWatch Project Developers", "Jeff Mendez <[email protected]>"]
edition = "2021"
license = "MIT OR Apache-2.0"
Expand All @@ -12,11 +12,11 @@ include = ["/src", "../LICENSE_MIT", "../LICENSE_APACHE", "../README.md", "local

[dependencies]
lazy_static = { workspace = true }
accessibility-scraper = { version = "0.0.12", features = ["main"], default-features = false, path = "../accessibility-scraper" }
accessibility-tree = { version = "0.0.12", path = "../accessibility-tree/victor" }
accessibility-scraper = { version = "0.0.14", features = ["main"], default-features = false, path = "../accessibility-scraper" }
accessibility-tree = { version = "0.0.14", path = "../accessibility-tree/victor" }
getrandom = { version = "0.2", features = ["js"] }
taffy = { version = "0.4.0" }
serde = { version = "1.0", features = ["derive"] }
taffy = { version = "0.5" }
serde = { version = "1", features = ["derive"] }
selectors = { workspace = true }
smallvec = { workspace = true }
ego-tree = { workspace = true }
Expand All @@ -29,7 +29,7 @@ contrast = "0.1"
rgb = "0.8"
rayon = { version = "1", optional = true }
crossbeam-channel = { version = "0.5", optional = true }
tokio = { version = "1", features = ["macros"], optional = true }
tokio = { version = "1", features = ["macros", "rt-multi-thread", "parking_lot"], optional = true }
tokio-stream = { version = "0.1", optional = true }
spider = { version = "1.98.2", optional = true }

Expand Down
8 changes: 4 additions & 4 deletions accessibility-rs/src/integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use mocks::mock;

#[test]
fn _audit() {
let report = accessibility_rs::audit(AuditConfig::new(
let report = accessibility_rs::audit(&AuditConfig::new(
mock::MOCK_WEBSITE_HTML,
&mock::MOCK_CSS_RULES,
false,
Expand All @@ -17,7 +17,7 @@ fn _audit() {

#[test]
fn _audit_large() {
let report = accessibility_rs::audit(AuditConfig::new(
let report = accessibility_rs::audit(&AuditConfig::new(
mock::MOCK_HTML_LARGE_PAGE,
&mock::MOCK_CSS_RULES_LARGE,
false,
Expand All @@ -28,7 +28,7 @@ fn _audit_large() {

#[test]
fn _audit_bounded() {
let report = accessibility_rs::audit(AuditConfig::new(
let report = accessibility_rs::audit(&AuditConfig::new(
mock::MOCK_WEBSITE_HTML,
&mock::MOCK_CSS_RULES,
true,
Expand All @@ -39,7 +39,7 @@ fn _audit_bounded() {

#[test]
fn _audit_large_bounded() {
let report = accessibility_rs::audit(AuditConfig::new(
let report = accessibility_rs::audit(&AuditConfig::new(
mock::MOCK_HTML_LARGE_PAGE,
&mock::MOCK_CSS_RULES_LARGE,
true,
Expand Down
4 changes: 2 additions & 2 deletions accessibility-rs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ pub use spider;
pub mod engine;
/// locales for translations.
pub mod i18n;

use crate::engine::audit::auditor::Auditor;
use crate::engine::issue::Issue;
pub use accessibility_scraper;
use accessibility_scraper::ElementRef;

i18n!("locales", fallback = "en");
Expand Down Expand Up @@ -253,7 +253,7 @@ pub async fn audit(config: AuditConfig) -> AuditResults {

/// audit a web page passing the html and css rules.
#[cfg(not(feature = "tokio"))]
pub fn audit(config: AuditConfig) -> Vec<Issue> {
pub fn audit(config: &AuditConfig) -> Vec<Issue> {
let document = accessibility_scraper::Html::parse_document(&config.html);
let auditor = Auditor::new(&document, &config.css, config.bounding_box, &config.locale);
engine::audit::wcag::WCAGAAA::audit(auditor)
Expand Down
16 changes: 8 additions & 8 deletions accessibility-rs/tests/integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use mocks::mock;
#[cfg(feature = "tokio")]
#[tokio::test]
async fn _audit() {
let report = accessibility_rs::audit(AuditConfig::new(
let report = accessibility_rs::audit(&AuditConfig::new(
mock::MOCK_WEBSITE_HTML,
&mock::MOCK_CSS_RULES,
false,
Expand All @@ -20,7 +20,7 @@ async fn _audit() {
#[test]
#[cfg(not(feature = "tokio"))]
fn _audit() {
let report = accessibility_rs::audit(AuditConfig::new(
let report = accessibility_rs::audit(&AuditConfig::new(
mock::MOCK_WEBSITE_HTML,
&mock::MOCK_CSS_RULES,
false,
Expand All @@ -32,7 +32,7 @@ fn _audit() {
#[test]
#[cfg(not(feature = "tokio"))]
fn _audit_large() {
let report = accessibility_rs::audit(AuditConfig::new(
let report = accessibility_rs::audit(&AuditConfig::new(
mock::MOCK_HTML_LARGE_PAGE,
&mock::MOCK_CSS_RULES_LARGE,
false,
Expand All @@ -44,7 +44,7 @@ fn _audit_large() {
#[test]
#[cfg(not(feature = "tokio"))]
fn _audit_with_layout() {
let report = accessibility_rs::audit(AuditConfig::new(
let report = accessibility_rs::audit(&AuditConfig::new(
mock::MOCK_WEBSITE_HTML,
&mock::MOCK_CSS_RULES,
true,
Expand All @@ -56,7 +56,7 @@ fn _audit_with_layout() {
#[test]
#[cfg(not(feature = "tokio"))]
fn _audit_large_with_layout() {
let report = accessibility_rs::audit(AuditConfig::new(
let report = accessibility_rs::audit(&AuditConfig::new(
mock::MOCK_HTML_LARGE_PAGE,
&mock::MOCK_CSS_RULES_LARGE,
true,
Expand All @@ -68,7 +68,7 @@ fn _audit_large_with_layout() {
#[test]
#[cfg(not(feature = "tokio"))]
fn _audit_xlarge() {
let report = accessibility_rs::audit(AuditConfig::new(
let report = accessibility_rs::audit(&AuditConfig::new(
mock::MOCK_WEBSITE_XLARGE_HTML,
&mock::MOCK_CSS_RULES_XLARGE,
false,
Expand All @@ -80,7 +80,7 @@ fn _audit_xlarge() {
#[tokio::test]
#[cfg(feature = "tokio")]
async fn _audit_xlarge() {
let report = accessibility_rs::audit(AuditConfig::new(
let report = accessibility_rs::audit(&AuditConfig::new(
mock::MOCK_WEBSITE_XLARGE_HTML,
&mock::MOCK_CSS_RULES_XLARGE,
false,
Expand All @@ -94,6 +94,6 @@ async fn _audit_xlarge() {
#[tokio::test]
async fn _audit_website() {
let audit_config = AuditConfig::new_website("https://choosealicense.com", "", false, "");
let report = accessibility_rs::audit(audit_config).await;
let report = accessibility_rs::audit(&audit_config).await;
println!("{:?}", report)
}
8 changes: 4 additions & 4 deletions accessibility-rs/tests/unit/anchor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use maud::html;
#[cfg(not(feature = "tokio"))]
/// anchor contains single img element without alt
fn _audit_missing_alt_anchor_img() {
let audit = accessibility_rs::audit(AuditConfig::basic(
let audit = accessibility_rs::audit(&AuditConfig::basic(
r###"<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<title>Decrative Img: Do not use!</title>
Expand All @@ -33,7 +33,7 @@ fn _audit_missing_anchor_content_valid_href() {
let markup = html! {
a href="www.example.com";
};
let audit = accessibility_rs::audit(AuditConfig::basic(&markup.into_string()));
let audit = accessibility_rs::audit(&AuditConfig::basic(&markup.into_string()));
let valid = !audit
.iter()
.any(|x| x.code == "WCAGAAA.Principle4.Guideline4_1.H91");
Expand All @@ -48,7 +48,7 @@ fn _audit_missing_anchor_content() {
let markup = html! {
a { "" }
};
let audit = accessibility_rs::audit(AuditConfig::basic(&markup.into_string()));
let audit = accessibility_rs::audit(&AuditConfig::basic(&markup.into_string()));
let valid = !audit
.iter()
.any(|x| x.code == "WCAGAAA.Principle4.Guideline4_1.H91");
Expand All @@ -60,7 +60,7 @@ fn _audit_missing_anchor_content() {
#[cfg(not(feature = "tokio"))]
/// anchor text matches img alt
fn _audit_img_alt_matches_text_anchor() {
let audit = accessibility_rs::audit(AuditConfig::basic(
let audit = accessibility_rs::audit(&AuditConfig::basic(
r###"<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<title>Decrative Img: Do not use!</title>
Expand Down
4 changes: 2 additions & 2 deletions accessibility-rs/tests/unit/applet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use accessibility_rs::AuditConfig;
#[cfg(not(feature = "tokio"))]
/// missing applet alt
fn _audit_missing_applet_alt() {
let audit = accessibility_rs::audit(AuditConfig::basic(
let audit = accessibility_rs::audit(&AuditConfig::basic(
r###"<html lang="en">
<head>
<title>Missing applet alt: Do not use this!</title>
Expand Down Expand Up @@ -34,7 +34,7 @@ fn _audit_missing_applet_alt() {
#[cfg(not(feature = "tokio"))]
/// missing applet body
fn _audit_missing_applet_body() {
let audit = accessibility_rs::audit(AuditConfig::basic(
let audit = accessibility_rs::audit(&AuditConfig::basic(
r###"<html lang="en">
<head>
<title>Missing applet alt: Do not use this!</title>
Expand Down
4 changes: 2 additions & 2 deletions accessibility-rs/tests/unit/area.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ fn _audit_missing_alt_area() {
<area shape="circle" coords="337,300,44" alt="Cup of coffee" href="coffee.htm">
</map>"#;
let audit: Vec<accessibility_rs::engine::issue::Issue> =
accessibility_rs::audit(AuditConfig::basic(html));
accessibility_rs::audit(&AuditConfig::basic(html));

let valid = audit
.iter()
Expand All @@ -35,7 +35,7 @@ fn _audit_missing_alt_map() {
<area shape="circle" coords="337,300,44" alt="Cup of coffee" href="coffee.htm">
</map>"#;
let audit: Vec<accessibility_rs::engine::issue::Issue> =
accessibility_rs::audit(AuditConfig::basic(html));
accessibility_rs::audit(&AuditConfig::basic(html));

let valid = audit.iter().any(|x| x.message == "1_1_1_H24.ImageMapNoAlt");

Expand Down
2 changes: 1 addition & 1 deletion accessibility-rs/tests/unit/contrast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ fn _audit_contrast_text_anchor() {
a href="www.example.com" style="color:blue;" { "example" };
}
};
let audit = accessibility_rs::audit(AuditConfig::basic(&markup.into_string()));
let audit = accessibility_rs::audit(&AuditConfig::basic(&markup.into_string()));

let valid = !audit
.iter()
Expand Down
2 changes: 1 addition & 1 deletion accessibility-rs/tests/unit/fieldset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ fn _audit_missing_fieldset_legend() {
}
};

let audit = accessibility_rs::audit(AuditConfig::basic(&m.into_string()));
let audit = accessibility_rs::audit(&AuditConfig::basic(&m.into_string()));

let valid = !audit
.iter()
Expand Down
4 changes: 2 additions & 2 deletions accessibility-rs/tests/unit/heading.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use accessibility_rs::AuditConfig;
#[cfg(not(feature = "tokio"))]
/// empty headings
fn _audit_headings_empty() {
let audit = accessibility_rs::audit(AuditConfig::basic(
let audit = accessibility_rs::audit(&AuditConfig::basic(
r###"<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<title>Valid headings</title>
Expand Down Expand Up @@ -48,7 +48,7 @@ fn _audit_headings_empty() {

assert_eq!(valid, true);

let audit = accessibility_rs::audit(AuditConfig::basic(
let audit = accessibility_rs::audit(&AuditConfig::basic(
r###"<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<title>Do not use missing Headings conent.</title>
Expand Down
6 changes: 3 additions & 3 deletions accessibility-rs/tests/unit/img.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use accessibility_rs::AuditConfig;
#[cfg(not(feature = "tokio"))]
/// img is missing an alt
fn _audit_img_missing_alt() {
let audit = accessibility_rs::audit(AuditConfig::basic(
let audit = accessibility_rs::audit(&AuditConfig::basic(
r###"<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<title>Missing Alt: Do not Use.</title>
Expand All @@ -31,7 +31,7 @@ fn _audit_img_missing_alt() {
#[cfg(not(feature = "tokio"))]
/// img is missing an alt
fn _audit_form_submit_img_missing_alt() {
let audit = accessibility_rs::audit(AuditConfig::basic(
let audit = accessibility_rs::audit(&AuditConfig::basic(
r###"<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<title>Missing Alt: Do not Use.</title>
Expand Down Expand Up @@ -60,7 +60,7 @@ fn _audit_form_submit_img_missing_alt() {
#[cfg(not(feature = "tokio"))]
/// img has empty alt and title
fn _audit_form_submit_img_has_alt_and_title() {
let audit = accessibility_rs::audit(AuditConfig::basic(
let audit = accessibility_rs::audit(&AuditConfig::basic(
r###"<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<title>Contains Title with Alt: Do not Use.</title>
Expand Down
2 changes: 1 addition & 1 deletion accessibility-rs/tests/unit/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use accessibility_rs::AuditConfig;
#[cfg(not(feature = "tokio"))]
/// input is missing a valid name
fn _audit_input_valid_name() {
let audit = accessibility_rs::audit(AuditConfig::basic(
let audit = accessibility_rs::audit(&AuditConfig::basic(
r###"<html lang="en">
<head>
<title>Missing Form control name: Do not Use.</title>
Expand Down
Loading

0 comments on commit 23bd18d

Please sign in to comment.