Minor edits to clang-format guide

This commit is contained in:
Kevin Sawicki 2016-10-07 14:03:03 -07:00
parent 0d930b65f1
commit f872799f5c
2 changed files with 23 additions and 23 deletions

View file

@ -88,7 +88,7 @@ an issue:
## Development ## Development
* [Coding Style](development/coding-style.md) * [Coding Style](development/coding-style.md)
* [Using clang-format on Electron C++ Code](development/clang-format.md) * [Using clang-format on C++ Code](development/clang-format.md)
* [Source Code Directory Structure](development/source-code-directory-structure.md) * [Source Code Directory Structure](development/source-code-directory-structure.md)
* [Technical Differences to NW.js (formerly node-webkit)](development/atom-shell-vs-node-webkit.md) * [Technical Differences to NW.js (formerly node-webkit)](development/atom-shell-vs-node-webkit.md)
* [Build System Overview](development/build-system-overview.md) * [Build System Overview](development/build-system-overview.md)

View file

@ -1,34 +1,34 @@
# Using clang-format on Electron C++ Code # Using clang-format on C++ Code
[`clang-format`](http://clang.llvm.org/docs/ClangFormat.html) is a tool to [`clang-format`](http://clang.llvm.org/docs/ClangFormat.html) is a tool to
automatically format C/C++/Objective-C code, so that developers don't need to automatically format C/C++/Objective-C code, so that developers don't need to
concern about style issues during code review. worry about style issues during code reviews.
It is highly recommended to format your changed C++ code before sending to It is highly recommended to format your changed C++ code before opening pull
code review, which will save your and reviews' time. requests, which will save you and the reviewers' time.
To automatically format a file according to Electron C++ code style, simply run
`clang-format path/to/electron/file.cc`. It should work on macOS/Linux/Windows.
The workflow to format your changed code:
1. Do your change in electron repository.
2. Run `git add your_changed_file.cc`.
3. Run `git-clang-format`, and you will probably see modifications in
your_changed_file.cc, these modifications are generated from `clang-format`.
4. Run `git add your_changed_file.cc`, and commit your change.
5. Now it is ready to send a pull request.
If you want to format the changed code on your latest git commit (HEAD), you can
run `git-clang-format HEAD~1`. See `git-clang-format -h` for more details.
You can install `clang-format` and `git-clang-format` via You can install `clang-format` and `git-clang-format` via
`npm install -g clang-format`. `npm install -g clang-format`.
## Editor integration To automatically format a file according to Electron C++ code style, simply run
`clang-format -i path/to/electron/file.cc`. It should work on macOS/Linux/Windows.
It is useful to integrate `clang-format` tool in your favorite editors. The workflow to format your changed code:
For further guidance on setting up editor integration, see specific pages:
1. Make codes changes in Electron repository.
2. Run `git add your_changed_file.cc`.
3. Run `git-clang-format`, and you will probably see modifications in
`your_changed_file.cc`, these modifications are generated from `clang-format`.
4. Run `git add your_changed_file.cc`, and commit your change.
5. Now the branch is ready to be opened as a pull request.
If you want to format the changed code on your latest git commit (HEAD), you can
run `git-clang-format HEAD~1`. See `git-clang-format -h` for more details.
## Editor Integration
You can also integrate `clang-format` directly into your favorite editors.
For further guidance on setting up editor integration, see these pages:
* [Atom](https://atom.io/packages/clang-format) * [Atom](https://atom.io/packages/clang-format)
* [Vim & Emacs](http://clang.llvm.org/docs/ClangFormat.html#vim-integration) * [Vim & Emacs](http://clang.llvm.org/docs/ClangFormat.html#vim-integration)