Skip to content

Commit c47c480

Browse files
authored
[clang-format][NFC] Fix broken dump_format_help.py and sync RST file (#65429)
Running `dump_format_help.py` in `clang/docs/tools`: ``` warning: line too long: relative to the current working directory when reading stdin. warning: line too long: --files=<filename> - A file containing a list of files to process, one per line. warning: line too long: --help-list - Display list of available options (--help-list-hidden for more) Traceback (most recent call last): File "/Users/Owen/remove-braces/clang/docs/tools/./dump_format_help.py", line 63, in <module> contents = substitute(contents, "FORMAT_HELP", help_text) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/Owen/remove-braces/clang/docs/tools/./dump_format_help.py", line 17, in substitute return re.sub(pattern, "%s", text, flags=re.S) % replacement ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~ TypeError: not enough arguments for format string ```
1 parent 195cdfd commit c47c480

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

clang/docs/ClangFormat.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,7 @@ to format C/C++/Java/JavaScript/JSON/Objective-C/Protobuf/C# code.
6969
--ferror-limit=<uint> - Set the maximum number of clang-format errors to emit
7070
before stopping (0 = no limit).
7171
Used only with --dry-run or -n
72-
--files=<filename> - A file containing a list of files to process, one
73-
per line.
72+
--files=<filename> - A file containing a list of files to process, one per line.
7473
-i - Inplace edit <file>s, if specified.
7574
--length=<uint> - Format a range of this length (in bytes).
7675
Multiple ranges can be formatted by specifying

clang/docs/tools/dump_format_help.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77
import subprocess
88
import sys
99

10-
CLANG_DIR = os.path.join(os.path.dirname(__file__), "../..")
11-
DOC_FILE = os.path.join(CLANG_DIR, "docs/ClangFormat.rst")
10+
PARENT_DIR = os.path.join(os.path.dirname(__file__), "..")
11+
DOC_FILE = os.path.join(PARENT_DIR, "ClangFormat.rst")
1212

1313

1414
def substitute(text, tag, contents):
1515
replacement = "\n.. START_%s\n\n%s\n\n.. END_%s\n" % (tag, contents, tag)
1616
pattern = r"\n\.\. START_%s\n.*\n\.\. END_%s\n" % (tag, tag)
17-
return re.sub(pattern, "%s", text, flags=re.S) % replacement
17+
return re.sub(pattern, replacement, text, flags=re.S)
1818

1919

2020
def indent(text, columns, indent_first_line=True):
@@ -40,7 +40,7 @@ def get_help_text():
4040
out = (
4141
""".. code-block:: console
4242
43-
$ clang-format -help
43+
$ clang-format --help
4444
"""
4545
+ out
4646
)
@@ -55,7 +55,7 @@ def validate(text, columns):
5555

5656

5757
help_text = get_help_text()
58-
validate(help_text, 95)
58+
validate(help_text, 100)
5959

6060
with open(DOC_FILE) as f:
6161
contents = f.read()

clang/tools/clang-format/ClangFormat.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,8 @@ static cl::opt<bool>
200200
"whether or not to print diagnostics in color"),
201201
cl::init(false), cl::cat(ClangFormatCategory), cl::Hidden);
202202

203-
static cl::list<std::string> FileNames(cl::Positional, cl::desc("[<file> ...]"),
203+
static cl::list<std::string> FileNames(cl::Positional,
204+
cl::desc("[@<file>] [<file> ...]"),
204205
cl::cat(ClangFormatCategory));
205206

206207
namespace clang {

0 commit comments

Comments
 (0)