/**
* @code
* char *a_very_very_very_long = "which makes it need to enter another line to
* fix"; if (foo > 1) { return;
* }
* @endcode
*/
int foo = 0;
i向LLVM项目提出了,他们说Clang-Format并非打算在文档中格式化代码。
我不认为这是C开发中的罕见情况,并且由于Doxygen和Clang-Format已被广泛使用了很长时间,所以我想知道最好的做法是什么? (即使代码可能无法正确格式为代码,也不应错误地格式打破其原始模式)
P.S。我知道我可以关闭Clang-Format来跳过整个评论,但是我确实希望Clang-Format在DOC评论中格式化其他正常部分。
最简单,最常见的解决方案是在敏感区域暂时禁用clang-format
:
/**
*
* @code
* // clang-format off
* char *a_very_very_very_long = "which makes it need to enter another line to fix";
* if (foo > 1) {
* return;
* }
* // clang-format on
* @endcode
*/
int foo = 0;
this明确指示
clang-format
避免仅重新格式化此代码段,同时仍适当地格式化您的其余评论。 您还可以使用Doxygen支持的Markdown Style代码围栏: