[clang-format][docs] mark new clang-format configuration options based on which version they would GA
Sometimes I see people unsure about which options they can use in specific versions of clang-format because https://clang.llvm.org/docs/ClangFormatStyleOptions.html points to the latest and greatest versions. The reality is this says its version 13.0, but actually anything we add now, will not be in 13.0 GA but instead 14.0 GA (as 13.0 has already been branched). How about we introduce some nomenclature to the Format.h so that we can mark which options in the documentation were introduced for which version? Reviewed By: HazardyKnusperkeks Differential Revision: https://reviews.llvm.org/D110432
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -87,15 +87,20 @@ def indent(text, columns, indent_first_line=True):
|
||||
return indent + s
|
||||
|
||||
class Option(object):
|
||||
def __init__(self, name, type, comment):
|
||||
def __init__(self, name, type, comment, version):
|
||||
self.name = name
|
||||
self.type = type
|
||||
self.comment = comment.strip()
|
||||
self.enum = None
|
||||
self.nested_struct = None
|
||||
self.version = version
|
||||
|
||||
def __str__(self):
|
||||
s = '**%s** (``%s``)\n%s' % (self.name, to_yaml_type(self.type),
|
||||
if self.version:
|
||||
s = '**%s** (``%s``) :versionbadge:`clang-format %s`\n%s' % (self.name, to_yaml_type(self.type), self.version,
|
||||
doxygen2rst(indent(self.comment, 2)))
|
||||
else:
|
||||
s = '**%s** (``%s``)\n%s' % (self.name, to_yaml_type(self.type),
|
||||
doxygen2rst(indent(self.comment, 2)))
|
||||
if self.enum and self.enum.values:
|
||||
s += indent('\n\nPossible values:\n\n%s\n' % self.enum, 2)
|
||||
@@ -194,6 +199,7 @@ def read_options(header):
|
||||
comment = ''
|
||||
enum = None
|
||||
nested_struct = None
|
||||
version = None
|
||||
|
||||
for line in header:
|
||||
line = line.strip()
|
||||
@@ -208,7 +214,11 @@ def read_options(header):
|
||||
state = State.Finished
|
||||
break
|
||||
elif state == State.InFieldComment:
|
||||
if line.startswith('///'):
|
||||
if line.startswith(r'/// \version'):
|
||||
match = re.match(r'/// \\version\s*(?P<version>[0-9.]+)*',line)
|
||||
if match:
|
||||
version = match.group('version')
|
||||
elif line.startswith('///'):
|
||||
comment += clean_comment_line(line)
|
||||
elif line.startswith('enum'):
|
||||
state = State.InEnum
|
||||
@@ -222,10 +232,14 @@ def read_options(header):
|
||||
state = State.InStruct
|
||||
field_type, field_name = re.match(r'([<>:\w(,\s)]+)\s+(\w+);',
|
||||
line).groups()
|
||||
option = Option(str(field_name), str(field_type), comment)
|
||||
|
||||
if not version:
|
||||
print('Warning missing version for ', field_name)
|
||||
option = Option(str(field_name), str(field_type), comment, version)
|
||||
options.append(option)
|
||||
version=None
|
||||
else:
|
||||
raise Exception('Invalid format, expected comment, field or enum')
|
||||
raise Exception('Invalid format, expected comment, field or enum\n'+line)
|
||||
elif state == State.InNestedStruct:
|
||||
if line.startswith('///'):
|
||||
state = State.InNestedFieldComment
|
||||
|
||||
@@ -63,6 +63,7 @@ struct FormatStyle {
|
||||
bool InheritsParentConfig;
|
||||
|
||||
/// The extra indent or outdent of access modifiers, e.g. ``public:``.
|
||||
/// \version 3.3
|
||||
int AccessModifierOffset;
|
||||
|
||||
/// Different styles for aligning after open brackets.
|
||||
@@ -92,6 +93,7 @@ struct FormatStyle {
|
||||
///
|
||||
/// This applies to round brackets (parentheses), angle brackets and square
|
||||
/// brackets.
|
||||
/// \version 3.8
|
||||
BracketAlignmentStyle AlignAfterOpenBracket;
|
||||
|
||||
/// Different style for aligning array initializers.
|
||||
@@ -121,6 +123,7 @@ struct FormatStyle {
|
||||
};
|
||||
/// if not ``None``, when using initialization for an array of structs
|
||||
/// aligns the fields into columns.
|
||||
/// \version 13
|
||||
ArrayInitializerAlignmentStyle AlignArrayOfStructures;
|
||||
|
||||
/// Styles for alignment of consecutive tokens. Tokens can be assignment signs
|
||||
@@ -205,6 +208,7 @@ struct FormatStyle {
|
||||
/// /* some comment */
|
||||
/// #define bar(y, z) (y + z)
|
||||
/// \endcode
|
||||
/// \version 13
|
||||
AlignConsecutiveStyle AlignConsecutiveMacros;
|
||||
|
||||
/// Style of aligning consecutive assignments.
|
||||
@@ -273,6 +277,7 @@ struct FormatStyle {
|
||||
/// /* A comment. */
|
||||
/// double e = 4;
|
||||
/// \endcode
|
||||
/// \version 13
|
||||
AlignConsecutiveStyle AlignConsecutiveAssignments;
|
||||
|
||||
/// Style of aligning consecutive bit field.
|
||||
@@ -342,6 +347,7 @@ struct FormatStyle {
|
||||
/// /* A comment. */
|
||||
/// int ee : 3;
|
||||
/// \endcode
|
||||
/// \version 13
|
||||
AlignConsecutiveStyle AlignConsecutiveBitFields;
|
||||
|
||||
/// Style of aligning consecutive declarations.
|
||||
@@ -411,6 +417,7 @@ struct FormatStyle {
|
||||
/// /* A comment. */
|
||||
/// bool c = false;
|
||||
/// \endcode
|
||||
/// \version 13
|
||||
AlignConsecutiveStyle AlignConsecutiveDeclarations;
|
||||
|
||||
/// Different styles for aligning escaped newlines.
|
||||
@@ -445,6 +452,7 @@ struct FormatStyle {
|
||||
};
|
||||
|
||||
/// Options for aligning backslashes in escaped newlines.
|
||||
/// \version 5
|
||||
EscapedNewlineAlignmentStyle AlignEscapedNewlines;
|
||||
|
||||
/// Different styles for aligning operands.
|
||||
@@ -483,6 +491,7 @@ struct FormatStyle {
|
||||
|
||||
/// If ``true``, horizontally align operands of binary and ternary
|
||||
/// expressions.
|
||||
/// \version 12
|
||||
OperandAlignmentStyle AlignOperands;
|
||||
|
||||
/// If ``true``, aligns trailing comments.
|
||||
@@ -491,6 +500,7 @@ struct FormatStyle {
|
||||
/// int a; // My comment a vs. int a; // My comment a
|
||||
/// int b = 2; // comment b int b = 2; // comment about b
|
||||
/// \endcode
|
||||
/// \version 3.7
|
||||
bool AlignTrailingComments;
|
||||
|
||||
/// \brief If a function call or braced initializer list doesn't fit on a
|
||||
@@ -507,10 +517,12 @@ struct FormatStyle {
|
||||
/// c,
|
||||
/// d);
|
||||
/// \endcode
|
||||
/// \version 9
|
||||
bool AllowAllArgumentsOnNextLine;
|
||||
|
||||
/// This option is **deprecated**. See ``NextLine`` of
|
||||
/// ``PackConstructorInitializers``.
|
||||
/// \version 9
|
||||
bool AllowAllConstructorInitializersOnNextLine;
|
||||
|
||||
/// If the function declaration doesn't fit on a line,
|
||||
@@ -528,6 +540,7 @@ struct FormatStyle {
|
||||
/// int d,
|
||||
/// int e);
|
||||
/// \endcode
|
||||
/// \version 3.3
|
||||
bool AllowAllParametersOfDeclarationOnNextLine;
|
||||
|
||||
/// Allow short enums on a single line.
|
||||
@@ -541,6 +554,7 @@ struct FormatStyle {
|
||||
/// B
|
||||
/// } myEnum;
|
||||
/// \endcode
|
||||
/// \version 12
|
||||
bool AllowShortEnumsOnASingleLine;
|
||||
|
||||
/// Different styles for merging short blocks containing at most one
|
||||
@@ -573,6 +587,7 @@ struct FormatStyle {
|
||||
|
||||
/// Dependent on the value, ``while (true) { continue; }`` can be put on a
|
||||
/// single line.
|
||||
/// \version 11
|
||||
ShortBlockStyle AllowShortBlocksOnASingleLine;
|
||||
|
||||
/// If ``true``, short case labels will be contracted to a single line.
|
||||
@@ -586,6 +601,7 @@ struct FormatStyle {
|
||||
/// return;
|
||||
/// }
|
||||
/// \endcode
|
||||
/// \version 3.6
|
||||
bool AllowShortCaseLabelsOnASingleLine;
|
||||
|
||||
/// Different styles for merging short functions containing at most one
|
||||
@@ -638,6 +654,7 @@ struct FormatStyle {
|
||||
|
||||
/// Dependent on the value, ``int f() { return 0; }`` can be put on a
|
||||
/// single line.
|
||||
/// \version 3.5
|
||||
ShortFunctionStyle AllowShortFunctionsOnASingleLine;
|
||||
|
||||
/// Different styles for handling short if statements.
|
||||
@@ -708,6 +725,7 @@ struct FormatStyle {
|
||||
};
|
||||
|
||||
/// Dependent on the value, ``if (a) return;`` can be put on a single line.
|
||||
/// \version 9
|
||||
ShortIfStyle AllowShortIfStatementsOnASingleLine;
|
||||
|
||||
/// Different styles for merging short lambdas containing at most one
|
||||
@@ -741,10 +759,12 @@ struct FormatStyle {
|
||||
|
||||
/// Dependent on the value, ``auto lambda []() { return 0; }`` can be put on a
|
||||
/// single line.
|
||||
/// \version 9
|
||||
ShortLambdaStyle AllowShortLambdasOnASingleLine;
|
||||
|
||||
/// If ``true``, ``while (true) continue;`` can be put on a single
|
||||
/// line.
|
||||
/// \version 3.7
|
||||
bool AllowShortLoopsOnASingleLine;
|
||||
|
||||
/// Different ways to break after the function definition return type.
|
||||
@@ -832,9 +852,11 @@ struct FormatStyle {
|
||||
|
||||
/// The function definition return type breaking style to use. This
|
||||
/// option is **deprecated** and is retained for backwards compatibility.
|
||||
/// \version 3.7
|
||||
DefinitionReturnTypeBreakingStyle AlwaysBreakAfterDefinitionReturnType;
|
||||
|
||||
/// The function declaration return type breaking style to use.
|
||||
/// \version 3.8
|
||||
ReturnTypeBreakingStyle AlwaysBreakAfterReturnType;
|
||||
|
||||
/// If ``true``, always break before multiline string literals.
|
||||
@@ -849,6 +871,7 @@ struct FormatStyle {
|
||||
/// "bbbb" "cccc";
|
||||
/// "cccc";
|
||||
/// \endcode
|
||||
/// \version 3.4
|
||||
bool AlwaysBreakBeforeMultilineStrings;
|
||||
|
||||
/// Different ways to break after the template declaration.
|
||||
@@ -888,6 +911,7 @@ struct FormatStyle {
|
||||
};
|
||||
|
||||
/// The template declaration breaking style to use.
|
||||
/// \version 7
|
||||
BreakTemplateDeclarationsStyle AlwaysBreakTemplateDeclarations;
|
||||
|
||||
/// A vector of strings that should be interpreted as attributes/qualifiers
|
||||
@@ -906,6 +930,7 @@ struct FormatStyle {
|
||||
/// AttributeMacros: ['__capability', '__output', '__ununsed']
|
||||
/// \endcode
|
||||
///
|
||||
/// \version 13
|
||||
std::vector<std::string> AttributeMacros;
|
||||
|
||||
/// If ``false``, a function call's arguments will either be all on the
|
||||
@@ -924,6 +949,7 @@ struct FormatStyle {
|
||||
/// aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);
|
||||
/// }
|
||||
/// \endcode
|
||||
/// \version 3.7
|
||||
bool BinPackArguments;
|
||||
|
||||
/// The style of inserting trailing commas into container literals.
|
||||
@@ -953,6 +979,7 @@ struct FormatStyle {
|
||||
/// // ^ inserted
|
||||
/// ]
|
||||
/// \endcode
|
||||
/// \version 12
|
||||
TrailingCommaStyle InsertTrailingCommas;
|
||||
|
||||
/// If ``false``, a function declaration's or function definition's
|
||||
@@ -967,6 +994,7 @@ struct FormatStyle {
|
||||
/// int aaaaaaaaaaaaaaaaaaaa,
|
||||
/// int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) {}
|
||||
/// \endcode
|
||||
/// \version 3.7
|
||||
bool BinPackParameters;
|
||||
|
||||
/// The style of wrapping parameters on the same line (bin-packed) or
|
||||
@@ -1021,6 +1049,7 @@ struct FormatStyle {
|
||||
};
|
||||
|
||||
/// The way to wrap binary operators.
|
||||
/// \version 3.6
|
||||
BinaryOperatorStyle BreakBeforeBinaryOperators;
|
||||
|
||||
/// Different ways to attach braces to their surrounding context.
|
||||
@@ -1455,6 +1484,7 @@ struct FormatStyle {
|
||||
};
|
||||
|
||||
/// The brace breaking style to use.
|
||||
/// \version 3.7
|
||||
BraceBreakingStyle BreakBeforeBraces;
|
||||
|
||||
/// Different ways to wrap braces after control statements.
|
||||
@@ -1729,6 +1759,7 @@ struct FormatStyle {
|
||||
/// AfterStruct: false
|
||||
/// SplitEmptyFunction: false
|
||||
/// \endcode
|
||||
/// \version 3.8
|
||||
BraceWrappingFlags BraceWrapping;
|
||||
|
||||
/// If ``true``, concept will be placed on a new line.
|
||||
@@ -1740,6 +1771,7 @@ struct FormatStyle {
|
||||
/// false:
|
||||
/// template<typename T> concept ...
|
||||
/// \endcode
|
||||
/// \version 13
|
||||
bool BreakBeforeConceptDeclarations;
|
||||
|
||||
/// If ``true``, ternary operators will be placed after line breaks.
|
||||
@@ -1754,6 +1786,7 @@ struct FormatStyle {
|
||||
/// firstValue :
|
||||
/// SecondValueVeryVeryVeryVeryLong;
|
||||
/// \endcode
|
||||
/// \version 3.7
|
||||
bool BreakBeforeTernaryOperators;
|
||||
|
||||
/// Different ways to break initializers.
|
||||
@@ -1783,6 +1816,7 @@ struct FormatStyle {
|
||||
};
|
||||
|
||||
/// The break constructor initializers style to use.
|
||||
/// \version 5
|
||||
BreakConstructorInitializersStyle BreakConstructorInitializers;
|
||||
|
||||
/// Break after each annotation on a field in Java files.
|
||||
@@ -1792,6 +1826,7 @@ struct FormatStyle {
|
||||
/// @Mock
|
||||
/// DataLoad loader;
|
||||
/// \endcode
|
||||
/// \version 3.8
|
||||
bool BreakAfterJavaFieldAnnotations;
|
||||
|
||||
/// Allow breaking string literals when formatting.
|
||||
@@ -1805,6 +1840,7 @@ struct FormatStyle {
|
||||
/// const char* x =
|
||||
/// "veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongString";
|
||||
/// \endcode
|
||||
/// \version 3.9
|
||||
bool BreakStringLiterals;
|
||||
|
||||
/// The column limit.
|
||||
@@ -1812,6 +1848,7 @@ struct FormatStyle {
|
||||
/// A column limit of ``0`` means that there is no column limit. In this case,
|
||||
/// clang-format will respect the input's line breaking decisions within
|
||||
/// statements unless they contradict other rules.
|
||||
/// \version 3.7
|
||||
unsigned ColumnLimit;
|
||||
|
||||
/// A regular expression that describes comments with special meaning,
|
||||
@@ -1821,6 +1858,7 @@ struct FormatStyle {
|
||||
/// // Will leave the following line unaffected
|
||||
/// #include <vector> // FOOBAR pragma: keep
|
||||
/// \endcode
|
||||
/// \version 3.7
|
||||
std::string CommentPragmas;
|
||||
|
||||
/// Different const/volatile qualifier alignment styles.
|
||||
@@ -1862,6 +1900,7 @@ struct FormatStyle {
|
||||
/// \warning
|
||||
/// ``QualifierAlignment`` COULD lead to incorrect code generation.
|
||||
/// \endwarning
|
||||
/// \version 14
|
||||
QualifierAlignmentStyle QualifierAlignment;
|
||||
|
||||
/// The Order in which the qualifiers appear.
|
||||
@@ -1882,6 +1921,7 @@ struct FormatStyle {
|
||||
/// \code{.yaml}
|
||||
/// QualifierOrder: ['inline', 'static', 'type', 'const', 'volatile' ]
|
||||
/// \endcode
|
||||
/// \version 14
|
||||
std::vector<std::string> QualifierOrder;
|
||||
|
||||
/// Different ways to break inheritance list.
|
||||
@@ -1921,6 +1961,7 @@ struct FormatStyle {
|
||||
};
|
||||
|
||||
/// The inheritance list style to use.
|
||||
/// \version 7
|
||||
BreakInheritanceListStyle BreakInheritanceList;
|
||||
|
||||
/// If ``true``, consecutive namespace declarations will be on the same
|
||||
@@ -1944,14 +1985,17 @@ struct FormatStyle {
|
||||
/// namespace Extra {
|
||||
/// }}}
|
||||
/// \endcode
|
||||
/// \version 5
|
||||
bool CompactNamespaces;
|
||||
|
||||
/// This option is **deprecated**. See ``CurrentLine`` of
|
||||
/// ``PackConstructorInitializers``.
|
||||
/// \version 3.7
|
||||
bool ConstructorInitializerAllOnOneLineOrOnePerLine;
|
||||
|
||||
/// The number of characters to use for indentation of constructor
|
||||
/// initializer lists as well as inheritance lists.
|
||||
/// \version 3.7
|
||||
unsigned ConstructorInitializerIndentWidth;
|
||||
|
||||
/// Indent width for line continuations.
|
||||
@@ -1962,6 +2006,7 @@ struct FormatStyle {
|
||||
/// longFunction( // Again a long comment
|
||||
/// arg);
|
||||
/// \endcode
|
||||
/// \version 3.7
|
||||
unsigned ContinuationIndentWidth;
|
||||
|
||||
/// If ``true``, format braced lists as best suited for C++11 braced
|
||||
@@ -1984,10 +2029,12 @@ struct FormatStyle {
|
||||
/// f(MyMap[{composite, key}]); f(MyMap[{ composite, key }]);
|
||||
/// new int[3]{1, 2, 3}; new int[3]{ 1, 2, 3 };
|
||||
/// \endcode
|
||||
/// \version 3.4
|
||||
bool Cpp11BracedListStyle;
|
||||
|
||||
/// \brief Analyze the formatted file for the most used line ending (``\r\n``
|
||||
/// or ``\n``). ``UseCRLF`` is only used as a fallback if none can be derived.
|
||||
/// \version 11
|
||||
bool DeriveLineEnding;
|
||||
|
||||
/// If ``true``, analyze the formatted file for the most common
|
||||
@@ -1995,9 +2042,11 @@ struct FormatStyle {
|
||||
/// Pointer and reference alignment styles are going to be updated according
|
||||
/// to the preferences found in the file.
|
||||
/// ``PointerAlignment`` is then used only as fallback.
|
||||
/// \version 3.7
|
||||
bool DerivePointerAlignment;
|
||||
|
||||
/// Disables formatting completely.
|
||||
/// \version 3.7
|
||||
bool DisableFormat;
|
||||
|
||||
/// Different styles for empty line after access modifiers.
|
||||
@@ -2048,6 +2097,7 @@ struct FormatStyle {
|
||||
/// Defines when to put an empty line after access modifiers.
|
||||
/// ``EmptyLineBeforeAccessModifier`` configuration handles the number of
|
||||
/// empty lines between two access modifiers.
|
||||
/// \version 14
|
||||
EmptyLineAfterAccessModifierStyle EmptyLineAfterAccessModifier;
|
||||
|
||||
/// Different styles for empty line before access modifiers.
|
||||
@@ -2110,6 +2160,7 @@ struct FormatStyle {
|
||||
};
|
||||
|
||||
/// Defines in which cases to put empty line before access modifiers.
|
||||
/// \version 13
|
||||
EmptyLineBeforeAccessModifierStyle EmptyLineBeforeAccessModifier;
|
||||
|
||||
/// If ``true``, clang-format detects whether function calls and
|
||||
@@ -2122,6 +2173,7 @@ struct FormatStyle {
|
||||
///
|
||||
/// NOTE: This is an experimental flag, that might go away or be renamed. Do
|
||||
/// not use this in config files, etc. Use at your own risk.
|
||||
/// \version 3.7
|
||||
bool ExperimentalAutoDetectBinPacking;
|
||||
|
||||
/// Different ways to try to fit all constructor initializers on a line.
|
||||
@@ -2168,6 +2220,7 @@ struct FormatStyle {
|
||||
};
|
||||
|
||||
/// The pack constructor initializers style to use.
|
||||
/// \version 14;
|
||||
PackConstructorInitializersStyle PackConstructorInitializers;
|
||||
|
||||
/// If ``true``, clang-format adds missing namespace end comments for
|
||||
@@ -2180,6 +2233,7 @@ struct FormatStyle {
|
||||
/// bar(); bar();
|
||||
/// } // namespace a }
|
||||
/// \endcode
|
||||
/// \version 5
|
||||
bool FixNamespaceComments;
|
||||
|
||||
/// A vector of macros that should be interpreted as foreach loops
|
||||
@@ -2197,6 +2251,7 @@ struct FormatStyle {
|
||||
/// \endcode
|
||||
///
|
||||
/// For example: BOOST_FOREACH.
|
||||
/// \version 3.7
|
||||
std::vector<std::string> ForEachMacros;
|
||||
|
||||
/// A vector of macros that should be interpreted as conditionals
|
||||
@@ -2217,6 +2272,7 @@ struct FormatStyle {
|
||||
///
|
||||
/// For example: `KJ_IF_MAYBE
|
||||
/// <https://github.com/capnproto/capnproto/blob/master/kjdoc/tour.md#maybes>`_
|
||||
/// \version 14
|
||||
std::vector<std::string> IfMacros;
|
||||
|
||||
/// \brief A vector of macros that should be interpreted as type declarations
|
||||
@@ -2233,6 +2289,7 @@ struct FormatStyle {
|
||||
/// \endcode
|
||||
///
|
||||
/// For example: OpenSSL STACK_OF, BSD LIST_ENTRY.
|
||||
/// \version 9
|
||||
std::vector<std::string> TypenameMacros;
|
||||
|
||||
/// A vector of macros that should be interpreted as complete
|
||||
@@ -2243,6 +2300,7 @@ struct FormatStyle {
|
||||
/// clang-format aware of such cases.
|
||||
///
|
||||
/// For example: Q_UNUSED
|
||||
/// \version 8
|
||||
std::vector<std::string> StatementMacros;
|
||||
|
||||
/// A vector of macros which are used to open namespace blocks.
|
||||
@@ -2255,6 +2313,7 @@ struct FormatStyle {
|
||||
/// \endcode
|
||||
///
|
||||
/// For example: TESTSUITE
|
||||
/// \version 9
|
||||
std::vector<std::string> NamespaceMacros;
|
||||
|
||||
/// A vector of macros which are whitespace-sensitive and should not
|
||||
@@ -2271,6 +2330,7 @@ struct FormatStyle {
|
||||
/// \endcode
|
||||
///
|
||||
/// For example: BOOST_PP_STRINGIZE
|
||||
/// \version 12
|
||||
std::vector<std::string> WhitespaceSensitiveMacros;
|
||||
|
||||
tooling::IncludeStyle IncludeStyle;
|
||||
@@ -2299,6 +2359,7 @@ struct FormatStyle {
|
||||
/// return 1; return 1;
|
||||
/// } }
|
||||
/// \endcode
|
||||
/// \version 13
|
||||
bool IndentAccessModifiers;
|
||||
|
||||
/// Indent case labels one level from the switch statement.
|
||||
@@ -2317,6 +2378,7 @@ struct FormatStyle {
|
||||
/// plop(); plop();
|
||||
/// } }
|
||||
/// \endcode
|
||||
/// \version 3.3
|
||||
bool IndentCaseLabels;
|
||||
|
||||
/// Indent case label blocks one level from the case label.
|
||||
@@ -2339,6 +2401,7 @@ struct FormatStyle {
|
||||
/// }
|
||||
/// }
|
||||
/// \endcode
|
||||
/// \version 11
|
||||
bool IndentCaseBlocks;
|
||||
|
||||
/// Indent goto labels.
|
||||
@@ -2355,6 +2418,7 @@ struct FormatStyle {
|
||||
/// return 1; return 1;
|
||||
/// } }
|
||||
/// \endcode
|
||||
/// \version 10
|
||||
bool IndentGotoLabels;
|
||||
|
||||
/// Options for indenting preprocessor directives.
|
||||
@@ -2389,6 +2453,7 @@ struct FormatStyle {
|
||||
};
|
||||
|
||||
/// The preprocessor directive indenting style to use.
|
||||
/// \version 6
|
||||
PPDirectiveIndentStyle IndentPPDirectives;
|
||||
|
||||
/// Indents extern blocks
|
||||
@@ -2428,6 +2493,7 @@ struct FormatStyle {
|
||||
};
|
||||
|
||||
/// IndentExternBlockStyle is the type of indenting of extern blocks.
|
||||
/// \version 12
|
||||
IndentExternBlockStyle IndentExternBlock;
|
||||
|
||||
/// Indent the requires clause in a template
|
||||
@@ -2446,6 +2512,7 @@ struct FormatStyle {
|
||||
/// //....
|
||||
/// }
|
||||
/// \endcode
|
||||
/// \version 13
|
||||
bool IndentRequires;
|
||||
|
||||
/// The number of columns to use for indentation.
|
||||
@@ -2459,6 +2526,7 @@ struct FormatStyle {
|
||||
/// }
|
||||
/// }
|
||||
/// \endcode
|
||||
/// \version 3.7
|
||||
unsigned IndentWidth;
|
||||
|
||||
/// Indent if a function definition or declaration is wrapped after the
|
||||
@@ -2472,6 +2540,7 @@ struct FormatStyle {
|
||||
/// LoooooooooooooooooooooooooooooooooooooooongReturnType
|
||||
/// LoooooooooooooooooooooooooooooooongFunctionDeclaration();
|
||||
/// \endcode
|
||||
/// \version 3.7
|
||||
bool IndentWrappedFunctionNames;
|
||||
|
||||
/// A vector of prefixes ordered by the desired groups for Java imports.
|
||||
@@ -2505,6 +2574,7 @@ struct FormatStyle {
|
||||
///
|
||||
/// import org.example.ClassD;
|
||||
/// \endcode
|
||||
/// \version 8
|
||||
std::vector<std::string> JavaImportGroups;
|
||||
|
||||
/// Quotation styles for JavaScript strings. Does not affect template
|
||||
@@ -2531,6 +2601,7 @@ struct FormatStyle {
|
||||
};
|
||||
|
||||
/// The JavaScriptQuoteStyle to use for JavaScript strings.
|
||||
/// \version 3.9
|
||||
JavaScriptQuoteStyle JavaScriptQuotes;
|
||||
|
||||
// clang-format off
|
||||
@@ -2546,6 +2617,7 @@ struct FormatStyle {
|
||||
/// false:
|
||||
/// import {VeryLongImportsAreAnnoying, VeryLongImportsAreAnnoying, VeryLongImportsAreAnnoying,} from "some/module.js"
|
||||
/// \endcode
|
||||
/// \version 3.9
|
||||
bool JavaScriptWrapImports;
|
||||
// clang-format on
|
||||
|
||||
@@ -2557,6 +2629,7 @@ struct FormatStyle {
|
||||
/// bar(); }
|
||||
/// }
|
||||
/// \endcode
|
||||
/// \version 3.7
|
||||
bool KeepEmptyLinesAtTheStartOfBlocks;
|
||||
|
||||
/// Supported languages.
|
||||
@@ -2593,6 +2666,7 @@ struct FormatStyle {
|
||||
bool isJson() const { return Language == LK_Json; }
|
||||
|
||||
/// Language, this format style is targeted at.
|
||||
/// \version 3.5
|
||||
LanguageKind Language;
|
||||
|
||||
/// Indentation logic for lambda bodies.
|
||||
@@ -2625,16 +2699,17 @@ struct FormatStyle {
|
||||
/// ``OuterScope``. The KJ style guide requires ``OuterScope``.
|
||||
/// `KJ style guide
|
||||
/// <https://github.com/capnproto/capnproto/blob/master/kjdoc/style-guide.md>`_
|
||||
/// \version 13
|
||||
LambdaBodyIndentationKind LambdaBodyIndentation;
|
||||
|
||||
/// A regular expression matching macros that start a block.
|
||||
/// \code
|
||||
/// # With:
|
||||
/// MacroBlockBegin: "^NS_MAP_BEGIN|\
|
||||
/// NS_TABLE_HEAD$"
|
||||
/// NS_TABLE_HEAD$"
|
||||
/// MacroBlockEnd: "^\
|
||||
/// NS_MAP_END|\
|
||||
/// NS_TABLE_.*_END$"
|
||||
/// NS_MAP_END|\
|
||||
/// NS_TABLE_.*_END$"
|
||||
///
|
||||
/// NS_MAP_BEGIN
|
||||
/// foo();
|
||||
@@ -2653,9 +2728,11 @@ struct FormatStyle {
|
||||
/// bar();
|
||||
/// NS_TABLE_FOO_END
|
||||
/// \endcode
|
||||
/// \version 3.7
|
||||
std::string MacroBlockBegin;
|
||||
|
||||
/// A regular expression matching macros that end a block.
|
||||
/// \version 3.7
|
||||
std::string MacroBlockEnd;
|
||||
|
||||
/// The maximum number of consecutive empty lines to keep.
|
||||
@@ -2669,6 +2746,7 @@ struct FormatStyle {
|
||||
/// return i;
|
||||
/// }
|
||||
/// \endcode
|
||||
/// \version 3.7
|
||||
unsigned MaxEmptyLinesToKeep;
|
||||
|
||||
/// Different ways to indent namespace contents.
|
||||
@@ -2706,6 +2784,7 @@ struct FormatStyle {
|
||||
};
|
||||
|
||||
/// The indentation used for namespaces.
|
||||
/// \version 3.7
|
||||
NamespaceIndentationKind NamespaceIndentation;
|
||||
|
||||
/// Controls bin-packing Objective-C protocol conformance list
|
||||
@@ -2738,6 +2817,7 @@ struct FormatStyle {
|
||||
/// ddddddddddddd> {
|
||||
/// }
|
||||
/// \endcode
|
||||
/// \version 7
|
||||
BinPackStyle ObjCBinPackProtocolList;
|
||||
|
||||
/// The number of characters to use for indentation of ObjC blocks.
|
||||
@@ -2748,10 +2828,12 @@ struct FormatStyle {
|
||||
/// [self onOperationDone];
|
||||
/// }];
|
||||
/// \endcode
|
||||
/// \version 3.7
|
||||
unsigned ObjCBlockIndentWidth;
|
||||
|
||||
/// Add a space after ``@property`` in Objective-C, i.e. use
|
||||
/// ``@property (readonly)`` instead of ``@property(readonly)``.
|
||||
/// \version 3.7
|
||||
bool ObjCSpaceAfterProperty;
|
||||
|
||||
/// Break parameters list into lines when there is nested block
|
||||
@@ -2775,39 +2857,50 @@ struct FormatStyle {
|
||||
/// }]
|
||||
/// }
|
||||
/// \endcode
|
||||
/// \version 12
|
||||
bool ObjCBreakBeforeNestedBlockParam;
|
||||
|
||||
/// Add a space in front of an Objective-C protocol list, i.e. use
|
||||
/// ``Foo <Protocol>`` instead of ``Foo<Protocol>``.
|
||||
/// \version 3.7
|
||||
bool ObjCSpaceBeforeProtocolList;
|
||||
|
||||
/// The penalty for breaking around an assignment operator.
|
||||
/// \version 5
|
||||
unsigned PenaltyBreakAssignment;
|
||||
|
||||
/// The penalty for breaking a function call after ``call(``.
|
||||
/// \version 3.7
|
||||
unsigned PenaltyBreakBeforeFirstCallParameter;
|
||||
|
||||
/// The penalty for each line break introduced inside a comment.
|
||||
/// \version 3.7
|
||||
unsigned PenaltyBreakComment;
|
||||
|
||||
/// The penalty for breaking before the first ``<<``.
|
||||
/// \version 3.7
|
||||
unsigned PenaltyBreakFirstLessLess;
|
||||
|
||||
/// The penalty for each line break introduced inside a string literal.
|
||||
/// \version 3.7
|
||||
unsigned PenaltyBreakString;
|
||||
|
||||
/// The penalty for breaking after template declaration.
|
||||
/// \version 7
|
||||
unsigned PenaltyBreakTemplateDeclaration;
|
||||
|
||||
/// The penalty for each character outside of the column limit.
|
||||
/// \version 3.7
|
||||
unsigned PenaltyExcessCharacter;
|
||||
|
||||
/// Penalty for putting the return type of a function onto its own
|
||||
/// line.
|
||||
/// \version 3.7
|
||||
unsigned PenaltyReturnTypeOnItsOwnLine;
|
||||
|
||||
/// Penalty for each character of whitespace indentation
|
||||
/// (counted relative to leading non-whitespace column).
|
||||
/// \version 13
|
||||
unsigned PenaltyIndentedWhitespace;
|
||||
|
||||
/// The ``&``, ``&&`` and ``*`` alignment style.
|
||||
@@ -2830,6 +2923,7 @@ struct FormatStyle {
|
||||
};
|
||||
|
||||
/// Pointer and reference alignment style.
|
||||
/// \version 3.7
|
||||
PointerAlignmentStyle PointerAlignment;
|
||||
|
||||
/// The number of columns to use for indentation of preprocessor statements.
|
||||
@@ -2844,6 +2938,7 @@ struct FormatStyle {
|
||||
/// # define BAR
|
||||
/// #endif
|
||||
/// \endcode
|
||||
/// \version 14
|
||||
int PPIndentWidth;
|
||||
|
||||
/// See documentation of ``RawStringFormats``.
|
||||
@@ -2903,6 +2998,7 @@ struct FormatStyle {
|
||||
/// BasedOnStyle: llvm
|
||||
/// CanonicalDelimiter: 'cc'
|
||||
/// \endcode
|
||||
/// \version 6
|
||||
std::vector<RawStringFormat> RawStringFormats;
|
||||
|
||||
/// \brief The ``&`` and ``&&`` alignment style.
|
||||
@@ -2928,6 +3024,7 @@ struct FormatStyle {
|
||||
|
||||
/// \brief Reference alignment style (overrides ``PointerAlignment`` for
|
||||
/// references).
|
||||
/// \version 14
|
||||
ReferenceAlignmentStyle ReferenceAlignment;
|
||||
|
||||
// clang-format off
|
||||
@@ -2943,6 +3040,7 @@ struct FormatStyle {
|
||||
/// /* second veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with plenty of
|
||||
/// * information */
|
||||
/// \endcode
|
||||
/// \version 4
|
||||
bool ReflowComments;
|
||||
// clang-format on
|
||||
|
||||
@@ -2965,6 +3063,7 @@ struct FormatStyle {
|
||||
/// int bar; int bar;
|
||||
/// } // namespace b } // namespace b
|
||||
/// \endcode
|
||||
/// \version 14
|
||||
unsigned ShortNamespaceLines;
|
||||
|
||||
/// Include sorting options.
|
||||
@@ -3004,6 +3103,7 @@ struct FormatStyle {
|
||||
/// insensitive fashion.
|
||||
/// If ``CaseSensitive``, includes are sorted in an alphabetical or case
|
||||
/// sensitive fashion.
|
||||
/// \version 4
|
||||
SortIncludesOptions SortIncludes;
|
||||
|
||||
/// Position for Java Static imports.
|
||||
@@ -3027,6 +3127,7 @@ struct FormatStyle {
|
||||
/// When sorting Java imports, by default static imports are placed before
|
||||
/// non-static imports. If ``JavaStaticImportAfterImport`` is ``After``,
|
||||
/// static imports are placed after non-static imports.
|
||||
/// \version 13
|
||||
SortJavaStaticImportOptions SortJavaStaticImport;
|
||||
|
||||
/// If ``true``, clang-format will sort using declarations.
|
||||
@@ -3043,6 +3144,7 @@ struct FormatStyle {
|
||||
/// using std::cout; vs. using std::cin;
|
||||
/// using std::cin; using std::cout;
|
||||
/// \endcode
|
||||
/// \version 5
|
||||
bool SortUsingDeclarations;
|
||||
|
||||
/// If ``true``, a space is inserted after C style casts.
|
||||
@@ -3050,6 +3152,7 @@ struct FormatStyle {
|
||||
/// true: false:
|
||||
/// (int) i; vs. (int)i;
|
||||
/// \endcode
|
||||
/// \version 3.5
|
||||
bool SpaceAfterCStyleCast;
|
||||
|
||||
/// If ``true``, a space is inserted after the logical not operator (``!``).
|
||||
@@ -3057,6 +3160,7 @@ struct FormatStyle {
|
||||
/// true: false:
|
||||
/// ! someExpression(); vs. !someExpression();
|
||||
/// \endcode
|
||||
/// \version 9
|
||||
bool SpaceAfterLogicalNot;
|
||||
|
||||
/// If \c true, a space will be inserted after the 'template' keyword.
|
||||
@@ -3064,6 +3168,7 @@ struct FormatStyle {
|
||||
/// true: false:
|
||||
/// template <int> void foo(); vs. template<int> void foo();
|
||||
/// \endcode
|
||||
/// \version 4
|
||||
bool SpaceAfterTemplateKeyword;
|
||||
|
||||
/// Different ways to put a space before opening parentheses.
|
||||
@@ -3096,6 +3201,7 @@ struct FormatStyle {
|
||||
};
|
||||
|
||||
/// Defines in which cases to put a space before or after pointer qualifiers
|
||||
/// \version 13
|
||||
SpaceAroundPointerQualifiersStyle SpaceAroundPointerQualifiers;
|
||||
|
||||
/// If ``false``, spaces will be removed before assignment operators.
|
||||
@@ -3104,6 +3210,7 @@ struct FormatStyle {
|
||||
/// int a = 5; vs. int a= 5;
|
||||
/// a += 42; a+= 42;
|
||||
/// \endcode
|
||||
/// \version 3.7
|
||||
bool SpaceBeforeAssignmentOperators;
|
||||
|
||||
/// If ``false``, spaces will be removed before case colon.
|
||||
@@ -3113,6 +3220,7 @@ struct FormatStyle {
|
||||
/// case 1 : break; case 1: break;
|
||||
/// } }
|
||||
/// \endcode
|
||||
/// \version 13
|
||||
bool SpaceBeforeCaseColon;
|
||||
|
||||
/// If ``true``, a space will be inserted before a C++11 braced list
|
||||
@@ -3124,6 +3232,7 @@ struct FormatStyle {
|
||||
/// vector<int> { 1, 2, 3 }; vector<int>{ 1, 2, 3 };
|
||||
/// new int[3] { 1, 2, 3 }; new int[3]{ 1, 2, 3 };
|
||||
/// \endcode
|
||||
/// \version 7
|
||||
bool SpaceBeforeCpp11BracedList;
|
||||
|
||||
/// If ``false``, spaces will be removed before constructor initializer
|
||||
@@ -3132,6 +3241,7 @@ struct FormatStyle {
|
||||
/// true: false:
|
||||
/// Foo::Foo() : a(a) {} Foo::Foo(): a(a) {}
|
||||
/// \endcode
|
||||
/// \version 7
|
||||
bool SpaceBeforeCtorInitializerColon;
|
||||
|
||||
/// If ``false``, spaces will be removed before inheritance colon.
|
||||
@@ -3139,6 +3249,7 @@ struct FormatStyle {
|
||||
/// true: false:
|
||||
/// class Foo : Bar {} vs. class Foo: Bar {}
|
||||
/// \endcode
|
||||
/// \version 7
|
||||
bool SpaceBeforeInheritanceColon;
|
||||
|
||||
/// Different ways to put a space before opening parentheses.
|
||||
@@ -3201,6 +3312,7 @@ struct FormatStyle {
|
||||
};
|
||||
|
||||
/// Defines in which cases to put a space before opening parentheses.
|
||||
/// \version 3.5
|
||||
SpaceBeforeParensOptions SpaceBeforeParens;
|
||||
|
||||
/// If ``false``, spaces will be removed before range-based for loop
|
||||
@@ -3209,6 +3321,7 @@ struct FormatStyle {
|
||||
/// true: false:
|
||||
/// for (auto v : values) {} vs. for(auto v: values) {}
|
||||
/// \endcode
|
||||
/// \version 7
|
||||
bool SpaceBeforeRangeBasedForLoopColon;
|
||||
|
||||
/// If ``true``, spaces will be inserted into ``{}``.
|
||||
@@ -3217,6 +3330,7 @@ struct FormatStyle {
|
||||
/// void f() { } vs. void f() {}
|
||||
/// while (true) { } while (true) {}
|
||||
/// \endcode
|
||||
/// \version 11
|
||||
bool SpaceInEmptyBlock;
|
||||
|
||||
/// If ``true``, spaces may be inserted into ``()``.
|
||||
@@ -3229,6 +3343,7 @@ struct FormatStyle {
|
||||
/// } }
|
||||
/// } }
|
||||
/// \endcode
|
||||
/// \version 3.7
|
||||
bool SpaceInEmptyParentheses;
|
||||
|
||||
/// The number of spaces before trailing line comments
|
||||
@@ -3245,6 +3360,7 @@ struct FormatStyle {
|
||||
/// } // foo
|
||||
/// }
|
||||
/// \endcode
|
||||
/// \version 3.7
|
||||
unsigned SpacesBeforeTrailingComments;
|
||||
|
||||
/// Styles for adding spacing after ``<`` and before ``>`
|
||||
@@ -3267,6 +3383,7 @@ struct FormatStyle {
|
||||
SIAS_Leave
|
||||
};
|
||||
/// The SpacesInAnglesStyle to use for template argument lists.
|
||||
/// \version 14
|
||||
SpacesInAnglesStyle SpacesInAngles;
|
||||
|
||||
/// If ``true``, spaces will be inserted around if/for/switch/while
|
||||
@@ -3276,6 +3393,7 @@ struct FormatStyle {
|
||||
/// if ( a ) { ... } vs. if (a) { ... }
|
||||
/// while ( i < 5 ) { ... } while (i < 5) { ... }
|
||||
/// \endcode
|
||||
/// \version 11
|
||||
bool SpacesInConditionalStatement;
|
||||
|
||||
/// If ``true``, spaces are inserted inside container literals (e.g.
|
||||
@@ -3285,6 +3403,7 @@ struct FormatStyle {
|
||||
/// var arr = [ 1, 2, 3 ]; vs. var arr = [1, 2, 3];
|
||||
/// f({a : 1, b : 2, c : 3}); f({a: 1, b: 2, c: 3});
|
||||
/// \endcode
|
||||
/// \version 3.7
|
||||
bool SpacesInContainerLiterals;
|
||||
|
||||
/// If ``true``, spaces may be inserted into C style casts.
|
||||
@@ -3292,6 +3411,7 @@ struct FormatStyle {
|
||||
/// true: false:
|
||||
/// x = ( int32 )y vs. x = (int32)y
|
||||
/// \endcode
|
||||
/// \version 3.7
|
||||
bool SpacesInCStyleCastParentheses;
|
||||
|
||||
/// Control of spaces within a single line comment
|
||||
@@ -3329,6 +3449,7 @@ struct FormatStyle {
|
||||
/// /// - Foo /// - Foo
|
||||
/// /// - Bar /// - Bar
|
||||
/// \endcode
|
||||
/// \version 14
|
||||
SpacesInLineComment SpacesInLineCommentPrefix;
|
||||
|
||||
/// If ``true``, spaces will be inserted after ``(`` and before ``)``.
|
||||
@@ -3336,6 +3457,7 @@ struct FormatStyle {
|
||||
/// true: false:
|
||||
/// t f( Deleted & ) & = delete; vs. t f(Deleted &) & = delete;
|
||||
/// \endcode
|
||||
/// \version 3.7
|
||||
bool SpacesInParentheses;
|
||||
|
||||
/// If ``true``, spaces will be inserted after ``[`` and before ``]``.
|
||||
@@ -3346,6 +3468,7 @@ struct FormatStyle {
|
||||
/// int a[ 5 ]; vs. int a[5];
|
||||
/// std::unique_ptr<int[]> foo() {} // Won't be affected
|
||||
/// \endcode
|
||||
/// \version 3.7
|
||||
bool SpacesInSquareBrackets;
|
||||
|
||||
/// If ``true``, spaces will be before ``[``.
|
||||
@@ -3355,6 +3478,7 @@ struct FormatStyle {
|
||||
/// int a [5]; vs. int a[5];
|
||||
/// int a [5][5]; vs. int a[5][5];
|
||||
/// \endcode
|
||||
/// \version 11
|
||||
bool SpaceBeforeSquareBrackets;
|
||||
|
||||
/// Styles for adding spacing around ``:`` in bitfield definitions.
|
||||
@@ -3383,6 +3507,7 @@ struct FormatStyle {
|
||||
BFCS_After
|
||||
};
|
||||
/// The BitFieldColonSpacingStyle to use for bitfields.
|
||||
/// \version 13
|
||||
BitFieldColonSpacingStyle BitFieldColonSpacing;
|
||||
|
||||
/// Supported language standards for parsing and formatting C++ constructs.
|
||||
@@ -3417,6 +3542,7 @@ struct FormatStyle {
|
||||
/// c++03: latest:
|
||||
/// vector<set<int> > x; vs. vector<set<int>> x;
|
||||
/// \endcode
|
||||
/// \version 3.7
|
||||
LanguageStandard Standard;
|
||||
|
||||
/// Macros which are ignored in front of a statement, as if they were an
|
||||
@@ -3433,9 +3559,11 @@ struct FormatStyle {
|
||||
/// unsigned char data = 'x';
|
||||
/// emit signal(data); // Now it's fine again.
|
||||
/// \endcode
|
||||
/// \version 13
|
||||
std::vector<std::string> StatementAttributeLikeMacros;
|
||||
|
||||
/// The number of columns used for tab stops.
|
||||
/// \version 3.7
|
||||
unsigned TabWidth;
|
||||
|
||||
/// Different ways to use tab in formatting.
|
||||
@@ -3457,9 +3585,11 @@ struct FormatStyle {
|
||||
|
||||
/// \brief Use ``\r\n`` instead of ``\n`` for line breaks.
|
||||
/// Also used as fallback if ``DeriveLineEnding`` is true.
|
||||
/// \version 11
|
||||
bool UseCRLF;
|
||||
|
||||
/// The way to use tab characters in the resulting file.
|
||||
/// \version 3.7
|
||||
UseTabStyle UseTab;
|
||||
|
||||
bool operator==(const FormatStyle &R) const {
|
||||
|
||||
@@ -50,6 +50,7 @@ struct IncludeStyle {
|
||||
|
||||
/// Dependent on the value, multiple ``#include`` blocks can be sorted
|
||||
/// as one and divided based on category.
|
||||
/// \version 7
|
||||
IncludeBlocksStyle IncludeBlocks;
|
||||
|
||||
/// See documentation of ``IncludeCategories``.
|
||||
@@ -113,6 +114,7 @@ struct IncludeStyle {
|
||||
/// Priority: 1
|
||||
/// SortPriority: 0
|
||||
/// \endcode
|
||||
/// \version 7
|
||||
std::vector<IncludeCategory> IncludeCategories;
|
||||
|
||||
/// Specify a regular expression of suffixes that are allowed in the
|
||||
@@ -126,6 +128,7 @@ struct IncludeStyle {
|
||||
///
|
||||
/// For example, if configured to "(_test)?$", then a header a.h would be seen
|
||||
/// as the "main" include in both a.cc and a_test.cc.
|
||||
/// \version 7
|
||||
std::string IncludeIsMainRegex;
|
||||
|
||||
/// Specify a regular expression for files being formatted
|
||||
@@ -146,6 +149,7 @@ struct IncludeStyle {
|
||||
/// also being respected in later phase). Without this option set,
|
||||
/// ``ClassImpl.hpp`` would not have the main include file put on top
|
||||
/// before any other include.
|
||||
/// \version 7
|
||||
std::string IncludeIsMainSourceRegex;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user