Skip to content

Commit

Permalink
added script to regroup release notes for official release by parsing…
Browse files Browse the repository at this point in the history
… dev release notes. improve naming of drop downs for generating dev release notes to be consistent
  • Loading branch information
georgemccabe committed Dec 18, 2024
1 parent 4ff2950 commit 78987fb
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 1 deletion.
54 changes: 54 additions & 0 deletions internal/scripts/dev_tools/compile_official_release_notes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#! /usr/bin/env python3

# Written by George McCabe <[email protected]>
# Helper script that parses release notes from development releases,
# gathers all issues by category, sorts them by issue number, then
# outputs the formatted content
# Note: Careful review and massaging of output is likely needed
# Run this script from the top of the repository to parse
# Assumes location and name of release notes RST file

import re

infile = './docs/Users_Guide/release-notes.rst'

with open(infile, 'r') as file_handle:
content = file_handle.read().splitlines()

category = None
items = {}
# gather issues and organize them by category
for line in content:
if match := re.match(r' .. dropdown:: (.*)', line):
category = match.group(1)
if not items.get(category):
items[category] = []
continue
if category is None: continue
if not line: continue
if line.strip().startswith('.. _'):
break
if line.lstrip().startswith('*'):
items[category].append(line)
elif line.strip() == 'NONE' or line.startswith('MET') or line.startswith('---') or line.startswith('==='):
continue
else:
items[category][-1] += f'\n{line}'

# get issues in each category to sort
issues = {}
for cat, item_list in items.items():
if not issues.get(cat):
issues[cat] = {}
for issue in item_list:
match = re.match(r'.*\#(\d+).*', issue.replace('\n', ''))
if match:
issues[cat][match.group(1)] = issue

# sort issues within each category and print formatted result
for cat in issues:
nums = sorted([int(item) for item in issues[cat].keys()])
print(f" .. dropdown:: {cat}\n")
for num in nums:
print(issues[cat][str(num)])
print()
5 changes: 4 additions & 1 deletion internal/scripts/dev_tools/generate_release_notes.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,10 @@ def print_issues_by_category(repo_name, issues_by_category):
for category, issues in issues_by_category.items():
print()
if category != 'none':
print(f" .. dropdown:: {category}\n")
header = category
if header in ('Enhancement', 'New Wrapper', 'New Use Case'):
header = f'{header}s'
print(f" .. dropdown:: {header}\n")
elif issues:
print('COULD NOT PARSE CATEGORY FROM THESE:\n')

Expand Down

0 comments on commit 78987fb

Please sign in to comment.