[clang] 9a5946c - [clang-format] Add --directory option to dump_format_help.py

Owen Pan via cfe-commits cfe-commits at lists.llvm.org
Thu Dec 5 20:16:20 PST 2024


Author: Owen Pan
Date: 2024-12-05T20:16:09-08:00
New Revision: 9a5946cdba91ce9801643711186dbffddda9f111

URL: https://github.com/llvm/llvm-project/commit/9a5946cdba91ce9801643711186dbffddda9f111
DIFF: https://github.com/llvm/llvm-project/commit/9a5946cdba91ce9801643711186dbffddda9f111.diff

LOG: [clang-format] Add --directory option to dump_format_help.py

Added: 
    

Modified: 
    clang/docs/tools/dump_format_help.py

Removed: 
    


################################################################################
diff  --git a/clang/docs/tools/dump_format_help.py b/clang/docs/tools/dump_format_help.py
index 1a9afde1b9db9c..a9893b3f91457a 100755
--- a/clang/docs/tools/dump_format_help.py
+++ b/clang/docs/tools/dump_format_help.py
@@ -2,6 +2,7 @@
 # A tool to parse the output of `clang-format --help` and update the
 # documentation in ../ClangFormat.rst automatically.
 
+import argparse
 import os
 import re
 import subprocess
@@ -26,7 +27,7 @@ def indent(text, columns, indent_first_line=True):
 
 
 def get_help_output():
-    args = ["clang-format", "--help"]
+    args = [binary, "--help"]
     cmd = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
     out, _ = cmd.communicate()
     out = out.decode(sys.stdout.encoding)
@@ -54,6 +55,14 @@ def validate(text, columns):
             print("warning: line too long:\n", line, file=sys.stderr)
 
 
+p = argparse.ArgumentParser()
+p.add_argument("-d", "--directory", help="directory of clang-format")
+opts = p.parse_args()
+
+binary = "clang-format"
+if opts.directory:
+    binary = opts.directory + "/" + binary
+
 help_text = get_help_text()
 validate(help_text, 100)
 


        


More information about the cfe-commits mailing list