Skip to content

Commit 6105a4b

Browse files
committed
[clang-format] Add --strip-trailing-cr to diff in docs_updated.test
Also clean up dump_format_style.py and dump_format_help.py.
1 parent 54ca1c4 commit 6105a4b

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

clang/docs/tools/dump_format_help.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,5 +72,7 @@ def validate(text, columns):
7272

7373
contents = substitute(contents, "FORMAT_HELP", help_text)
7474

75-
with open(opts.output if opts.output else DOC_FILE, "wb") as output:
76-
output.write(contents.encode())
75+
with open(
76+
opts.output if opts.output else DOC_FILE, "w", newline="", encoding="utf-8"
77+
) as f:
78+
f.write(contents)

clang/docs/tools/dump_format_style.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -411,8 +411,8 @@ class State:
411411
state = State.InStruct
412412
enums[enum.name] = enum
413413
else:
414-
# Enum member without documentation. Must be documented where the enum
415-
# is used.
414+
# Enum member without documentation. Must be documented
415+
# where the enum is used.
416416
pass
417417
elif state == State.InNestedEnum:
418418
if line.startswith("///"):
@@ -492,5 +492,7 @@ class State:
492492

493493
contents = substitute(contents, "FORMAT_STYLE_OPTIONS", options_text)
494494

495-
with open(args.output if args.output else DOC_FILE, "wb") as output:
496-
output.write(contents.encode())
495+
with open(
496+
args.output if args.output else DOC_FILE, "w", newline="", encoding="utf-8"
497+
) as f:
498+
f.write(contents)

clang/test/Format/docs_updated.test

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// RUN: %python %S/../../docs/tools/dump_format_style.py -o %t.style
2-
// RUN: diff %t.style %S/../../docs/ClangFormatStyleOptions.rst
2+
// RUN: diff --strip-trailing-cr %t.style \
3+
// RUN: %S/../../docs/ClangFormatStyleOptions.rst
34

45
// RUN: %python %S/../../docs/tools/dump_format_help.py -o %t.help
5-
// RUN: diff %t.help %S/../../docs/ClangFormat.rst
6+
// RUN: diff --strip-trailing-cr %t.help %S/../../docs/ClangFormat.rst

0 commit comments

Comments
 (0)