我正在尝试使用 clang-format 来清理我存储库中的代码。我们使用 WebKit 样式作为格式化的基础,但我们也想确保多行注释的格式正确。
根据我的理解,可以通过这样定义 .clang-format 文件来覆盖给定样式的格式设置规则:
BasedOnStyle: WebKit
AlignTrailingComments: true
这样 clang-format 应该对齐尾随的注释。
给定输入文件:
/**
* 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-format 文件中,并将 AlignTrailingComments 从 false 更改为 true。这也没有关系。
Webkit 样式中是否有某些选项干扰了 AlignTrailingComments 选项?
最佳答案
AlignTrailingComments
对齐连续行中尾随代码的注释:
int short; // short
int longlonglong; // long
关于c++ - clang-format 重写 WebKit 风格的多行注释,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35712729/