MCPcopy Create free account
hub / github.com/crisxuan/bestJavaer / write_category_index

Function write_category_index

scripts/generate_english_articles.py:350–368  ·  view source on GitHub ↗
(category: str, meta: dict[str, str], article_map: dict[str, dict[str, str]])

Source from the content-addressed store, hash-verified

348
349
350def write_category_index(category: str, meta: dict[str, str], article_map: dict[str, dict[str, str]]) -> None:
351 lines = [
352 f"# {meta['title']}",
353 "",
354 meta["description"],
355 "",
356 ]
357 source_items = parse_index_items(SOURCE_ROOT / category / "README.md")
358 for date, _title, href in source_items:
359 source_path = (SOURCE_ROOT / category / unquote(href.split("?")[0].split("#")[0].replace("./", ""))).resolve()
360 source_rel = source_path.relative_to(ROOT).as_posix()
361 mapped = article_map.get(source_rel)
362 if not mapped:
363 continue
364 file_name = Path(mapped["english_path"]).name
365 lines.append(f"- {date} - [{mapped['english_title']}](./{file_name})")
366
367 lines.extend(["", '<p class="branch-back"><a href="#/en/ai-articles/README">Back</a></p>', ""])
368 (TARGET_ROOT / category / "README.md").write_text("\n".join(lines), encoding="utf-8")
369
370
371def update_english_readme_links(article_map: dict[str, dict[str, str]]) -> None:

Callers 1

write_indexesFunction · 0.85

Calls 1

parse_index_itemsFunction · 0.85

Tested by

no test coverage detected