5945
|
1 |
/**
|
|
2 |
* \ingroup utils
|
|
3 |
* \defgroup CheckStyle check-style.py
|
|
4 |
*
|
|
5 |
* The check-style.py script will test and reformat code according to the
|
|
6 |
* ns-3 coding style posted at http://www.nsnam.org/codingstyle.html
|
|
7 |
* It requires that you install 'uncrustify'
|
|
8 |
*
|
|
9 |
* It has multiple levels of conformance:
|
|
10 |
* - level=0: the default: merely checks indentation
|
|
11 |
* - level=1: checks also for missing spaces before parentheses
|
|
12 |
* - level=2: checks also for missing newlines and braces around single-line statements
|
|
13 |
* - level=3: checks also for missing trailing whitespaces
|
|
14 |
*
|
|
15 |
* Examples:
|
|
16 |
*
|
|
17 |
* check a single file (level 0 by default):
|
|
18 |
\verbatim
|
|
19 |
./check-style.py -f src/core/object.h
|
|
20 |
\endverbatim
|
|
21 |
*
|
|
22 |
* fix the style of a single file:
|
|
23 |
\verbatim
|
|
24 |
./check-style.py --level=2 --in-place -f src/core/object.h
|
|
25 |
\endverbatim
|
|
26 |
*
|
|
27 |
* look at the changes needed for a single file:
|
|
28 |
\verbatim
|
|
29 |
./check-style.py --diff --level=1 -f src/core/object.h | less
|
|
30 |
\endverbatim
|
|
31 |
*
|
|
32 |
* look at the status of all files modified in your mercurial repository:
|
|
33 |
\verbatim
|
|
34 |
./check-style.py --check-hg
|
|
35 |
\endverbatim
|
|
36 |
*
|
|
37 |
* look at the changes needed for all modified files in your mercurial
|
|
38 |
* repository:
|
|
39 |
\verbatim
|
|
40 |
./check-style.py --check-hg --diff |less
|
|
41 |
\endverbatim
|
|
42 |
*
|
|
43 |
* Enable this script to run as a 'commit' hook in your repository and
|
|
44 |
* disallow commits which contain files with invalid style:
|
|
45 |
*
|
|
46 |
\verbatim
|
|
47 |
cat hgrc (can be appended to .hg/hgrc or ~/.hg/hgrc or /etc/hg/hgrc
|
|
48 |
[hooks]
|
|
49 |
# uncomment below line to enable: works only with mercurial >= 1.3
|
|
50 |
#pretxncommit.indent = path-to-binary/check-indent.py --check-hg-hook
|
|
51 |
# uncomment below line to enable: works with all (?) versions
|
|
52 |
# of mercurial but requires that PYTHONPATH is defined to point to
|
|
53 |
# the directory which contains check-indent.py
|
|
54 |
#pretxncommit.indent = python:check-indent.run_as_hg_hook
|
|
55 |
\endverbatim
|
|
56 |
*
|
|
57 |
* Usage:
|
|
58 |
\verbatim
|
|
59 |
Usage: check-style.py [options]
|
|
60 |
|
|
61 |
Options:
|
|
62 |
-h, --help show this help message and exit
|
|
63 |
--debug Output some debugging information
|
|
64 |
-l LEVEL, --level=LEVEL
|
|
65 |
Level of style conformance: higher levels include all
|
|
66 |
lower levels. level=0: re-indent only. level=1: add
|
|
67 |
extra spaces. level=2: insert extra newlines and extra
|
|
68 |
braces around single-line statements. level=3: remove
|
|
69 |
all trailing spaces
|
|
70 |
--check-hg-hook Get the list of files to check from mercurial's list
|
|
71 |
of modified and added files and assume that the script
|
|
72 |
runs as a pretxncommit mercurial hook
|
|
73 |
--check-hg Get the list of files to check from mercurial's list
|
|
74 |
of modified and added files
|
|
75 |
-f FILE, --check-file=FILE
|
|
76 |
Check a single file
|
|
77 |
--diff Generate a diff on stdout of the indented files
|
|
78 |
-i, --in-place Indent the input files in-place
|
|
79 |
\endverbatim
|
|
80 |
*/
|