Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion make_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ def extract_info_from_md(file_path):
techs_match = re.search(
r"# 関連する達成方法(?:\s*\(複数\))?\s*\n\s*((?:(?!^#).)*?)(?=\n#|\Z)", content, re.DOTALL | re.MULTILINE
)
selectors_match = re.search(
r"^# 関連する要素や属性[ \t]*\r?\n(.*?)(?=^# |\Z)", content, re.DOTALL | re.MULTILINE
)
code_link_match = re.search(
r"# テストコード \(テストファイルへのリンク\)\s*\n\s*((?:\[.*?\]\(.*?\)(?:\s*,\s*)?)+)",
content,
Expand Down Expand Up @@ -58,14 +61,22 @@ def extract_info_from_md(file_path):
# Skip empty items and "なし" variants
if item and item not in ("なし", "今のところなし", "無し"):
techs.append(item)
# 関連する要素や属性(セレクタ形式の箇条書き。「なし」は除く)
selectors = []
if selectors_match:
selectors = [
item
for item in re.findall(r"^- (.+?)\s*$", selectors_match.group(1), re.MULTILINE)
if item != "なし"
]
# テストコードのリンクをすべて抽出(複数リンクは配列にする)
code_links = re.findall(r"\[.*?\]\((.*?)\)", code_link_match.group(1))
code_link = code_links[0] if len(code_links) == 1 else code_links

# document は既存の as_info の形式(waic.github.io の .html)に合わせる
doc_basename = os.path.basename(file_path).replace(".md", ".html")

return test_id, OrderedDict(
info = OrderedDict(
{
"title": title,
"code": code_link,
Expand All @@ -74,6 +85,9 @@ def extract_info_from_md(file_path):
"techs": techs,
}
)
if selectors:
info["selectors"] = selectors
return test_id, info
return None, None


Expand Down
6 changes: 4 additions & 2 deletions update_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ uv run make_tests.py
```

カレントディレクトリに `tests.yaml` が生成されます。
`as_test` の「関連する要素や属性」(`input[type="text"]` のようなセレクタ形式の箇条書き)は、各テストの `selectors` として出力されます(「なし」のテストには出力されません)。

```bash
# 生成件数を確認(期待値と一致するか)
Expand All @@ -256,7 +257,8 @@ uv run update_tests_yaml.py tests.yaml
```

- `../as_info/src/content/tests/tests.yaml` を更新します。
- `criteria` と `techs` も `as_test` の最新状態から更新されます。
- 各テストの `criteria` と `techs`(達成基準・達成方法の ID)は `as_test` の最新状態に更新されますが、`criteria.yaml` と `techs.yaml` 自体は更新されません。
- 新しいテストが `techs.yaml` や `criteria.yaml` にない ID を参照している場合は、[4. criteria / techs / metadata の更新](#4-criteria--techs--metadata-の更新必要に応じて) で手動で追加します(未追加のままだと as_info のビルドや `checkdata.py` が失敗します)。

### 3-4. 差分の確認

Expand All @@ -268,7 +270,7 @@ git -C ../as_info diff src/content/tests/tests.yaml

## 4. criteria / techs / metadata の更新(必要に応じて)

WCAG 達成基準や達成方法(テクニック集)、サイトのメタデータを更新する場合:
WCAG 達成基準や達成方法(テクニック集)、サイトのメタデータを更新する場合は、下記のファイルを手動で編集し(生成するコマンドはありません)、並べ替えスクリプトを実行します。

```bash
cd ../as_info
Expand Down