]> granicus.if.org Git - clang/commitdiff
[clang-format ]Extend IncludeCategories regex documentation
authorKrasimir Georgiev <krasimir@google.com>
Wed, 25 Jul 2018 10:21:47 +0000 (10:21 +0000)
committerKrasimir Georgiev <krasimir@google.com>
Wed, 25 Jul 2018 10:21:47 +0000 (10:21 +0000)
Summary:
Extend the Clang-Format IncludeCategories documentation by adding a link to the supported regular expression standard (POSIX).
And extenting the example with a system header regex.
[[ https://bugs.llvm.org/show_bug.cgi?id=35041 | bug 35041]]

Contributed by WimLeflere!

Reviewers: krasimir, Typz

Reviewed By: krasimir

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D48827

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@337899 91177308-0d34-0410-b5e6-96231b3b80d8

docs/ClangFormatStyleOptions.rst
docs/tools/dump_format_style.py
include/clang/Format/Format.h
include/clang/Tooling/Inclusions/IncludeStyle.h

index b6281ecae74128c426a32e0ee85fdfeb7dd8d664..e4892d79b91f2da616bc74ab3ba5e586f82a6fc8 100644 (file)
@@ -1280,6 +1280,10 @@ the configuration (without a prefix: ``Auto``).
   Regular expressions denoting the different ``#include`` categories
   used for ordering ``#includes``.
 
+  `POSIX extended
+  <http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html>`_
+  regular expressions are supported.
+
   These regular expressions are matched against the filename of an include
   (including the <> or "") in order. The value belonging to the first
   matching regular expression is assigned and ``#includes`` are sorted first
@@ -1302,6 +1306,8 @@ the configuration (without a prefix: ``Auto``).
         Priority:        2
       - Regex:           '^(<|"(gtest|gmock|isl|json)/)'
         Priority:        3
+      - Regex:           '<[[:alnum:].]+>'
+        Priority:        4
       - Regex:           '.*'
         Priority:        1
 
index 1ca050e062b7496134709b159c0f5e81a74e54af..3d61227f736172690b5a481548704ef5d6b0783f 100755 (executable)
@@ -10,6 +10,7 @@ import urllib2
 
 CLANG_DIR = os.path.join(os.path.dirname(__file__), '../..')
 FORMAT_STYLE_FILE = os.path.join(CLANG_DIR, 'include/clang/Format/Format.h')
+INCLUDE_STYLE_FILE = os.path.join(CLANG_DIR, 'include/clang/Tooling/Inclusions/IncludeStyle.h')
 DOC_FILE = os.path.join(CLANG_DIR, 'docs/ClangFormatStyleOptions.rst')
 
 
@@ -115,7 +116,7 @@ def read_options(header):
   for line in header:
     line = line.strip()
     if state == State.BeforeStruct:
-      if line == 'struct FormatStyle {':
+      if line == 'struct FormatStyle {' or line == 'struct IncludeStyle {':
         state = State.InStruct
     elif state == State.InStruct:
       if line.startswith('///'):
@@ -188,6 +189,7 @@ def read_options(header):
   return options
 
 options = read_options(open(FORMAT_STYLE_FILE))
+options += read_options(open(INCLUDE_STYLE_FILE))
 
 options = sorted(options, key=lambda x: x.name)
 options_text = '\n\n'.join(map(str, options))
index 36616e556a90fe0a0f263d86dcadd82e8b5628ee..85dda948c11f5b1701b378e69af241c4cdebf61d 100644 (file)
@@ -1296,7 +1296,7 @@ struct FormatStyle {
   /// If ``Never``, lays out Objective-C protocol conformance list items
   /// onto individual lines whenever they go over ``ColumnLimit``.
   ///
-  /// \code
+  /// \code{.objc}
   ///    Always (or Auto, if BinPackParameters=true):
   ///    @interface ccccccccccccc () <
   ///        ccccccccccccc, ccccccccccccc,
index 42d6e1a5cf160758f8712068faef82aeb442a11b..a093dff277288686c84ebd361f0207da5141134b 100644 (file)
@@ -67,6 +67,10 @@ struct IncludeStyle {
   /// Regular expressions denoting the different ``#include`` categories
   /// used for ordering ``#includes``.
   ///
+  /// `POSIX extended
+  /// <http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html>`_
+  /// regular expressions are supported.
+  ///
   /// These regular expressions are matched against the filename of an include
   /// (including the <> or "") in order. The value belonging to the first
   /// matching regular expression is assigned and ``#includes`` are sorted first
@@ -87,6 +91,8 @@ struct IncludeStyle {
   ///       Priority:        2
   ///     - Regex:           '^(<|"(gtest|gmock|isl|json)/)'
   ///       Priority:        3
+  ///     - Regex:           '<[[:alnum:].]+>'
+  ///       Priority:        4
   ///     - Regex:           '.*'
   ///       Priority:        1
   /// \endcode