1
0
mirror of https://github.com/OpenTTD/OpenTTD synced 2026-01-30 23:54:35 +01:00

Codechange: Add sorter for doxygen warnings.

This commit is contained in:
Rito12
2026-01-28 13:22:42 +01:00
committed by rubidium42
parent a42ba2493e
commit a706ac7dc9

27
.github/sort_doxygen_warnings.py vendored Normal file
View File

@@ -0,0 +1,27 @@
""" Script that sorts warnings generated by doxygen to maintain consistent order. """
import sys
def read_by_line(file_path):
with open(file_path, "r") as f:
while line := f.readline():
yield line[:-1]
def main():
if len(sys.argv) != 3:
print("Wrong number of arguments provided, expected two.")
print("Usage: python3 sort_doxygen_warnings.py [input_file] [output_file]")
sys.exit(1)
warnings = []
for line in read_by_line(sys.argv[1]):
if "warning:" in line or "error:" in line:
warnings.append(line)
continue
# Doxygen warnings can span multiple lines, keep these lines together.
warnings[-1] = f"{warnings[-1]}\n{line}"
warnings.sort()
with open(sys.argv[2], "w") as out:
out.write("\n".join(warnings))
print("Doxygen warnings sorted successfully.")
if __name__ == "__main__":
main()