[clang] [clang-format] Add --strip-trailing-cr to diff in docs_updated.test (PR #119666)
Owen Pan via cfe-commits
cfe-commits at lists.llvm.org
Wed Dec 11 23:20:33 PST 2024
https://github.com/owenca created https://github.com/llvm/llvm-project/pull/119666
Also clean up dump_format_style.py and dump_format_help.py.
>From 6105a4ba95e7458623e2bf7363f0d454c3bd1b9a Mon Sep 17 00:00:00 2001
From: Owen Pan <owenpiano at gmail.com>
Date: Wed, 11 Dec 2024 23:14:29 -0800
Subject: [PATCH] [clang-format] Add --strip-trailing-cr to diff in
docs_updated.test
Also clean up dump_format_style.py and dump_format_help.py.
---
clang/docs/tools/dump_format_help.py | 6 ++++--
clang/docs/tools/dump_format_style.py | 10 ++++++----
clang/test/Format/docs_updated.test | 5 +++--
3 files changed, 13 insertions(+), 8 deletions(-)
diff --git a/clang/docs/tools/dump_format_help.py b/clang/docs/tools/dump_format_help.py
index baf90048ee1352..ba41ed8c02c817 100755
--- a/clang/docs/tools/dump_format_help.py
+++ b/clang/docs/tools/dump_format_help.py
@@ -72,5 +72,7 @@ def validate(text, columns):
contents = substitute(contents, "FORMAT_HELP", help_text)
-with open(opts.output if opts.output else DOC_FILE, "wb") as output:
- output.write(contents.encode())
+with open(
+ opts.output if opts.output else DOC_FILE, "w", newline="", encoding="utf-8"
+) as f:
+ f.write(contents)
diff --git a/clang/docs/tools/dump_format_style.py b/clang/docs/tools/dump_format_style.py
index f00f3ee8b20e87..f035143f6b3d14 100755
--- a/clang/docs/tools/dump_format_style.py
+++ b/clang/docs/tools/dump_format_style.py
@@ -411,8 +411,8 @@ class State:
state = State.InStruct
enums[enum.name] = enum
else:
- # Enum member without documentation. Must be documented where the enum
- # is used.
+ # Enum member without documentation. Must be documented
+ # where the enum is used.
pass
elif state == State.InNestedEnum:
if line.startswith("///"):
@@ -492,5 +492,7 @@ class State:
contents = substitute(contents, "FORMAT_STYLE_OPTIONS", options_text)
-with open(args.output if args.output else DOC_FILE, "wb") as output:
- output.write(contents.encode())
+with open(
+ args.output if args.output else DOC_FILE, "w", newline="", encoding="utf-8"
+) as f:
+ f.write(contents)
diff --git a/clang/test/Format/docs_updated.test b/clang/test/Format/docs_updated.test
index 17066650a12677..98d330e37ef450 100644
--- a/clang/test/Format/docs_updated.test
+++ b/clang/test/Format/docs_updated.test
@@ -1,5 +1,6 @@
// RUN: %python %S/../../docs/tools/dump_format_style.py -o %t.style
-// RUN: diff %t.style %S/../../docs/ClangFormatStyleOptions.rst
+// RUN: diff --strip-trailing-cr %t.style \
+// RUN: %S/../../docs/ClangFormatStyleOptions.rst
// RUN: %python %S/../../docs/tools/dump_format_help.py -o %t.help
-// RUN: diff %t.help %S/../../docs/ClangFormat.rst
+// RUN: diff --strip-trailing-cr %t.help %S/../../docs/ClangFormat.rst
More information about the cfe-commits
mailing list