API documentation

class wcag_zoo.utils.WCAGCommand(*args, **kwargs)

The base class for all WCAG validation commands

classmethod as_cli()

Exposes the WCAG validator as a click-based command line interface tool.

check_skip_element(node)

Performs checking to see if an element can be skipped for validation, including check if it has an id or class to skip, or if it has a CSS rule to hide it.

THis class calls WCAGCommand.skip_element to get any additional skip logic, override skip_element not this method to add custom skip logic.

Returns True if the node is to be skipped.

run_validation_loop(xpath=None, validator=None)

Runs validation of elements that match an xpath using the given validation method. By default runs self.validate_element

skip_element(node)

Method for adding extra checks to determine if an HTML element should be skipped by the validation loop.

Override this to add custom skip logic to a wcag command.

Return true to skip validation of the given node.

validate_document(html)

Main validation method - validates an entire document, single node from a HTML tree.

Note: This checks the validitity of the whole document and executes the validation loop.

By default, returns a dictionary with the number of successful checks, and a list of failures, warnings and skipped elements.

validate_element(node)

Validate a single node from a HTML element tree. Errors and warnings are attached to the instances failures and warnings properties.

By default, returns nothing.

validate_file(filename)

Validates a file given as a string filenames

By returns a dictionary of results from validate_document.

validate_files(*filenames)

Validates the files given as a list of strings of filenames

By default, returns nothing.

validate_whole_document(html)

Validates an entire document from a HTML element tree. Errors and warnings are attached to the instances failures and warnings properties.

Note: This checks the validatity of the whole document, but does not execute the validation loop.

By default, returns nothing.

wcag_zoo.utils.build_msg(node, **kwargs)

Assistance method that builds a dictionary error message with appropriate references to the node

wcag_zoo.utils.get_applicable_styles(node)

Generates a list of dictionaries that contains all the styles that could influence the style of an element.

This is the collection of all styles from an element and all it parent elements.

Returns a list, with each list item being a dictionary with keys that correspond to CSS styles and the values are the corresponding values for each ancestor element.