Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Pinoxchio
apollo
提交
eecab463
A
apollo
项目概览
Pinoxchio
/
apollo
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
apollo
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
eecab463
编写于
9月 02, 2020
作者:
C
changsh726
提交者:
Liu Jiaming
9月 02, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Docs: update how_to_lint_and_format.md
上级
2c025ef3
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
48 addition
and
1 deletion
+48
-1
docs/howto/how_to_lint_and_format.md
docs/howto/how_to_lint_and_format.md
+38
-0
scripts/apollo_format.sh
scripts/apollo_format.sh
+10
-1
未找到文件。
docs/howto/how_to_lint_and_format.md
0 → 100644
浏览文件 @
eecab463
# How to Lint and Format
## Coding style
-
**C/C++ coding style**
: Apollo adopted the
[
Google C++ Style Guide
](
https://google.github.io/styleguide/cppguide.html
)
.
## Linters provided in apollo
Apollo uses the following lint tools to check the code style.
**Note:**
As for
now, ci will only check the style of C++ codes and it may do so in the future
for codes in other languages.
| tool | file type | usage (from Apollo root dir) |
| :--------: | :-----------------------------------: | :---------------------------------------------: |
| cpplint | .h .c .hpp .cpp .hh .cc .hxx .cxx .cu | ./apollo.sh lint cpp
<path
/
to
/
src
/
dir
/
or
/
files
>
|
| flake8 | .py | ./apollo.sh lint py
<path
/
to
/
src
/
dir
/
or
/
files
>
|
| shellcheck | .sh .bash .bashrc | ./apollo.sh lint sh
<path
/
to
/
src
/
dir
/
or
/
files
>
|
To make sure your code conforms to the style guide, you can use command
`bash apollo.sh lint all`
to check if your code has any style problems and then
fix them manually. Another option is to use formatters to fix style problems
automatically.
## Formatters provided in apollo
Apollo integrated a set of formatting tools that cover many types of files:
| tool | file type | usage (from Apollo root dir) | configuration file |
| :----------: | :-----------------------------------: | :----------------------------------------------: | :----------------: |
| clang-format | .h .c .hpp .cpp .hh .cc .hxx .cxx .cu | ./apollo.sh format -c
<path
/
to
/
src
/
dir
/
or
/
files
>
| .clang-format |
| autopep8 | .py | ./apollo.sh format -p
<path
/
to
/
src
/
dir
/
or
/
files
>
| tox.ini |
| buildifier | BUILD .BUILD .bzl .bazel | ./apollo.sh format -b
<path
/
to
/
src
/
dir
/
or
/
files
>
| NA |
| shfmt | .sh .bash .bashrc | ./apollo.sh format -s
<path
/
to
/
src
/
dir
/
or
/
files
>
| .editorconfig |
| prettier | .md .json .yaml | ./apollo.sh format -m
<path
/
to
/
src
/
dir
/
or
/
files
>
| .prettier.json |
For ease of use, you can format all the files with types listed above using
command
`./apollo.sh format -a <path/to/src/dir/or/files>`
scripts/apollo_format.sh
浏览文件 @
eecab463
...
...
@@ -33,7 +33,8 @@ function print_usage() {
${
BLUE
}
-b|--bazel
${
NO_COLOR
}
Format Bazel code
${
BLUE
}
-c|--cpp
${
NO_COLOR
}
Format cpp code
${
BLUE
}
-s|--shell
${
NO_COLOR
}
Format Shell code
${
BLUE
}
-a|--all
${
NO_COLOR
}
Format all (C++/Python/Bazel/Shell)
${
BLUE
}
-m|--markdown
${
NO_COLOR
}
Format Markdown file
${
BLUE
}
-a|--all
${
NO_COLOR
}
Format all
${
BLUE
}
-h|--help
${
NO_COLOR
}
Show this message"
}
...
...
@@ -53,11 +54,16 @@ function run_shfmt() {
bash
"
${
TOP_DIR
}
/scripts/shfmt.sh"
"
$@
"
}
function
run_prettier
()
{
bash
"
${
TOP_DIR
}
/scripts/mdfmt.sh"
"
$@
"
}
function
run_format_all
()
{
run_clang_format
"
$@
"
run_buildifier
"
$@
"
run_autopep8
"
$@
"
run_shfmt
"
$@
"
run_prettier
"
$@
"
}
function
main
()
{
...
...
@@ -81,6 +87,9 @@ function main() {
-s
|
--shell
)
run_shfmt
"
$@
"
;;
-m
|
--markdown
)
run_prettier
"
$@
"
;;
-a
|
--all
)
run_format_all
"
$@
"
;;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录