diff --git a/clang/docs/ClangFormatStyleOptions.rst b/clang/docs/ClangFormatStyleOptions.rst --- a/clang/docs/ClangFormatStyleOptions.rst +++ b/clang/docs/ClangFormatStyleOptions.rst @@ -717,26 +717,6 @@ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa); } - -**InsertTrailingCommas** (``TrailingCommaStyle``) can be set to ``TCS_Wrapped`` - to insert trailing commas in container literals (arrays and objects) that wrap - across multiple lines. It is currently only available for JavaScript and - disabled by default (``TCS_None``). - - ``InsertTrailingCommas`` cannot be used together with ``BinPackArguments`` as - inserting the comma disables bin-packing. - - .. code-block:: c++ - - TSC_Wrapped: - const someArray = [ - aaaaaaaaaaaaaaaaaaaaaaaaaa, - aaaaaaaaaaaaaaaaaaaaaaaaaa, - aaaaaaaaaaaaaaaaaaaaaaaaaa, - // ^ inserted - ] - - **BinPackParameters** (``bool``) If ``false``, a function declaration's or function definition's parameters will either all be on the same line or will have one line each. @@ -1770,6 +1750,38 @@ LoooooooooooooooooooooooooooooooooooooooongReturnType LoooooooooooooooooooooooooooooooongFunctionDeclaration(); +**InsertTrailingCommas** (``TrailingCommaStyle``) + If set to ``TCS_Wrapped`` will insert trailing commas in container + literals (arrays and objects) that wrap across multiple lines. + It is currently only available for JavaScript + and disabled by default ``TCS_None``. + ``InsertTrailingCommas`` cannot be used together with ``BinPackArguments`` + as inserting the comma disables bin-packing. + + .. code-block:: c++ + + TSC_Wrapped: + const someArray = [ + aaaaaaaaaaaaaaaaaaaaaaaaaa, + aaaaaaaaaaaaaaaaaaaaaaaaaa, + aaaaaaaaaaaaaaaaaaaaaaaaaa, + // ^ inserted + ] + + Possible values: + + * ``TCS_None`` (in configuration: ``None``) + Do not insert trailing commas. + + * ``TCS_Wrapped`` (in configuration: ``Wrapped``) + Insert trailing commas in container literals that were wrapped over + multiple lines. Note that this is conceptually incompatible with + bin-packing, because the trailing comma is used as an indicator + that a container should be formatted one-per-line (i.e. not bin-packed). + So inserting a trailing comma counteracts bin-packing. + + + **JavaImportGroups** (``std::vector``) A vector of prefixes ordered by the desired groups for Java imports. @@ -2064,7 +2076,8 @@ false: - (void)_aMethod { - [self.test1 t:self w:self callback:^(typeof(self) self, NSNumber *u, NSNumber *v) { + [self.test1 t:self w:self callback:^(typeof(self) self, NSNumber + *u, NSNumber *v) { u = c; }] } @@ -2072,8 +2085,8 @@ - (void)_aMethod { [self.test1 t:self - w:self - callback:^(typeof(self) self, NSNumber *u, NSNumber *v) { + w:self + callback:^(typeof(self) self, NSNumber *u, NSNumber *v) { u = c; }] } @@ -2538,7 +2551,8 @@ appears within a line (e.g. consecutive assignments and declarations). * ``UT_AlignWithSpaces`` (in configuration: ``AlignWithSpaces``) - Use tabs for line continuation and indentation, and spaces for alignment. + Use tabs for line continuation and indentation, and spaces for + alignment. * ``UT_Always`` (in configuration: ``Always``) Use tabs whenever we need to fill whitespace that spans at least from diff --git a/clang/include/clang/Format/Format.h b/clang/include/clang/Format/Format.h --- a/clang/include/clang/Format/Format.h +++ b/clang/include/clang/Format/Format.h @@ -561,6 +561,21 @@ TCS_Wrapped, }; + /// If set to ``TCS_Wrapped`` will insert trailing commas in container + /// literals (arrays and objects) that wrap across multiple lines. + /// It is currently only available for JavaScript + /// and disabled by default ``TCS_None``. + /// ``InsertTrailingCommas`` cannot be used together with ``BinPackArguments`` + /// as inserting the comma disables bin-packing. + /// \code + /// TSC_Wrapped: + /// const someArray = [ + /// aaaaaaaaaaaaaaaaaaaaaaaaaa, + /// aaaaaaaaaaaaaaaaaaaaaaaaaa, + /// aaaaaaaaaaaaaaaaaaaaaaaaaa, + /// // ^ inserted + /// ] + /// \endcode TrailingCommaStyle InsertTrailingCommas; /// If ``false``, a function declaration's or function definition's @@ -2133,7 +2148,7 @@ /// appears within a line (e.g. consecutive assignments and declarations). UT_ForContinuationAndIndentation, /// Use tabs for line continuation and indentation, and spaces for - /// alignemnt. + /// alignment. UT_AlignWithSpaces, /// Use tabs whenever we need to fill whitespace that spans at least from /// one tab stop to the next one.