From f4a1b9ec1bf59d497a402d71629250e30d955107 Mon Sep 17 00:00:00 2001 From: mehm8128 Date: Thu, 15 Oct 2026 22:59:30 +0900 Subject: [PATCH] =?UTF-8?q?make=5Ftests.py=20=E3=81=A7=E9=96=A2=E9=80=A3?= =?UTF-8?q?=E3=81=99=E3=82=8B=E8=A6=81=E7=B4=A0=E3=82=84=E5=B1=9E=E6=80=A7?= =?UTF-8?q?=E3=82=92=20selectors=20=E3=81=A8=E3=81=97=E3=81=A6=E5=87=BA?= =?UTF-8?q?=E5=8A=9B=E3=81=97=E3=80=81update=5Fguide.md=20=E3=81=AE=20tech?= =?UTF-8?q?s/criteria=20=E3=81=AE=E8=AA=AC=E6=98=8E=E3=82=92=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- make_tests.py | 16 +++++++++++++++- update_guide.md | 6 ++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/make_tests.py b/make_tests.py index beb56dd..98a6715 100644 --- a/make_tests.py +++ b/make_tests.py @@ -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, @@ -58,6 +61,14 @@ 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 @@ -65,7 +76,7 @@ def extract_info_from_md(file_path): # 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, @@ -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 diff --git a/update_guide.md b/update_guide.md index 89156aa..fcca622 100644 --- a/update_guide.md +++ b/update_guide.md @@ -238,6 +238,7 @@ uv run make_tests.py ``` カレントディレクトリに `tests.yaml` が生成されます。 +`as_test` の「関連する要素や属性」(`input[type="text"]` のようなセレクタ形式の箇条書き)は、各テストの `selectors` として出力されます(「なし」のテストには出力されません)。 ```bash # 生成件数を確認(期待値と一致するか) @@ -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. 差分の確認 @@ -268,7 +270,7 @@ git -C ../as_info diff src/content/tests/tests.yaml ## 4. criteria / techs / metadata の更新(必要に応じて) -WCAG 達成基準や達成方法(テクニック集)、サイトのメタデータを更新する場合: +WCAG 達成基準や達成方法(テクニック集)、サイトのメタデータを更新する場合は、下記のファイルを手動で編集し(生成するコマンドはありません)、並べ替えスクリプトを実行します。 ```bash cd ../as_info