summaryrefslogtreecommitdiffstats
path: root/TOOLS/gen-interface-changes.py
diff options
context:
space:
mode:
Diffstat (limited to 'TOOLS/gen-interface-changes.py')
-rwxr-xr-xTOOLS/gen-interface-changes.py18
1 files changed, 11 insertions, 7 deletions
diff --git a/TOOLS/gen-interface-changes.py b/TOOLS/gen-interface-changes.py
index 7f5435e216..3a415192af 100755
--- a/TOOLS/gen-interface-changes.py
+++ b/TOOLS/gen-interface-changes.py
@@ -22,6 +22,7 @@
import pathlib
import sys
+import textwrap
from shutil import which
from subprocess import check_output
@@ -33,16 +34,19 @@ def add_new_entries(docs_dir, out, git):
timestamp = check_output([git, "log", "--format=%ct", "-n", "1", "--",
f], encoding="UTF-8")
if timestamp:
- files.append((f, timestamp))
+ content = f.read_text()
+ files.append(content)
else:
print(f"Skipping file not tracked by git: {f.name}")
- files.sort(key=lambda x: x[1])
- for file in files:
- with open(file[0].resolve(), "r") as f:
- for line in f:
- line = " - " + line.rstrip()
- out.write(line + "\n")
+ # Sort the changes by "severity", which roughly corresponds to
+ # alphabetical order by accident (e.g. remove > deprecate > change > add)
+ for file in reversed(sorted(files)):
+ for line in file.splitlines():
+ line = textwrap.fill(line.rstrip(), width=80,
+ initial_indent=" - ",
+ subsequent_indent=" ")
+ out.write(line + "\n")
if __name__ == "__main__":
if len(sys.argv) < 2: