|
| 1 | +# freee_a11y_gl |
| 2 | + |
| 3 | +A comprehensive Python library for managing accessibility guidelines, checks, and related content. This library provides a framework for processing YAML-based accessibility guidelines, performing validation, and managing relationships between different accessibility entities. |
| 4 | + |
| 5 | +## Features |
| 6 | + |
| 7 | +- **Model-based Architecture**: Structured models for categories, guidelines, checks, FAQ articles, and WCAG success criteria |
| 8 | +- **YAML Processing**: Robust YAML file processing with validation and error handling |
| 9 | +- **Relationship Management**: Automatic relationship resolution between different entities |
| 10 | +- **Configuration System**: Flexible configuration management with profile support |
| 11 | +- **Internationalization**: Multi-language support with message catalogs |
| 12 | +- **Validation**: Comprehensive YAML validation with configurable modes |
| 13 | +- **axe-core Integration**: Built-in support for axe-core accessibility rules |
| 14 | + |
| 15 | +## Installation |
| 16 | + |
| 17 | +```bash |
| 18 | +pip install freee_a11y_gl |
| 19 | +``` |
| 20 | + |
| 21 | +### Requirements |
| 22 | + |
| 23 | +- Python 3.9 or higher |
| 24 | +- PyYAML >= 6.0 |
| 25 | +- GitPython >= 3.1.43 |
| 26 | +- Pydantic >= 2.7.0 |
| 27 | + |
| 28 | +## Quick Start |
| 29 | + |
| 30 | +### Basic Usage |
| 31 | + |
| 32 | +```python |
| 33 | +import freee_a11y_gl as a11y |
| 34 | + |
| 35 | +# Initialize the library with your data directory |
| 36 | +rel_manager = a11y.setup_instances(basedir='/path/to/your/data') |
| 37 | + |
| 38 | +# Access categories |
| 39 | +categories = a11y.Category.list_all() |
| 40 | +for category in categories: |
| 41 | + print(f"Category: {category.get_name('ja')}") |
| 42 | + |
| 43 | +# Access guidelines |
| 44 | +guidelines = a11y.Guideline.list_all() |
| 45 | +for guideline in guidelines: |
| 46 | + template_data = guideline.template_data('ja') |
| 47 | + print(f"Guideline: {template_data['title']}") |
| 48 | + |
| 49 | +# Access checks |
| 50 | +checks = a11y.Check.list_all() |
| 51 | +for check in checks: |
| 52 | + print(f"Check: {check.id}") |
| 53 | +``` |
| 54 | + |
| 55 | +### Working with Settings |
| 56 | + |
| 57 | +```python |
| 58 | +from freee_a11y_gl import settings |
| 59 | + |
| 60 | +# Access configuration |
| 61 | +config = settings.config |
| 62 | +print(f"Base URL: {config.base_url}") |
| 63 | +print(f"Available languages: {config.languages.available}") |
| 64 | + |
| 65 | +# Update settings |
| 66 | +settings.set('validation.yaml_validation', 'warning') |
| 67 | + |
| 68 | +# Initialize with custom profile |
| 69 | +settings.initialize(profile='development') |
| 70 | +``` |
| 71 | + |
| 72 | +### YAML Processing |
| 73 | + |
| 74 | +```python |
| 75 | +from freee_a11y_gl import process_yaml_data |
| 76 | + |
| 77 | +# Process YAML data with validation |
| 78 | +data = process_yaml_data('/path/to/yaml/file.yaml') |
| 79 | +``` |
| 80 | + |
| 81 | +## Data Structure |
| 82 | + |
| 83 | +The library expects a specific directory structure for your accessibility data: |
| 84 | + |
| 85 | +``` |
| 86 | +data/ |
| 87 | +├── json/ |
| 88 | +│ ├── guideline-categories.json |
| 89 | +│ ├── wcag-sc.json |
| 90 | +│ ├── faq-tags.json |
| 91 | +│ ├── info.json |
| 92 | +│ └── schemas/ |
| 93 | +│ ├── guideline.json |
| 94 | +│ ├── check.json |
| 95 | +│ └── faq.json |
| 96 | +└── yaml/ |
| 97 | + ├── gl/ # Guidelines |
| 98 | + ├── checks/ # Accessibility checks |
| 99 | + └── faq/ # FAQ articles |
| 100 | +``` |
| 101 | + |
| 102 | +## Core Models |
| 103 | + |
| 104 | +### Category |
| 105 | +Represents groupings of accessibility guidelines. |
| 106 | + |
| 107 | +```python |
| 108 | +category = a11y.Category.get_by_id('form') |
| 109 | +name_ja = category.get_name('ja') |
| 110 | +dependencies = category.get_dependency() |
| 111 | +``` |
| 112 | + |
| 113 | +### Guideline |
| 114 | +Represents individual accessibility guidelines. |
| 115 | + |
| 116 | +```python |
| 117 | +guideline = a11y.Guideline.get_by_id('form-labeling') |
| 118 | +template_data = guideline.template_data('ja') |
| 119 | +link_data = guideline.link_data('https://example.com') |
| 120 | +``` |
| 121 | + |
| 122 | +### Check |
| 123 | +Represents accessibility checks and validation rules. |
| 124 | + |
| 125 | +```python |
| 126 | +check = a11y.Check.get_by_id('form-label-check') |
| 127 | +template_data = check.template_data('ja', platform=['web']) |
| 128 | +``` |
| 129 | + |
| 130 | +### FAQ |
| 131 | +Represents frequently asked questions and articles. |
| 132 | + |
| 133 | +```python |
| 134 | +faq = a11y.Faq.get_by_id('p0001') |
| 135 | +template_data = faq.template_data('ja') |
| 136 | +``` |
| 137 | + |
| 138 | +## Configuration |
| 139 | + |
| 140 | +The library supports hierarchical configuration with the following precedence: |
| 141 | + |
| 142 | +1. Program-specified configuration (`settings.initialize()`) |
| 143 | +2. Profile settings (`~/.config/freee_a11y_gl/profiles/{profile}.yaml`) |
| 144 | +3. Default profile (`~/.config/freee_a11y_gl/profiles/default.yaml`) |
| 145 | +4. Library defaults (`~/.config/freee_a11y_gl/lib/config.yaml`) |
| 146 | +5. Built-in defaults |
| 147 | +6. Emergency fallback values |
| 148 | + |
| 149 | +### Configuration Example |
| 150 | + |
| 151 | +```yaml |
| 152 | +# ~/.config/freee_a11y_gl/profiles/development.yaml |
| 153 | +languages: |
| 154 | + available: ["ja", "en"] |
| 155 | + default: "ja" |
| 156 | +base_url: "https://localhost:3000" |
| 157 | +paths: |
| 158 | + guidelines: "/categories/" |
| 159 | + faq: "/faq/articles/" |
| 160 | +validation: |
| 161 | + yaml_validation: "warning" |
| 162 | +``` |
| 163 | +
|
| 164 | +## Validation |
| 165 | +
|
| 166 | +The library provides comprehensive YAML validation with three modes: |
| 167 | +
|
| 168 | +- **strict**: Validation errors cause program termination |
| 169 | +- **warning**: Validation errors are logged as warnings |
| 170 | +- **disabled**: No validation is performed |
| 171 | +
|
| 172 | +```python |
| 173 | +from freee_a11y_gl.yaml_validator import YamlValidator |
| 174 | + |
| 175 | +validator = YamlValidator('/path/to/schemas', 'strict') |
| 176 | +validator.validate_with_mode(data, 'guideline', '/path/to/file.yaml') |
| 177 | +``` |
| 178 | + |
| 179 | +## Error Handling |
| 180 | + |
| 181 | +The library includes robust error handling and recovery mechanisms: |
| 182 | + |
| 183 | +```python |
| 184 | +from freee_a11y_gl.error_recovery import ErrorRecovery |
| 185 | + |
| 186 | +recovery = ErrorRecovery() |
| 187 | +try: |
| 188 | + # Your code here |
| 189 | + pass |
| 190 | +except Exception as e: |
| 191 | + recovery.handle_error(e, context={'file': 'example.yaml'}) |
| 192 | +``` |
| 193 | + |
| 194 | +## Utilities |
| 195 | + |
| 196 | +### Version Information |
| 197 | + |
| 198 | +```python |
| 199 | +from freee_a11y_gl import get_version_info |
| 200 | + |
| 201 | +version_info = get_version_info() |
| 202 | +print(f"Version: {version_info['version']}") |
| 203 | +``` |
| 204 | + |
| 205 | +### Source Path Utilities |
| 206 | + |
| 207 | +```python |
| 208 | +from freee_a11y_gl import get_src_path |
| 209 | + |
| 210 | +src_paths = get_src_path('/path/to/data') |
| 211 | +print(f"Guidelines path: {src_paths['guidelines']}") |
| 212 | +``` |
| 213 | + |
| 214 | +### Info Links |
| 215 | + |
| 216 | +```python |
| 217 | +from freee_a11y_gl import get_info_links |
| 218 | + |
| 219 | +links = get_info_links() |
| 220 | +for link in links: |
| 221 | + print(f"Link: {link.url}") |
| 222 | +``` |
| 223 | + |
| 224 | +## Documentation |
| 225 | + |
| 226 | +For detailed API documentation and configuration guides, see the [docs](./docs/) directory: |
| 227 | + |
| 228 | +- [API Reference](./docs/API_REFERENCE.md) - Comprehensive API documentation |
| 229 | +- [Configuration Guide](./docs/CONFIGURATION.md) - Detailed configuration documentation |
| 230 | + |
| 231 | +## Development |
| 232 | + |
| 233 | +### Running Tests |
| 234 | + |
| 235 | +```bash |
| 236 | +cd tools/lib/freee_a11y_gl |
| 237 | +python -m pytest tests/ |
| 238 | +``` |
| 239 | + |
| 240 | +### Code Quality |
| 241 | + |
| 242 | +The library maintains high code quality standards: |
| 243 | +- 100% test coverage (594 tests) |
| 244 | +- Zero flake8 warnings |
| 245 | +- Comprehensive docstrings following PEP 257 |
| 246 | + |
| 247 | +## License |
| 248 | + |
| 249 | +This library is part of the freee accessibility guidelines project. |
| 250 | + |
| 251 | +## Contributing |
| 252 | + |
| 253 | +Please refer to the main project's contributing guidelines for information on how to contribute to this library. |
0 commit comments