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
3434 timestamp = check_output([git, "log", "--format=%ct", "-n", "1", "--",
3535 f], encoding="UTF-8")
3636 if timestamp:
37− files.append((f, timestamp))
37+ content = f.read_text()
38+ files.append(content)
3839 else:
3940 print(f"Skipping file not tracked by git: {f.name}")
4041
41− files.sort(key=lambda x: x[1])
42− for file in files:
43− with open(file[0].resolve(), "r") as f:
44− for line in f:
45− line = textwrap.fill(line.rstrip(), width=80,
46− initial_indent=" - ",
47− subsequent_indent=" ")
48− out.write(line + "\n")
42+ # Sort the changes by "severity", which roughly corresponds to
43+ # alphabetical order by accident (e.g. remove > deprecate > change > add)
44+ for file in reversed(sorted(files)):
45+ for line in file.splitlines():
46+ line = textwrap.fill(line.rstrip(), width=80,
47+ initial_indent=" - ",
48+ subsequent_indent=" ")
49+ out.write(line + "\n")
4950
5051 if __name__ == "__main__":
5152 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