Check which Markdown files are out of sync with JSON data. Returns list of out-of-sync files.
()
| 1092 | |
| 1093 | |
| 1094 | def verify_sync() -> list[str]: |
| 1095 | """Check which Markdown files are out of sync with JSON data. Returns list of out-of-sync files.""" |
| 1096 | out_of_sync = [] |
| 1097 | |
| 1098 | # Check standards |
| 1099 | standards_dir = ROOT / "eu_mdr" / "standards" |
| 1100 | index_path = standards_dir / "_index.json" |
| 1101 | if not index_path.exists(): |
| 1102 | print(" WARN: eu_mdr/standards/_index.json not found") |
| 1103 | return out_of_sync |
| 1104 | |
| 1105 | index_data = load_json(index_path) |
| 1106 | |
| 1107 | for cat_slug, cat_info in index_data.get("categories", {}).items(): |
| 1108 | json_file = cat_info.get("file") |
| 1109 | if not json_file: |
| 1110 | continue |
| 1111 | json_path = standards_dir / json_file |
| 1112 | if not json_path.exists(): |
| 1113 | continue |
| 1114 | |
| 1115 | data = load_json(json_path) |
| 1116 | slug = cat_slug.replace("_", "-") |
| 1117 | |
| 1118 | # Check ZH |
| 1119 | zh_path = DOCS_ZH / "eu_mdr" / "standards" / f"{slug}.md" |
| 1120 | zh_content = generate_standards_subpage_zh(cat_slug, data, index_data) |
| 1121 | if zh_path.exists(): |
| 1122 | old = zh_path.read_text(encoding="utf-8") |
| 1123 | if old.strip() != zh_content.strip(): |
| 1124 | out_of_sync.append(str(zh_path.relative_to(ROOT))) |
| 1125 | else: |
| 1126 | out_of_sync.append(str(zh_path.relative_to(ROOT)) + " (MISSING)") |
| 1127 | |
| 1128 | # Check EN |
| 1129 | en_path = DOCS_EN / "eu_mdr" / "standards" / f"{slug}.md" |
| 1130 | en_content = generate_standards_subpage_en(cat_slug, data, index_data) |
| 1131 | if en_path.exists(): |
| 1132 | old = en_path.read_text(encoding="utf-8") |
| 1133 | if old.strip() != en_content.strip(): |
| 1134 | out_of_sync.append(str(en_path.relative_to(ROOT))) |
| 1135 | else: |
| 1136 | out_of_sync.append(str(en_path.relative_to(ROOT)) + " (MISSING)") |
| 1137 | |
| 1138 | return out_of_sync |
| 1139 | |
| 1140 | |
| 1141 | # --------------------------------------------------------------------------- |
no test coverage detected