【问题标题】:clang-format breaking long doxygen commentsclang-format 打破长长的 doxygen 评论
【发布时间】:2019-03-23 20:30:50
【问题描述】:

我在我的遗留代码库中得到了这个 doxygen cmets,我喜欢保留它们以保持一致性。

/***************//****************************************************************
 *
 * @file
 *
 * Serial inteface to Novatel OEM4 GPS API.
 *
 *******************************************************************************/

不幸的是,clang-format-7 正在格式化 cmets,使 doxygen cmets 无用。

/*****************************************************************************/ /**
                                                                                 *
                                                                                 * @file
                                                                                 *
                                                                                 * Serial inteface to Novatel OEM4 GPS API.
                                                                                                                                                                *
                                                                                 *******************************************************************************/

我尝试了 CommentPragmas : '^\.+' or '//**' in my .clang-format 没有成功。

我的 .clang 格式如下

---
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: 'true'
AlignConsecutiveDeclarations: 'true'
AlignEscapedNewlines: Right
AlignOperands: 'true'
AlignTrailingComments: 'true'
AllowAllParametersOfDeclarationOnNextLine: 'false'
AllowShortBlocksOnASingleLine: 'false'
AllowShortCaseLabelsOnASingleLine: 'false'
AllowShortFunctionsOnASingleLine: None
AllowShortIfStatementsOnASingleLine: 'false'
AlwaysBreakAfterDefinitionReturnType: None
BinPackArguments: 'false'
BinPackParameters: 'false'
BreakBeforeBinaryOperators: All
BreakBeforeBraces: Stroustrup
BreakBeforeTernaryOperators: 'true'
BreakConstructorInitializers: BeforeComma
BreakStringLiterals: 'true'
ColumnLimit: '132'
ConstructorInitializerAllOnOneLineOrOnePerLine: 'true'
Cpp11BracedListStyle: 'true'
DerivePointerAlignment: 'false'
IndentCaseLabels: 'false'
IndentPPDirectives: AfterHash
IndentWidth: '4'
IndentWrappedFunctionNames: 'false'
KeepEmptyLinesAtTheStartOfBlocks: 'false'
Language: Cpp
MaxEmptyLinesToKeep: '1'
PointerAlignment: Right
ReflowComments: 'true'
SortIncludes: 'false'
SortUsingDeclarations: 'false'
SpaceAfterCStyleCast: 'true'
SpacesBeforeTrailingComments: '2'
SpaceBeforeAssignmentOperators: 'true'
SpaceBeforeCpp11BracedList: 'false'
SpaceBeforeParens: ControlStatements
Standard: Cpp11
TabWidth: '4'
UseTab: Never
CommentPragmas: '^\\.+'

...

我希望我的 CommentPragmas 不会影响 doxygen 评论,但它对我不起作用。

感谢任何帮助。

【问题讨论】:

    标签: comments doxygen clang-format


    【解决方案1】:

    ReflowComments 更改为false 应该可以做到这一点(至少对于clang-format 8.0)。

    【讨论】:

    • 这将阻止任何地方的 cmets 回流。它会将第一行转换为 ...***//**。那不是我想要的。我尝试了 CommentPragmaS 选项,但无法弄清楚:(
    猜你喜欢
    • 1970-01-01
    • 2014-11-10
    • 1970-01-01
    • 2020-02-28
    • 2019-03-30
    • 2013-06-05
    • 2018-05-20
    • 2011-12-10
    • 1970-01-01
    相关资源
    最近更新 更多