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