make_changelog.py
Go to the documentation of this file.
1 #!/usr/bin/env python3
2 from __future__ import annotations
3 
4 import re
5 
6 import ghapi.all
7 from rich import print
8 from rich.syntax import Syntax
9 
10 ENTRY = re.compile(
11  r"""
12  Suggested \s changelog \s entry:
13  .*
14  ```rst
15  \s*
16  (.*?)
17  \s*
18  ```
19 """,
20  re.DOTALL | re.VERBOSE,
21 )
22 
23 print()
24 
25 
26 api = ghapi.all.GhApi(owner="pybind", repo="pybind11")
27 
28 issues_pages = ghapi.page.paged(
29  api.issues.list_for_repo, labels="needs changelog", state="closed"
30 )
31 issues = (issue for page in issues_pages for issue in page)
32 missing = []
33 cats_descr = {
34  "feat": "New Features",
35  "feat(types)": "",
36  "feat(cmake)": "",
37  "fix": "Bug fixes",
38  "fix(types)": "",
39  "fix(cmake)": "",
40  "docs": "Documentation",
41  "tests": "Tests",
42  "ci": "CI",
43  "chore": "Other",
44  "unknown": "Uncategorised",
45 }
46 cats: dict[str, list[str]] = {c: [] for c in cats_descr}
47 
48 for issue in issues:
49  changelog = ENTRY.findall(issue.body or "")
50  if not changelog or not changelog[0]:
51  missing.append(issue)
52  else:
53  (msg,) = changelog
54  if msg.startswith("- "):
55  msg = msg[2:]
56  if not msg.startswith("* "):
57  msg = "* " + msg
58  if not msg.endswith("."):
59  msg += "."
60 
61  msg += f"\n `#{issue.number} <{issue.html_url}>`_"
62  for cat in cats:
63  if issue.title.lower().startswith(f"{cat}:"):
64  cats[cat].append(msg)
65  break
66  else:
67  cats["unknown"].append(msg)
68 
69 for cat, msgs in cats.items():
70  if msgs:
71  desc = cats_descr[cat]
72  print(f"[bold]{desc}:" if desc else f".. {cat}")
73  print()
74  for msg in msgs:
75  print(Syntax(msg, "rst", theme="ansi_light", word_wrap=True))
76  print()
77  print()
78 
79 if missing:
80  print()
81  print("[blue]" + "-" * 30)
82  print()
83 
84  for issue in missing:
85  print(f"[red bold]Missing:[/red bold][red] {issue.title}")
86  print(f"[red] {issue.html_url}\n")
87 
88  print("[bold]Template:\n")
89  msg = "## Suggested changelog entry:\n\n```rst\n\n```"
90  print(Syntax(msg, "md", theme="ansi_light"))
91 
92 print()
Eigen::internal::print
EIGEN_STRONG_INLINE Packet4f print(const Packet4f &a)
Definition: NEON/PacketMath.h:3115


gtsam
Author(s):
autogenerated on Fri Nov 1 2024 03:33:10