[clang] [clang-format] Fix broken dump_format_help.py and sync the RST file (PR #65429)

via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 5 18:13:21 PDT 2023


https://github.com/owenca created https://github.com/llvm/llvm-project/pull/65429:

None

>From 57a72b3867aa9fb99372cea73866cede4ab45a75 Mon Sep 17 00:00:00 2001
From: Owen Pan <owenpiano at gmail.com>
Date: Tue, 5 Sep 2023 18:04:46 -0700
Subject: [PATCH] [clang-format] Fix broken dump_format_help.py and sync the
 RST file

---
 clang/docs/ClangFormat.rst               |  3 +--
 clang/docs/tools/dump_format_help.py     | 10 +++++-----
 clang/tools/clang-format/ClangFormat.cpp |  3 ++-
 3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/clang/docs/ClangFormat.rst b/clang/docs/ClangFormat.rst
index 129d5f101a0c4d..f52f35550d03eb 100644
--- a/clang/docs/ClangFormat.rst
+++ b/clang/docs/ClangFormat.rst
@@ -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
diff --git a/clang/docs/tools/dump_format_help.py b/clang/docs/tools/dump_format_help.py
index 041bee78062808..1a9afde1b9db9c 100755
--- a/clang/docs/tools/dump_format_help.py
+++ b/clang/docs/tools/dump_format_help.py
@@ -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):
@@ -40,7 +40,7 @@ def get_help_text():
     out = (
         """.. code-block:: console
 
-$ clang-format -help
+$ clang-format --help
 """
         + out
     )
@@ -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()
diff --git a/clang/tools/clang-format/ClangFormat.cpp b/clang/tools/clang-format/ClangFormat.cpp
index dab8a7f2f8c579..cb6e7460a66ecb 100644
--- a/clang/tools/clang-format/ClangFormat.cpp
+++ b/clang/tools/clang-format/ClangFormat.cpp
@@ -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 {



More information about the cfe-commits mailing list