chore: convert changelog to markdown (#5672)

* chore: move changelog to markdown

* chore: switch to simpler block def

Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>

* style: pre-commit fixes

* chore: handle more block ends

Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>

* docs: fix md display

Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>

* docs: one more fix

Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>

* style: pre-commit fixes

---------

Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
Henry Schreiner
2025-05-20 14:52:14 -04:00
committed by GitHub
parent e625668439
commit ec8b050824
10 changed files with 3184 additions and 3859 deletions

View File

@@ -12,19 +12,20 @@ import ghapi.all
from rich import print
from rich.syntax import Syntax
ENTRY = re.compile(
MD_ENTRY = re.compile(
r"""
Suggested \s changelog \s entry:
.*
```rst
\s*
(.*?)
\s*
```
""",
re.DOTALL | re.VERBOSE,
\#\#\ Suggested\ changelog\ entry: # Match the heading exactly
(?:\s*<!--.*?-->)? # Optionally match one comment
(?P<content>.*?) # Lazily capture content until...
(?= # Lookahead for one of the following:
^-{3,}\s*$ # A line with 3 or more dashes
| ^<!--\s*readthedocs # A comment starting with 'readthedocs'
| ^\#\# # A new heading
| \Z # End of string
)
""",
re.DOTALL | re.VERBOSE | re.MULTILINE,
)
print()
@@ -35,6 +36,7 @@ issues_pages = ghapi.page.paged(
)
issues = (issue for page in issues_pages for issue in page)
missing = []
old = []
cats_descr = {
"feat": "New Features",
"feat(types)": "",
@@ -53,33 +55,38 @@ cats_descr = {
cats: dict[str, list[str]] = {c: [] for c in cats_descr}
for issue in issues:
changelog = ENTRY.findall(issue.body or "")
if not changelog or not changelog[0]:
missing.append(issue)
else:
(msg,) = changelog
if msg.startswith("- "):
msg = msg[2:]
if not msg.startswith("* "):
msg = "* " + msg
if not msg.endswith("."):
msg += "."
if "```rst" in issue.body:
old.append(issue)
continue
msg += f"\n `#{issue.number} <{issue.html_url}>`_"
for cat, cat_list in cats.items():
if issue.title.lower().startswith(f"{cat}:"):
cat_list.append(msg)
break
else:
cats["unknown"].append(msg)
changelog = MD_ENTRY.search(issue.body or "")
if not changelog:
missing.append(issue)
continue
msg = changelog.group("content").strip()
if msg.startswith("- "):
msg = msg[2:]
if not msg.startswith("* "):
msg = "* " + msg
if not msg.endswith("."):
msg += "."
msg += f"\n [#{issue.number}]({issue.html_url})"
for cat, cat_list in cats.items():
if issue.title.lower().startswith(f"{cat}:"):
cat_list.append(msg)
break
else:
cats["unknown"].append(msg)
for cat, msgs in cats.items():
if msgs:
desc = cats_descr[cat]
print(f"[bold]{desc}:" if desc else f".. {cat}")
print(f"[bold]{desc}:" if desc else f"<!-- {cat} -->")
print()
for msg in msgs:
print(Syntax(msg, "rst", theme="ansi_light", word_wrap=True))
print(Syntax(msg, "md", theme="ansi_light", word_wrap=True))
print()
print()
@@ -93,7 +100,16 @@ if missing:
print(f"[red] {issue.html_url}\n")
print("[bold]Template:\n")
msg = "## Suggested changelog entry:\n\n```rst\n\n```"
msg = "## Suggested changelog entry:"
print(Syntax(msg, "md", theme="ansi_light"))
if old:
print()
print("[red]" + "-" * 30)
print()
for issue in old:
print(f"[red bold]Old:[/red bold][red] {issue.title}")
print(f"[red] {issue.html_url}\n")
print()