mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 20:12:57 +01:00
[doc] Remove unused clang format dev script
Also, update the clang format file to reflect the current coding style mentioned in the developer notes.
This commit is contained in:
parent
a7ea2f8fdb
commit
fa5137c11d
@ -8,11 +8,6 @@ check-doc.py
|
|||||||
Check if all command line args are documented. The return value indicates the
|
Check if all command line args are documented. The return value indicates the
|
||||||
number of undocumented args.
|
number of undocumented args.
|
||||||
|
|
||||||
clang-format.py
|
|
||||||
===============
|
|
||||||
|
|
||||||
A script to format cpp source code according to [.clang-format](../../src/.clang-format). This should only be applied to new files or files which are currently not actively developed on. Also, git subtrees are not subject to formatting.
|
|
||||||
|
|
||||||
clang-format-diff.py
|
clang-format-diff.py
|
||||||
===================
|
===================
|
||||||
|
|
||||||
@ -24,6 +19,7 @@ the script should be called from the git root folder as follows.
|
|||||||
```
|
```
|
||||||
git diff -U0 HEAD~1.. | ./contrib/devtools/clang-format-diff.py -p1 -i -v
|
git diff -U0 HEAD~1.. | ./contrib/devtools/clang-format-diff.py -p1 -i -v
|
||||||
```
|
```
|
||||||
|
|
||||||
copyright\_header.py
|
copyright\_header.py
|
||||||
====================
|
====================
|
||||||
|
|
||||||
|
@ -1,62 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
'''
|
|
||||||
Wrapper script for clang-format
|
|
||||||
|
|
||||||
Copyright (c) 2015 MarcoFalke
|
|
||||||
Copyright (c) 2015 The Bitcoin Core developers
|
|
||||||
Distributed under the MIT software license, see the accompanying
|
|
||||||
file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
||||||
'''
|
|
||||||
|
|
||||||
import os
|
|
||||||
import sys
|
|
||||||
import subprocess
|
|
||||||
|
|
||||||
tested_versions = ['3.6.0', '3.6.1', '3.6.2'] # A set of versions known to produce the same output
|
|
||||||
accepted_file_extensions = ('.h', '.cpp') # Files to format
|
|
||||||
|
|
||||||
def check_clang_format_version(clang_format_exe):
|
|
||||||
try:
|
|
||||||
output = subprocess.check_output([clang_format_exe, '-version'])
|
|
||||||
for ver in tested_versions:
|
|
||||||
if ver in output:
|
|
||||||
print "Detected clang-format version " + ver
|
|
||||||
return
|
|
||||||
raise RuntimeError("Untested version: " + output)
|
|
||||||
except Exception as e:
|
|
||||||
print 'Could not verify version of ' + clang_format_exe + '.'
|
|
||||||
raise e
|
|
||||||
|
|
||||||
def check_command_line_args(argv):
|
|
||||||
required_args = ['{clang-format-exe}', '{files}']
|
|
||||||
example_args = ['clang-format-3.x', 'src/main.cpp', 'src/wallet/*']
|
|
||||||
|
|
||||||
if(len(argv) < len(required_args) + 1):
|
|
||||||
for word in (['Usage:', argv[0]] + required_args):
|
|
||||||
print word,
|
|
||||||
print ''
|
|
||||||
for word in (['E.g:', argv[0]] + example_args):
|
|
||||||
print word,
|
|
||||||
print ''
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
def run_clang_format(clang_format_exe, files):
|
|
||||||
for target in files:
|
|
||||||
if os.path.isdir(target):
|
|
||||||
for path, dirs, files in os.walk(target):
|
|
||||||
run_clang_format(clang_format_exe, (os.path.join(path, f) for f in files))
|
|
||||||
elif target.endswith(accepted_file_extensions):
|
|
||||||
print "Format " + target
|
|
||||||
subprocess.check_call([clang_format_exe, '-i', '-style=file', target], stdout=open(os.devnull, 'wb'), stderr=subprocess.STDOUT)
|
|
||||||
else:
|
|
||||||
print "Skip " + target
|
|
||||||
|
|
||||||
def main(argv):
|
|
||||||
check_command_line_args(argv)
|
|
||||||
clang_format_exe = argv[1]
|
|
||||||
files = argv[2:]
|
|
||||||
check_clang_format_version(clang_format_exe)
|
|
||||||
run_clang_format(clang_format_exe, files)
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
main(sys.argv)
|
|
@ -4,10 +4,11 @@ Developer Notes
|
|||||||
Various coding styles have been used during the history of the codebase,
|
Various coding styles have been used during the history of the codebase,
|
||||||
and the result is not very consistent. However, we're now trying to converge to
|
and the result is not very consistent. However, we're now trying to converge to
|
||||||
a single style, so please use it in new code. Old code will be converted
|
a single style, so please use it in new code. Old code will be converted
|
||||||
gradually.
|
gradually and you are encouraged to use the provided
|
||||||
|
[clang-format-diff script](/contrib/devtools/README.md#clang-format-diffpy)
|
||||||
|
to clean up the patch automatically before submitting a pull request.
|
||||||
|
|
||||||
- Basic rules specified in [src/.clang-format](/src/.clang-format).
|
- Basic rules specified in [src/.clang-format](/src/.clang-format).
|
||||||
Use a recent clang-format to format automatically using one of the [dev scripts]
|
|
||||||
(/contrib/devtools/README.md#clang-formatpy).
|
|
||||||
- Braces on new lines for namespaces, classes, functions, methods.
|
- Braces on new lines for namespaces, classes, functions, methods.
|
||||||
- Braces on the same line for everything else.
|
- Braces on the same line for everything else.
|
||||||
- 4 space indentation (no tabs) for every block except namespaces.
|
- 4 space indentation (no tabs) for every block except namespaces.
|
||||||
|
@ -6,7 +6,7 @@ AlignTrailingComments: true
|
|||||||
AllowAllParametersOfDeclarationOnNextLine: false
|
AllowAllParametersOfDeclarationOnNextLine: false
|
||||||
AllowShortBlocksOnASingleLine: false
|
AllowShortBlocksOnASingleLine: false
|
||||||
AllowShortFunctionsOnASingleLine: All
|
AllowShortFunctionsOnASingleLine: All
|
||||||
AllowShortIfStatementsOnASingleLine: false
|
AllowShortIfStatementsOnASingleLine: true
|
||||||
AllowShortLoopsOnASingleLine: false
|
AllowShortLoopsOnASingleLine: false
|
||||||
AlwaysBreakBeforeMultilineStrings: false
|
AlwaysBreakBeforeMultilineStrings: false
|
||||||
AlwaysBreakTemplateDeclarations: true
|
AlwaysBreakTemplateDeclarations: true
|
||||||
|
Loading…
Reference in New Issue
Block a user