Skip to content

[clang-format][NFC] Fix broken dump_format_help.py and sync RST file #65429

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions clang/docs/ClangFormat.rst
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ to format C/C++/Java/JavaScript/JSON/Objective-C/Protobuf/C# code.
--ferror-limit=<uint> - Set the maximum number of clang-format errors to emit
before stopping (0 = no limit).
Used only with --dry-run or -n
--files=<filename> - A file containing a list of files to process, one
per line.
--files=<filename> - A file containing a list of files to process, one per line.
-i - Inplace edit <file>s, if specified.
--length=<uint> - Format a range of this length (in bytes).
Multiple ranges can be formatted by specifying
Expand Down
10 changes: 5 additions & 5 deletions clang/docs/tools/dump_format_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
import subprocess
import sys

CLANG_DIR = os.path.join(os.path.dirname(__file__), "../..")
DOC_FILE = os.path.join(CLANG_DIR, "docs/ClangFormat.rst")
PARENT_DIR = os.path.join(os.path.dirname(__file__), "..")
DOC_FILE = os.path.join(PARENT_DIR, "ClangFormat.rst")


def substitute(text, tag, contents):
replacement = "\n.. START_%s\n\n%s\n\n.. END_%s\n" % (tag, contents, tag)
pattern = r"\n\.\. START_%s\n.*\n\.\. END_%s\n" % (tag, tag)
return re.sub(pattern, "%s", text, flags=re.S) % replacement
return re.sub(pattern, replacement, text, flags=re.S)


def indent(text, columns, indent_first_line=True):
Expand All @@ -40,7 +40,7 @@ def get_help_text():
out = (
""".. code-block:: console
$ clang-format -help
$ clang-format --help
"""
+ out
)
Expand All @@ -55,7 +55,7 @@ def validate(text, columns):


help_text = get_help_text()
validate(help_text, 95)
validate(help_text, 100)

with open(DOC_FILE) as f:
contents = f.read()
Expand Down
3 changes: 2 additions & 1 deletion clang/tools/clang-format/ClangFormat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,8 @@ static cl::opt<bool>
"whether or not to print diagnostics in color"),
cl::init(false), cl::cat(ClangFormatCategory), cl::Hidden);

static cl::list<std::string> FileNames(cl::Positional, cl::desc("[<file> ...]"),
static cl::list<std::string> FileNames(cl::Positional,
cl::desc("[@<file>] [<file> ...]"),
cl::cat(ClangFormatCategory));

namespace clang {
Expand Down