7

リポジトリ内のコードをクリーンアップするために 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 に変更してみました。これも違いはありません。

AlignTrailingComments オプションに干渉する Webkit スタイルのオプションはありますか?

4

3 に答える 3

2

AlignTrailingCommentsコメントの末尾のコードを連続した行に揃えます。

int short;        // short
int longlonglong; // long
于 2016-11-22T23:51:45.293 に答える