Skip to content
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

Clang format based on WebKit style #390

Merged
merged 6 commits into from
Oct 6, 2018
Merged

Clang format based on WebKit style #390

merged 6 commits into from
Oct 6, 2018

Conversation

mewmew
Copy link
Contributor

@mewmew mewmew commented Oct 6, 2018

Add clang-format script.

Base default style on WebKit and set a few options
specific to Devilution.

  • AlignTrailingComments: true
  • AllowShortBlocksOnASingleLine: true
  • AllowShortFunctionsOnASingleLine: None
  • PointerAlignment: Right

For header files, we also want to add

  • AlignConsecutiveAssignments: true

This allows us to format enums.h to align key = val pairs; e.g.

enum {
   FOO    = 1,
   FOOBAR = 2,
}

Note: For starters, we only format the files that are already binary exact (or almost binary exact, in the case of player.cpp). This reduces churn and we can easily extend from here going forward.

The list of clang-format style settings is described in https://clang.llvm.org/docs/ClangFormatStyleOptions.html

Fixes #182.

@mewmew
Copy link
Contributor Author

mewmew commented Oct 6, 2018

Note: this PR should be merged after the PRs currently open. This is done.

Base default style on WebKit and set a few options
specific to Devilution.

* `AlignTrailingComments: true`
* `AllowShortBlocksOnASingleLine: true`
* `AllowShortFunctionsOnASingleLine: None`
* `PointerAlignment: Right`

For header files, we also want to add

* `AlignConsecutiveAssignments: true`
Source/tmsg.cpp Show resolved Hide resolved
format.sh Outdated Show resolved Hide resolved
Generated as follows:

	$ clang-format --version
	clang-format version 7.0.0 (tags/RELEASE_700/final)
	$ clang-format -style=webkit -dump-config > .clang-format
* AlignTrailingComments: true
* AllowShortBlocksOnASingleLine: true
* AllowShortFunctionsOnASingleLine: None
* PointerAlignment: Right

Note, currently, the format.sh script uses the config file
for .cpp files. The `AlignConsecutiveAssignments: true` setting
is specifically added for .h files.

I could not find a way to specify what config file to use
for clang-format. So, for now, the config file is used for
.cpp.
The Source/.clang-format config is used for *.cpp files.

The root .clang-format config is used for *.h files.
@AJenbo AJenbo merged commit 82527fb into diasurgical:nightly Oct 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants