Skip to content

Commit 650a91f

Browse files
committed
write README
1 parent b2f6f62 commit 650a91f

File tree

1 file changed

+40
-1
lines changed

1 file changed

+40
-1
lines changed

README.md

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,41 @@
11
# clang-formatter
2-
clang-format代码格式化批量执行脚本
2+
clang-formatter是一个通过调用clang-format进行代码批量格式化的工具,使用时根据配置项生成clang-format命令并执行。<br>
3+
使用该工具前需要先安装clang-format并将其加入环境变量。<br>
4+
LLVM下载地址: https://releases.llvm.org/ <br><br>
5+
**注意:不同版本的clang-format对于同一style在某些地方也会生成不同风格!团队成员间请使用同样的clang-format版本,或者使用.clang-format文件限定代码风格!**
6+
7+
## 配置文件说明
8+
```
9+
{
10+
"style": "WebKit",
11+
"filter": [
12+
"*.c",
13+
"*.cc",
14+
"*.cpp",
15+
"*.h",
16+
"*.hh",
17+
"*.hpp"
18+
],
19+
"dirs": [
20+
"./"
21+
]
22+
}
23+
```
24+
`style` 用于指定format风格,可选值有 `LLVM, GNU, Google, Chromium, Microsoft, Mozilla, WebKit, file` ,当该参数设置为 `file` 时,将会读取当前目录下的 `.clang-format` 文件作为代码风格配置,该文件可使用clang-format生成。<br>
25+
`filter` 填入需要格式化的文件类型列表,符合条件的文件将会被clang-format格式化。<br>
26+
`dirs` 填入需要格式化的目录列表,程序运行时会遍历递归遍历子目录,索引出符合 `filter` 列表中的文件。
27+
28+
## 使用说明
29+
直接运行程序将会在当前目录下生成一个 `format.json` 文件
30+
31+
```
32+
$ ./clang-formatter
33+
param config is empty, create a example config...
34+
example config is created!
35+
```
36+
37+
根据上一节的内容编写好配置文件后,运行程序并使用 `-c` 参数引入配置文件,即可批量格式化代码。
38+
39+
```
40+
$ ./clang-formatter -c ./format.json
41+
```

0 commit comments

Comments
 (0)