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