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:
27
.github/sort_doxygen_warnings.py
vendored
Normal file
27
.github/sort_doxygen_warnings.py
vendored
Normal 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()
|
||||
Reference in New Issue
Block a user