docs: Add NEWS.md

This commit is contained in:
Dorota Czaplejewicz
2022-09-03 12:17:02 +00:00
parent decf547e41
commit 113970566b
2 changed files with 62 additions and 10 deletions

36
tools/make_message Executable file
View File

@ -0,0 +1,36 @@
#!/usr/bin/env python3
"""Extracts commit message for the last release from NEWS.md file.
"""
from itertools import dropwhile
import sys
with open('NEWS.md') as f:
contents = f.readlines()
if contents[0].startswith('## '):
name = contents[0][3:]
contents = contents[1:]
elif contents[1].startswith('---'):
name = contents[0]
contents = contents[2:]
else:
raise ValueError("Can't find release name")
name = name.strip()
print("Release", name)
# git wants a single newline between commit title and message body
print()
# meanwhile, markdown ignores newlines after a title
contents = dropwhile(lambda x: x.strip() == '', contents)
# Need to look up forward
contents = list(contents)
for line, nextline in zip(contents, contents[1:] + ['']):
if nextline.startswith('---') or line.startswith('## '):
break
elif nextline.startswith('===') or line.startswith('# '):
raise ValueError("Encountered title instead of release section")
print(line.strip())