|
10 | 10 |
|
11 | 11 |
|
12 | 12 | def update_home_wiki_page(wiki_dir: Path, year_month: str) -> None:
|
13 |
| - TABLE_BEGINNING = """\ |
| 13 | + YEAR_MONTHLY_TABLES = "<!-- YEAR_MONTHLY_TABLES -->\n" |
| 14 | + |
| 15 | + TABLE_HEADER = """\ |
14 | 16 | | Month |
|
15 | 17 | | ---------------------- |
|
16 | 18 | """
|
| 19 | + |
17 | 20 | wiki_home_file = wiki_dir / "Home.md"
|
18 | 21 | wiki_home_content = wiki_home_file.read_text()
|
| 22 | + |
| 23 | + year = year_month[:4] |
| 24 | + year_header = f"## {year}\n" |
| 25 | + if year_header not in wiki_home_content: |
| 26 | + assert YEAR_MONTHLY_TABLES in wiki_home_content |
| 27 | + wiki_home_content = wiki_home_content.replace( |
| 28 | + YEAR_MONTHLY_TABLES, |
| 29 | + YEAR_MONTHLY_TABLES + f"\n{year_header}\n{TABLE_HEADER}", |
| 30 | + ) |
| 31 | + LOGGER.info(f"Updated wiki home page with year header for year: {year}") |
| 32 | + |
19 | 33 | year_month_line = f"| [`{year_month}`](./{year_month}) |\n"
|
20 | 34 | if year_month_line not in wiki_home_content:
|
21 |
| - assert TABLE_BEGINNING in wiki_home_content |
| 35 | + assert TABLE_HEADER in wiki_home_content |
22 | 36 | wiki_home_content = wiki_home_content.replace(
|
23 |
| - TABLE_BEGINNING, TABLE_BEGINNING + year_month_line |
| 37 | + TABLE_HEADER, TABLE_HEADER + year_month_line |
24 | 38 | )
|
25 |
| - wiki_home_file.write_text(wiki_home_content) |
26 | 39 | LOGGER.info(f"Updated wiki home page with month: {year_month}")
|
27 | 40 |
|
| 41 | + wiki_home_file.write_text(wiki_home_content) |
| 42 | + |
28 | 43 |
|
29 | 44 | def update_monthly_wiki_page(
|
30 | 45 | wiki_dir: Path, year_month: str, build_history_line: str
|
|
0 commit comments