History

TOOLS/gen-interface-changes.py: sort interface changes by file content

With the previous commit, they're in effect sorted by the types of the interface changes. As a lazy measure to sort changes by the breakages they cause, sort the content reverse alphabetically, which works OK by accident.

nanahi committed 2 years ago

Commit e8905651 parent 20bd4481 file · +10 −9Browse files

Unified · Split

TOOLS/gen-interface-changes.py+10−9
@@ -34,18 +34,19 @@ def add_new_entries(docs_dir, out, git): · 33 unmodified lines
34 timestamp = check_output([git, "log", "--format=%ct", "-n", "1", "--",34 timestamp = check_output([git, "log", "--format=%ct", "-n", "1", "--",
35 f], encoding="UTF-8")35 f], encoding="UTF-8")
36 if timestamp:36 if timestamp:
37 files.append((f, timestamp))37 content = f.read_text()
38 files.append(content)
38 else:39 else:
39 print(f"Skipping file not tracked by git: {f.name}")40 print(f"Skipping file not tracked by git: {f.name}")
40 41
41 files.sort(key=lambda x: x[1])42 # Sort the changes by "severity", which roughly corresponds to
42 for file in files:43 # alphabetical order by accident (e.g. remove > deprecate > change > add)
43 with open(file[0].resolve(), "r") as f:44 for file in reversed(sorted(files)):
44 for line in f:45 for line in file.splitlines():
45 line = textwrap.fill(line.rstrip(), width=80,46 line = textwrap.fill(line.rstrip(), width=80,
46 initial_indent=" - ",47 initial_indent=" - ",
47 subsequent_indent=" ")48 subsequent_indent=" ")
48 out.write(line + "\n")49 out.write(line + "\n")
49 50
50if __name__ == "__main__":51if __name__ == "__main__":
51 if len(sys.argv) < 2:52 if len(sys.argv) < 2:

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t