|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +This is the **freee Accessibility Guidelines** repository - a comprehensive documentation project for web and mobile accessibility guidelines. The project generates multi-language (Japanese/English) HTML documentation using Sphinx, with content sourced from YAML files and converted to reStructuredText. |
| 8 | + |
| 9 | +**Main branch:** `develop` |
| 10 | + |
| 11 | +**Published documentation:** https://a11y-guidelines.freee.co.jp/ |
| 12 | + |
| 13 | +## Core Architecture |
| 14 | + |
| 15 | +### Build System |
| 16 | + |
| 17 | +The project uses a **two-stage build process**: |
| 18 | + |
| 19 | +1. **YAML → RST conversion** (`yaml2rst` tool) |
| 20 | + - Converts YAML guideline/check/FAQ data to reStructuredText |
| 21 | + - Generates category pages, reference tables, and cross-references |
| 22 | + - Runs before Sphinx build |
| 23 | + |
| 24 | +2. **RST → HTML generation** (Sphinx) |
| 25 | + - Builds Japanese docs in `ja/` directory |
| 26 | + - Builds English docs in `en/` directory |
| 27 | + - Supports both multi-page HTML and single-page HTML output |
| 28 | + |
| 29 | +### Data Structure |
| 30 | + |
| 31 | +``` |
| 32 | +data/ |
| 33 | +├── json/ |
| 34 | +│ ├── guideline-categories.json # Category definitions |
| 35 | +│ ├── wcag-sc.json # WCAG success criteria mapping |
| 36 | +│ ├── faq-tags.json # FAQ tag definitions |
| 37 | +│ ├── info.json # Reference link definitions |
| 38 | +│ └── schemas/ # JSON schemas for validation |
| 39 | +│ ├── guideline.json |
| 40 | +│ ├── check.json |
| 41 | +│ └── faq.json |
| 42 | +└── yaml/ |
| 43 | + ├── gl/ # Guidelines by category |
| 44 | + ├── checks/ # Accessibility checks |
| 45 | + └── faq/ # FAQ articles |
| 46 | +``` |
| 47 | + |
| 48 | +### Custom Python Libraries |
| 49 | + |
| 50 | +**`tools/lib/freee_a11y_gl`** - Core library for accessibility guideline management |
| 51 | +- Models: Category, Guideline, Check, FAQ, WCAG mappings |
| 52 | +- YAML processing and validation |
| 53 | +- Relationship management between entities |
| 54 | +- Multi-language support |
| 55 | + |
| 56 | +**`tools/scripts/yaml2rst`** - RST content generator |
| 57 | +- Template-based content generation using Jinja2 |
| 58 | +- Converts YAML data to Sphinx-compatible RST files |
| 59 | +- Generates category pages, indexes, and cross-references |
| 60 | + |
| 61 | +## Common Commands |
| 62 | + |
| 63 | +### Building Documentation |
| 64 | + |
| 65 | +```bash |
| 66 | +# Build both Japanese and English HTML |
| 67 | +make html |
| 68 | + |
| 69 | +# Build specific language |
| 70 | +cd ja && make html |
| 71 | +cd en && make html |
| 72 | + |
| 73 | +# Build single-page HTML (singlehtml) |
| 74 | +make singlehtml |
| 75 | + |
| 76 | +# Clean build artifacts |
| 77 | +make clean |
| 78 | + |
| 79 | +# Check that all include files are referenced |
| 80 | +make check-includes |
| 81 | +``` |
| 82 | + |
| 83 | +### Testing and Validation |
| 84 | + |
| 85 | +```bash |
| 86 | +# Install dependencies |
| 87 | +pip install -r requirements.txt |
| 88 | +pip install -r requirements-dev.txt |
| 89 | +npm install |
| 90 | + |
| 91 | +# Run Python tests (yaml2rst) |
| 92 | +cd tools/scripts/yaml2rst |
| 93 | +python run_tests.py |
| 94 | +python run_tests.py --coverage |
| 95 | + |
| 96 | +# Run Python tests (freee_a11y_gl) |
| 97 | +cd tools/lib/freee_a11y_gl |
| 98 | +python -m pytest tests/ |
| 99 | + |
| 100 | +# Validate YAML against JSON schemas |
| 101 | +ajv validate --spec=draft2020 -s data/json/schemas/guideline.json -r data/json/schemas/common.json -d data/yaml/gl/form/label.yaml |
| 102 | + |
| 103 | +# Lint reStructuredText files |
| 104 | +sphinx-lint --enable all --disable line-too-long ja/**/*.rst |
| 105 | + |
| 106 | +# Lint Japanese text (textlint) |
| 107 | +npx textlint ja/source/**/*.rst |
| 108 | + |
| 109 | +# Code quality (Python) |
| 110 | +black tools/ |
| 111 | +isort tools/ |
| 112 | +flake8 tools/ |
| 113 | +mypy tools/ |
| 114 | +``` |
| 115 | + |
| 116 | +### Development Workflow |
| 117 | + |
| 118 | +The build process for each language (ja/en) follows: |
| 119 | + |
| 120 | +1. `yaml2rst` generates RST files from YAML data into `source/inc/` and `source/faq/` |
| 121 | +2. `incfiles.mk` tracks dependencies |
| 122 | +3. Sphinx builds HTML from RST sources in `source/` directory |
| 123 | +4. Output goes to `build/html/` (or `build/singlehtml/`) |
| 124 | + |
| 125 | +### Working with Guidelines |
| 126 | + |
| 127 | +Each guideline YAML file structure: |
| 128 | +```yaml |
| 129 | +id: gl-category-name # Unique ID with gl- prefix |
| 130 | +sortKey: 1901 # Integer 1001-2199 for ordering |
| 131 | +category: form # Category identifier |
| 132 | +title: |
| 133 | + ja: "日本語タイトル" |
| 134 | + en: "English Title" |
| 135 | +platform: |
| 136 | + - web # web and/or mobile |
| 137 | + - mobile |
| 138 | +guideline: |
| 139 | + ja: "ガイドライン本文" |
| 140 | + en: "Guideline text" |
| 141 | +sc: # WCAG success criteria |
| 142 | + - 1.1.1 |
| 143 | + - 1.3.1 |
| 144 | +intent: |
| 145 | + ja: "意図の説明" |
| 146 | + en: "Intent explanation" |
| 147 | +checks: # Related check IDs |
| 148 | + - '0931' |
| 149 | +info: # Related info links |
| 150 | + - exp-form-labeling |
| 151 | +``` |
| 152 | +
|
| 153 | +### Pre-commit Hooks |
| 154 | +
|
| 155 | +The repository uses **Husky + lint-staged** for pre-commit validation: |
| 156 | +- JSON schema validation for YAML files |
| 157 | +- Sphinx linting for RST files |
| 158 | +- Runs automatically on `git commit` |
| 159 | + |
| 160 | +Configuration in `.lintstagedrc.mjs` |
| 161 | + |
| 162 | +## Version Management |
| 163 | + |
| 164 | +Version information is stored in `version.py`: |
| 165 | +- `guidelines_version` - Main version (e.g., 'Ver. 202508.0') |
| 166 | +- `checksheet_version` - Checksheet version |
| 167 | +- `publishedDate` - Publication date |
| 168 | + |
| 169 | +This file is imported by Sphinx configuration to set document version. |
| 170 | + |
| 171 | +## Internationalization |
| 172 | + |
| 173 | +The project supports **Japanese (ja)** and **English (en)**: |
| 174 | + |
| 175 | +- Both languages share the same data structure |
| 176 | +- YAML files contain i18n strings with `ja:` and `en:` keys |
| 177 | +- Template directory symlink: `en/source/_templates → ja/source/_templates` |
| 178 | +- Each language has its own Sphinx `conf.py` with locale settings |
| 179 | + |
| 180 | +## Build Environment Notes |
| 181 | + |
| 182 | +- **Locale required:** `ja_JP.UTF-8` must be installed for Japanese date formatting |
| 183 | +- **Python version:** 3.9+ (see requirements) |
| 184 | +- **Sphinx:** ~7.0 (specified in requirements.txt) |
| 185 | +- **Theme:** sphinx_rtd_theme ~3.0 |
| 186 | + |
| 187 | +## GitHub Actions |
| 188 | + |
| 189 | +The repository uses reusable workflows for building: |
| 190 | +- `.github/workflows/reusable-build-doc.yml` - Main build workflow |
| 191 | +- Builds for specific tags/versions with configurable Python/Sphinx/theme versions |
| 192 | +- Supports artifact reuse to avoid rebuilding unchanged content |
| 193 | +- Environment variables: `BASE_URL`, `GTM_ID`, build flags |
| 194 | + |
| 195 | +## Common Tasks |
| 196 | + |
| 197 | +**Adding a new guideline:** |
| 198 | +1. Create YAML file in appropriate `data/yaml/gl/{category}/` directory |
| 199 | +2. Follow the guideline schema (see `data/json/schemas/guideline.json`) |
| 200 | +3. Run `make clean` and `make html` to rebuild |
| 201 | +4. Validate with `ajv validate` command |
| 202 | + |
| 203 | +**Modifying templates:** |
| 204 | +1. Templates are in `yaml2rst` package (Jinja2 format) |
| 205 | +2. Export with: `yaml2rst --export-templates` |
| 206 | +3. Customize in `~/.config/freee_a11y_gl/templates/` |
| 207 | +4. Template resolution: custom → user → built-in |
| 208 | + |
| 209 | +**Testing a single component:** |
| 210 | +```bash |
| 211 | +# Test yaml2rst |
| 212 | +cd tools/scripts/yaml2rst |
| 213 | +pytest tests/unit/test_specific.py -v |
| 214 | +
|
| 215 | +# Test freee_a11y_gl |
| 216 | +cd tools/lib/freee_a11y_gl |
| 217 | +pytest tests/ -k "test_name" |
| 218 | +``` |
0 commit comments