blob: 4402e78ce640bb0217fcd982831c40dc740e8e30 [file] [log] [blame]
Georg Brandl116aa622007-08-15 14:28:22 +00001
2:mod:`tabnanny` --- Detection of ambiguous indentation
3======================================================
4
5.. module:: tabnanny
6 :synopsis: Tool for detecting white space related problems in Python source files in a
7 directory tree.
8.. moduleauthor:: Tim Peters <tim_one@users.sourceforge.net>
9.. sectionauthor:: Peter Funk <pf@artcom-gmbh.de>
10
11
12.. % rudimentary documentation based on module comments, by Peter Funk
13.. % <pf@artcom-gmbh.de>
14
15For the time being this module is intended to be called as a script. However it
16is possible to import it into an IDE and use the function :func:`check`
17described below.
18
19.. warning::
20
21 The API provided by this module is likely to change in future releases; such
22 changes may not be backward compatible.
23
24
25.. function:: check(file_or_dir)
26
27 If *file_or_dir* is a directory and not a symbolic link, then recursively
28 descend the directory tree named by *file_or_dir*, checking all :file:`.py`
Georg Brandl6911e3c2007-09-04 07:15:32 +000029 files along the way. If *file_or_dir* is an ordinary Python source file, it
30 is checked for whitespace related problems. The diagnostic messages are
31 written to standard output using the :func:`print` function.
Georg Brandl116aa622007-08-15 14:28:22 +000032
33
34.. data:: verbose
35
36 Flag indicating whether to print verbose messages. This is incremented by the
37 ``-v`` option if called as a script.
38
39
40.. data:: filename_only
41
42 Flag indicating whether to print only the filenames of files containing
43 whitespace related problems. This is set to true by the ``-q`` option if called
44 as a script.
45
46
47.. exception:: NannyNag
48
49 Raised by :func:`tokeneater` if detecting an ambiguous indent. Captured and
50 handled in :func:`check`.
51
52
53.. function:: tokeneater(type, token, start, end, line)
54
55 This function is used by :func:`check` as a callback parameter to the function
56 :func:`tokenize.tokenize`.
57
58.. % XXX FIXME: Document \function{errprint},
59.. % \function{format_witnesses} \class{Whitespace}
60.. % check_equal, indents
61.. % \function{reset_globals}
62
63
64.. seealso::
65
66 Module :mod:`tokenize`
67 Lexical scanner for Python source code.
68