-
Notifications
You must be signed in to change notification settings - Fork 38.7k
Fix inconsistent namespace formatting guidelines #12982
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Suggested formatting for namespaces in the developer guide is currently
inconsistent. This commit updates the developer guide and clang-format
configuration to consistently put "namespace" and opening/closing braces
on the same line. Example:
```c++
namespace boost {
namespace signals2 {
class connection;
} // namespace signals2
} // namespace boost
```
Currently the "Source code organization" section has an example like the one
above, but the "Coding style" section example and description put a newline
between the opening "namespace foo" and brace (but oddly no newline between
closing namespace and brace).
Avoiding newlines before namespace opening braces makes nested declarations
less verbose and also avoids asymmetry with closing braces. It's also a
common style used in other codebases:
* https://google.github.io/styleguide/cppguide.html#Namespaces
* https://developer.mozilla.org/en-US/docs/Mozilla/Developer_guide/Coding_Style#Classes
* https://llvm.org/docs/CodingStandards.html#namespace-indentation
|
Concept ACK |
src/.clang-format
Outdated
| BraceWrapping: | ||
| AfterClass: true | ||
| AfterFunction: true | ||
| AfterStruct: true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
structs had their braces on the same line previously?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
structs had their braces on the same line previously?
Good catch, this was a mistake.
|
Fine with me, since this seems a common theme, but I feel like the other settings in the clang-format file should not be toggled. |
681dea1 to
cd0e1e9
Compare
Fixed now, this was a mistake. I misread the documentation which didn't mention there was difference between classes and structs. Updated 681dea1 -> cd0e1e9 (pr/namespace.1 -> pr/namespace.2) |
|
utACK cd0e1e9 |
|
utACK cd0e1e9 |
|
utACK cd0e1e9 |
|
utACK cd0e1e9. |
cd0e1e9 Fix inconsistent namespace formatting guidelines (Russell Yanofsky) Pull request description: Suggested formatting for namespaces in the developer guide is currently inconsistent. This commit updates the developer guide and clang-format configuration to consistently put "namespace" and opening/closing braces on the same line. Example: ```c++ namespace boost { namespace signals2 { class connection; } // namespace signals2 } // namespace boost ``` Currently the [Source code organization](https://github.com/bitcoin/bitcoin/blob/master/doc/developer-notes.md#source-code-organization) section has an example like the one above, but the [Coding style](https://github.com/bitcoin/bitcoin/blob/master/doc/developer-notes.md#coding-style) section example and description put a newline between the opening "namespace foo" and brace (but oddly no newline between closing namespace and brace). Avoiding newlines before namespace opening braces makes nested declarations less verbose and also avoids asymmetry with closing braces. It's also a common style used in our own and other codebases: * https://google.github.io/styleguide/cppguide.html#Namespaces * https://developer.mozilla.org/en-US/docs/Mozilla/Developer_guide/Coding_Style#Classes * https://llvm.org/docs/CodingStandards.html#namespace-indentation Tree-SHA512: 507259478e1a7f6f96db386dd04eb25aa04294f533503fdd82368cf809c3ceaa20204b2cb6ae65322eb27446e5934c1aa1ccb6240ead12aa06b314af76f68139
cd0e1e9 Fix inconsistent namespace formatting guidelines (Russell Yanofsky) Pull request description: Suggested formatting for namespaces in the developer guide is currently inconsistent. This commit updates the developer guide and clang-format configuration to consistently put "namespace" and opening/closing braces on the same line. Example: ```c++ namespace boost { namespace signals2 { class connection; } // namespace signals2 } // namespace boost ``` Currently the [Source code organization](https://github.com/bitcoin/bitcoin/blob/master/doc/developer-notes.md#source-code-organization) section has an example like the one above, but the [Coding style](https://github.com/bitcoin/bitcoin/blob/master/doc/developer-notes.md#coding-style) section example and description put a newline between the opening "namespace foo" and brace (but oddly no newline between closing namespace and brace). Avoiding newlines before namespace opening braces makes nested declarations less verbose and also avoids asymmetry with closing braces. It's also a common style used in our own and other codebases: * https://google.github.io/styleguide/cppguide.html#Namespaces * https://developer.mozilla.org/en-US/docs/Mozilla/Developer_guide/Coding_Style#Classes * https://llvm.org/docs/CodingStandards.html#namespace-indentation Tree-SHA512: 507259478e1a7f6f96db386dd04eb25aa04294f533503fdd82368cf809c3ceaa20204b2cb6ae65322eb27446e5934c1aa1ccb6240ead12aa06b314af76f68139
Suggested formatting for namespaces in the developer guide is currently inconsistent. This commit updates the developer guide and clang-format configuration to consistently put "namespace" and opening/closing braces on the same line. Example:
Currently the Source code organization section has an example like the one above, but the Coding style section example and description put a newline between the opening "namespace foo" and brace (but oddly no newline between closing namespace and brace).
Avoiding newlines before namespace opening braces makes nested declarations less verbose and also avoids asymmetry with closing braces. It's also a common style used in our own and other codebases: