MyDeveloperDay created this revision. MyDeveloperDay added reviewers: HazardyKnusperkeks, curdeius, krasimir. MyDeveloperDay added projects: clang, clang-format. MyDeveloperDay requested review of this revision.
Sometimes I see people unsure about which versions they can use in 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 (perhaps really the trunk should get relabelled as soon as the branch is made) 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? If this seems appealing I'm happing to start going back over the older releases and marking the versions for each option. F19212632: image.png <https://reviews.llvm.org/F19212632> F19212564: image.png <https://reviews.llvm.org/F19212564> Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D110432 Files: clang/docs/ClangFormatStyleOptions.rst clang/docs/tools/dump_format_style.py clang/include/clang/Format/Format.h
Index: clang/include/clang/Format/Format.h =================================================================== --- clang/include/clang/Format/Format.h +++ clang/include/clang/Format/Format.h @@ -1862,7 +1862,7 @@ /// \warning /// ``QualifierAlignment`` COULD lead to incorrect code generation. /// \endwarning - QualifierAlignmentStyle QualifierAlignment; + QualifierAlignmentStyle QualifierAlignment /*version=14.0.0*/; /// The Order in which the qualifiers appear. /// Order is a an array can contain any of the following @@ -1882,7 +1882,7 @@ /// \code{.yaml} /// QualifierOrder: ['inline', 'static', 'type', 'const', 'volatile' ] /// \endcode - std::vector<std::string> QualifierOrder; + std::vector<std::string> QualifierOrder /*version=14.0.0*/; /// Different ways to break inheritance list. enum BreakInheritanceListStyle : unsigned char { Index: clang/docs/tools/dump_format_style.py =================================================================== --- clang/docs/tools/dump_format_style.py +++ clang/docs/tools/dump_format_style.py @@ -87,15 +87,20 @@ 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) @@ -173,6 +178,14 @@ if endcode_match: return '' + match = re.match(r'^/// \\version$', line) + if match: + return '\n.. badge:: \n\n' + + endversion_match = re.match(r'^/// +\\endversion$', line) + if endversion_match: + return '' + match = re.match(r'^/// \\warning$', line) if match: return '\n.. warning:: \n\n' @@ -220,9 +233,9 @@ nested_struct = NestedStruct(name, comment) elif line.endswith(';'): state = State.InStruct - field_type, field_name = re.match(r'([<>:\w(,\s)]+)\s+(\w+);', + field_type, field_name, trailcomment, version = re.match(r'([<>:\w(,\s)]+)\s+(\w+)\s*(\/\*version=([0-9.]*)\*\/)*;', line).groups() - option = Option(str(field_name), str(field_type), comment) + option = Option(str(field_name), str(field_type), comment, version) options.append(option) else: raise Exception('Invalid format, expected comment, field or enum') Index: clang/docs/ClangFormatStyleOptions.rst =================================================================== --- clang/docs/ClangFormatStyleOptions.rst +++ clang/docs/ClangFormatStyleOptions.rst @@ -1,3 +1,11 @@ +.. raw:: html + + <style type="text/css"> + .versionbadge { background-color: #1c913d; height: 20px; display: inline-block; width: 130px; text-align: center; border-radius: 5px; color: #FFFFFF; font-family="Verdana,Geneva,DejaVu Sans,sans-serif" } + </style> + +.. role:: versionbadge + ========================== Clang-Format Style Options ========================== @@ -3225,7 +3233,7 @@ -**QualifierAlignment** (``QualifierAlignmentStyle``) +**QualifierAlignment** (``QualifierAlignmentStyle``) :versionbadge:`clang-format 14.0.0` Different ways to arrange const/volatile qualifiers. .. warning:: @@ -3276,7 +3284,7 @@ -**QualifierOrder** (``List of Strings``) +**QualifierOrder** (``List of Strings``) :versionbadge:`clang-format 14.0.0` The Order in which the qualifiers appear. Order is a an array can contain any of the following
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits