]> granicus.if.org Git - clang/commitdiff
clang-format: Add documentation about disabling formatting.
authorDaniel Jasper <djasper@google.com>
Tue, 7 Oct 2014 12:15:15 +0000 (12:15 +0000)
committerDaniel Jasper <djasper@google.com>
Tue, 7 Oct 2014 12:15:15 +0000 (12:15 +0000)
Patch by Marek Kurdej, thanks!

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

docs/ClangFormatStyleOptions.rst

index 5bd051663f1724e208d0d98fdd82cd99836a1356..95f85ba3dfd12d2278924e167385903d2891b1ae 100644 (file)
@@ -85,6 +85,24 @@ is applied for all input files. The format of the configuration is:
   -style='{key1: value1, key2: value2, ...}'
 
 
+Disabling Formatting on a Piece of Code
+=======================================
+
+Clang-format understands also special comments that switch formatting in a
+delimited range. The code between a comment ``// clang-format off`` or
+``/* clang-format off */`` up to a comment ``// clang-format on`` or
+``/* clang-format on */`` will not be formatted. The comments themselves
+will be formatted (aligned) normally.
+
+.. code-block:: c++
+
+  int formatted_code;
+  // clang-format off
+      void    unformatted_code  ;
+  // clang-format on
+  void formatted_code_again;
+
+
 Configuring Style in Code
 =========================