utils/utils.h
changeset 6553 fb5ad9c7755a
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/utils/utils.h	Wed Aug 11 11:37:37 2010 -0400
     1.3 @@ -0,0 +1,80 @@
     1.4 +/**
     1.5 + * \ingroup utils 
     1.6 + * \defgroup CheckStyle check-style.py
     1.7 + *
     1.8 + * The check-style.py script will test and reformat code according to the
     1.9 + * ns-3 coding style posted at http://www.nsnam.org/codingstyle.html
    1.10 + * It requires that you install 'uncrustify' 
    1.11 + *
    1.12 + * It has multiple levels of conformance:
    1.13 + *   - level=0: the default: merely checks indentation
    1.14 + *   - level=1: checks also for missing spaces before parentheses
    1.15 + *   - level=2: checks also for missing newlines and braces around single-line statements
    1.16 + *   - level=3: checks also for missing trailing whitespaces
    1.17 + *
    1.18 + * Examples:
    1.19 + * 
    1.20 + * check a single file (level 0 by default):
    1.21 +\verbatim
    1.22 +./check-style.py -f src/core/object.h
    1.23 +\endverbatim
    1.24 + *  
    1.25 + * fix the style of a single file:
    1.26 +\verbatim
    1.27 +./check-style.py --level=2 --in-place -f src/core/object.h
    1.28 +\endverbatim
    1.29 + * 
    1.30 + * look at the changes needed for a single file:
    1.31 +\verbatim
    1.32 +./check-style.py --diff --level=1 -f src/core/object.h | less
    1.33 +\endverbatim
    1.34 + *
    1.35 + * look at the status of all files modified in your mercurial repository:
    1.36 +\verbatim
    1.37 +./check-style.py --check-hg
    1.38 +\endverbatim
    1.39 + * 
    1.40 + * look at the changes needed for all modified files in your mercurial
    1.41 + * repository:
    1.42 +\verbatim
    1.43 +./check-style.py --check-hg --diff |less
    1.44 +\endverbatim
    1.45 + * 
    1.46 + * Enable this script to run as a 'commit' hook in your repository and
    1.47 + * disallow commits which contain files with invalid style:
    1.48 + * 
    1.49 +\verbatim
    1.50 +cat hgrc (can be appended to .hg/hgrc or ~/.hg/hgrc or /etc/hg/hgrc
    1.51 +[hooks]
    1.52 +# uncomment below line to enable: works only with mercurial >= 1.3
    1.53 +#pretxncommit.indent = path-to-binary/check-indent.py --check-hg-hook
    1.54 +# uncomment below line to enable: works with all (?) versions 
    1.55 +# of mercurial but requires that PYTHONPATH is defined to point to 
    1.56 +# the directory which contains check-indent.py
    1.57 +#pretxncommit.indent = python:check-indent.run_as_hg_hook
    1.58 +\endverbatim
    1.59 + *
    1.60 + * Usage:
    1.61 +\verbatim
    1.62 +Usage: check-style.py [options]
    1.63 +
    1.64 +Options:
    1.65 +  -h, --help            show this help message and exit
    1.66 +  --debug               Output some debugging information
    1.67 +  -l LEVEL, --level=LEVEL
    1.68 +                        Level of style conformance: higher levels include all
    1.69 +                        lower levels. level=0: re-indent only. level=1: add
    1.70 +                        extra spaces. level=2: insert extra newlines and extra
    1.71 +                        braces around single-line statements. level=3: remove
    1.72 +                        all trailing spaces
    1.73 +  --check-hg-hook       Get the list of files to check from mercurial's list
    1.74 +                        of modified and added files and assume that the script
    1.75 +                        runs as a pretxncommit mercurial hook
    1.76 +  --check-hg            Get the list of files to check from mercurial's list
    1.77 +                        of modified and added files
    1.78 +  -f FILE, --check-file=FILE
    1.79 +                        Check a single file
    1.80 +  --diff                Generate a diff on stdout of the indented files
    1.81 +  -i, --in-place        Indent the input files in-place
    1.82 +\endverbatim
    1.83 + */