docs: store the release-calendar information in csv (and fix tests)

Restructured text (and markdown) is painful to programatically
manipulate, most python parsers are geared towards writing markdown and
generating html. I'd like to move the calendar updates to being
scripted, as such using csv to store them will be convenient. This also
allows us to simplify our scripting that manipulates the table
considerably.

Acked-by: Eric Engestrom <eric@engestrom.ch>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8341>
This commit is contained in:
Dylan Baker
2021-01-04 16:39:27 -08:00
committed by Marge Bot
parent e1b7c42cc6
commit 8587e57f12
5 changed files with 54 additions and 150 deletions

View File

@@ -22,6 +22,7 @@
"""Update the main page, release notes, and calendar."""
import argparse
import csv
import pathlib
import subprocess
@@ -52,30 +53,24 @@ def update_release_notes(version: str) -> None:
def update_calendar(version: str) -> None:
p = pathlib.Path('docs') / 'release-calendar.rst'
p = pathlib.Path('docs') / 'release-calendar.csv'
with open(p, 'r') as f:
calendar = f.readlines()
with p.open('r') as f:
calendar = csv.reader(f)
branch = ''
skip_line = False
new_calendar = []
for line in calendar:
if version in line:
branch = line.split('|')[1].strip()
skip_line = True
elif skip_line:
skip_line = False
elif branch:
# Put the branch number back on the next line
new_calendar.append(line[:2] + branch + line[len(branch) + 2:])
branch = ''
else:
new_calendar.append(line)
branch = None
for i, line in enumerate(calendar):
if line[2] == version:
if line[0]:
branch = line[0]
break
if branch is not None:
calendar[i + 1][0] = branch
del calendar[i]
with open(p, 'w') as f:
for line in new_calendar:
f.write(line)
with p.open('w') as f:
writer = csv.writer(f)
writer.writerows(calendar)
subprocess.run(['git', 'add', p])