OLD | NEW |
(Empty) | |
| 1 clang-format-eyeo |
| 2 ================= |
| 3 |
| 4 A file containing style configuration for [`clang-format`][clang-format-docs] |
| 5 that formats according to the |
| 6 [Adblock Plus coding style guide][abp-coding-style-cpp] for C++. |
| 7 |
| 8 Installation |
| 9 ------------ |
| 10 |
| 11 When `clang-format` receives its style configuration from a file, it searches |
| 12 for style configuration in the directory of each input file and then each parent |
| 13 directory. Copy the format file to the parent directory of the working |
| 14 directory. In this way it will `clang-format` will find the format file and |
| 15 the version control system will not. |
| 16 |
| 17 The configuration file must be named either "`.clang-format`" or |
| 18 "`_clang-format`". At the present time there's no command line option to specify |
| 19 the file name. |
| 20 |
| 21 Usage |
| 22 ----- |
| 23 |
| 24 clang-format -style=file [...] |
| 25 |
| 26 The option "-style=file" (note that this is the word "file", not a file name) |
| 27 says to perform a directory search for the configuration. For the rest of the |
| 28 command line, see the `clang-format` documentation link above. |
| 29 |
| 30 Notes |
| 31 ----- |
| 32 |
| 33 `clang-format` is a complete reformatter; it largely ignores whitespace within |
| 34 the input and reformats code according to its specified rules. Its treatment of |
| 35 whitespace within comments, however, is different, within which it preserves |
| 36 whitespace by default. If the automatically-formatted code is not acceptable, |
| 37 interventions are available. |
| 38 |
| 39 * Formatting can be turned on and off with explicit special comments. |
| 40 |
| 41 ``` |
| 42 // clang-format off |
| 43 // clang-format on |
| 44 /* clang-format off */ |
| 45 /* clang-format on */ |
| 46 ``` |
| 47 |
| 48 * Line-end comments contain an embedded newline that `clang-format` will retain. |
| 49 To prevent a manually-split line from unwrapping, add a `//`-comment at the end |
| 50 of the line; it can be empty. |
| 51 |
| 52 For more information, see the answer to this Stack Overflow question: |
| 53 [Clang-format line breaks][SO-1] |
| 54 |
| 55 Clang Version Support |
| 56 --------------------- |
| 57 The present version is for Clang 4. One option (`BreakConstructorInitializers`) |
| 58 we're using has changed in Clang 5. If you want to use Clang 5, edit the file as |
| 59 part of installation. Uncomment the new version and comment out the old one. |
| 60 |
| 61 |
| 62 [clang-format-docs]: http://clang.llvm.org/docs/ClangFormat.html |
| 63 [abp-coding-style-cpp]: https://adblockplus.org/coding-style#cpp |
| 64 [SO-1]: https://stackoverflow.com/questions/33656800/clang-format-line-breaks#an
swer-34362422 |
OLD | NEW |