pub struct AccessibilityReport {
pub issues: Vec<Issue>,
pub wcag_level: WcagLevel,
pub elements_checked: usize,
pub issue_count: usize,
pub check_duration_ms: u64,
}Expand description
A comprehensive accessibility check result.
§Examples
use html_generator::accessibility::{
validate_wcag, AccessibilityConfig,
};
let html = r#"<html lang="en"><body><h1>Hi</h1></body></html>"#;
let report = validate_wcag(html, &AccessibilityConfig::default(), None).unwrap();
assert_eq!(report.issue_count, report.issues.len());Fields§
§issues: Vec<Issue>List of accessibility issues found
wcag_level: WcagLevelWCAG conformance level checked
elements_checked: usizeTotal number of elements checked
issue_count: usizeNumber of issues found
check_duration_ms: u64Time taken for the check (in milliseconds)
Implementations§
Source§impl AccessibilityReport
Helper functions for WCAG validation
impl AccessibilityReport
Helper functions for WCAG validation
Check keyboard navigation.
Walks all interactive elements (a, button, input, select,
textarea, [tabindex]) and pushes a KeyboardNavigation
Issue for negative tabindex values or click handlers without
keyboard equivalents.
§Examples
use html_generator::accessibility::{AccessibilityReport, Issue};
use scraper::Html;
let doc = Html::parse_document(
r#"<html><body><button tabindex="-1">x</button></body></html>"#,
);
let mut issues: Vec<Issue> = Vec::new();
AccessibilityReport::check_keyboard_navigation(&doc, &mut issues).unwrap();
assert!(issues.iter().any(|i| i.message.contains("Negative tabindex")));§Errors
Returns Error::HtmlProcessingError if internal selector
dispatch fails (none of the static selectors used here can
fail in practice).
Sourcepub fn check_language_attributes(
document: &Html,
issues: &mut Vec<Issue>,
) -> Result<()>
pub fn check_language_attributes( document: &Html, issues: &mut Vec<Issue>, ) -> Result<()>
Check language attributes.
Verifies that the root <html> element carries a lang attribute
and that any element-level lang="..." overrides are valid BCP 47
codes. Each violation is pushed to issues.
§Examples
use html_generator::accessibility::{AccessibilityReport, Issue};
use scraper::Html;
let doc = Html::parse_document(r#"<html><body><p>x</p></body></html>"#);
let mut issues: Vec<Issue> = Vec::new();
AccessibilityReport::check_language_attributes(&doc, &mut issues).unwrap();
assert!(issues.iter().any(|i| i.message.contains("Missing language")));§Errors
Returns Error::HtmlProcessingError for internal selector
dispatch failures (not reachable in practice).
Sourcepub fn check_advanced_aria(
document: &Html,
issues: &mut Vec<Issue>,
) -> Result<()>
pub fn check_advanced_aria( document: &Html, issues: &mut Vec<Issue>, ) -> Result<()>
Check advanced ARIA usage.
Verifies that any role="..." attributes are valid for the
element they appear on, and that elements with ARIA roles carry
all required companion properties (e.g. a slider requires
aria-valuenow).
§Examples
use html_generator::accessibility::{AccessibilityReport, Issue};
use scraper::Html;
// The `aria-label` is what makes the element match the
// `aria-*` selector that `check_advanced_aria` walks; `slider`
// requires `aria-valuenow` plus min/max, which are absent here.
let doc = Html::parse_fragment(
r#"<div role="slider" aria-label="vol"></div>"#,
);
let mut issues: Vec<Issue> = Vec::new();
AccessibilityReport::check_advanced_aria(&doc, &mut issues).unwrap();
assert!(
issues
.iter()
.any(|i| i.message.contains("required ARIA properties"))
);§Errors
Returns Error::HtmlProcessingError for internal selector
dispatch failures (not reachable in practice).
Trait Implementations§
Source§impl Clone for AccessibilityReport
impl Clone for AccessibilityReport
Source§fn clone(&self) -> AccessibilityReport
fn clone(&self) -> AccessibilityReport
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for AccessibilityReport
impl RefUnwindSafe for AccessibilityReport
impl Send for AccessibilityReport
impl Sync for AccessibilityReport
impl Unpin for AccessibilityReport
impl UnsafeUnpin for AccessibilityReport
impl UnwindSafe for AccessibilityReport
Blanket Implementations§
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<F, W, T, D> Deserialize<With<T, W>, D> for F
impl<F, W, T, D> Deserialize<With<T, W>, D> for F
§fn deserialize(
&self,
deserializer: &mut D,
) -> Result<With<T, W>, <D as Fallible>::Error>
fn deserialize( &self, deserializer: &mut D, ) -> Result<With<T, W>, <D as Fallible>::Error>
§impl<'a, T> FromIn<'a, T> for T
impl<'a, T> FromIn<'a, T> for T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<'a, T, U> IntoIn<'a, U> for Twhere
U: FromIn<'a, T>,
impl<'a, T, U> IntoIn<'a, U> for Twhere
U: FromIn<'a, T>,
§impl<D> OwoColorize for D
impl<D> OwoColorize for D
§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg] or
a color-specific method, such as [OwoColorize::green], Read more§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg] or
a color-specific method, such as [OwoColorize::on_yellow], Read more