【发布时间】:2016-06-13 06:28:46
【问题描述】:
我正在尝试使用 clang-format 来清理我的存储库中的代码。我们使用 WebKit 样式作为格式化的基础,但是我们也想确保多行 cmets 的格式正确。
据我了解,可以通过这样定义 .clang-format 文件来覆盖给定样式的格式规则:
BasedOnStyle: WebKit
AlignTrailingComments: true
这种方式 clang-format 应该对齐尾随 cmets。
给定输入文件:
/**
* This is a multi-line comment
*/
void function() {
/**
* This is comment inside the function
*/
}
我的期望是以下输出
/**
* This is a multi-line comment
*/
void function()
{
/**
* This is comment inside the function
*/
}
但是我得到的是:
/**
* This is a multi-line comment
*/
void function()
{
/**
* This is comment inside the function
*/
}
我尝试将 Webkit 的格式化选项转储到 .clang 格式文件中,并将 AlignTrailingComments 从 false 更改为 true。这也没有什么不同。
Webkit 样式中是否存在干扰 AlignTrailingComments 选项的选项?
【问题讨论】:
-
来这里问同样的问题。我没有任何 BasedOnStyle 集,我认为 AlignTrailingComments 是不相关的(它适用于在一行代码之后以
//开头的 cmets,不是吗?)。看起来像一个错误:块的开头对齐,但其余部分没有。 -
我也有同样的问题。而且这里的 3 个答案似乎都没有回答这个问题。
标签: c++ clang-format