Skip to content

Commit c11ba76

Browse files
committed
Add doc for compileall.compile_file
1 parent a8132ec commit c11ba76

2 files changed

Lines changed: 25 additions & 11 deletions

File tree

Doc/library/compileall.rst

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
:mod:`compileall` --- Byte-compile Python libraries
32
===================================================
43

@@ -50,14 +49,14 @@ compile Python sources.
5049

5150
Expand list with its content (file and directory names).
5251

53-
.. versionadded:: 2.7
54-
The ``-i`` option.
52+
.. versionchanged:: 2.7
53+
Added the ``-i`` option.
5554

5655

5756
Public functions
5857
----------------
5958

60-
.. function:: compile_dir(dir[, maxlevels[, ddir[, force[, rx[, quiet]]]]])
59+
.. function:: compile_dir(dir[, maxlevels[, ddir[, force[, rx[, quiet]]]]])
6160

6261
Recursively descend the directory tree named by *dir*, compiling all :file:`.py`
6362
files along the way. The *maxlevels* parameter is used to limit the depth of
@@ -72,6 +71,23 @@ Public functions
7271
If *quiet* is true, nothing is printed to the standard output in normal
7372
operation.
7473

74+
75+
.. function:: compile_file(fullname[, ddir[, force[, rx[, quiet]]]])
76+
77+
Compile the file with path *fullname*. If *ddir* is given, it is used as the
78+
base path from which the filename used in error messages will be generated.
79+
If *force* is true, modules are re-compiled even if the timestamp is up to
80+
date.
81+
82+
If *rx* is given, it specifies a regular expression which, if matched, will
83+
prevent compilation; that expression is searched for in the full path.
84+
85+
If *quiet* is true, nothing is printed to the standard output in normal
86+
operation.
87+
88+
.. versionadded:: 2.7
89+
90+
7591
.. function:: compile_path([skip_curdir[, maxlevels[, force]]])
7692

7793
Byte-compile all the :file:`.py` files found along ``sys.path``. If

Lib/compileall.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
packages -- for now, you'll have to deal with packages separately.)
1010
1111
See module py_compile for details of the actual byte-compilation.
12-
1312
"""
1413
import os
1514
import sys
@@ -31,7 +30,6 @@ def compile_dir(dir, maxlevels=10, ddir=None,
3130
directory name that will show up in error messages)
3231
force: if 1, force compilation, even if timestamps are up-to-date
3332
quiet: if 1, be quiet during compilation
34-
3533
"""
3634
if not quiet:
3735
print 'Listing', dir, '...'
@@ -61,15 +59,16 @@ def compile_dir(dir, maxlevels=10, ddir=None,
6159
return success
6260

6361
def compile_file(fullname, ddir=None, force=0, rx=None, quiet=0):
64-
"""Byte-compile file.
65-
file: the file to byte-compile
62+
"""Byte-compile one file.
63+
64+
Arguments (only fullname is required):
65+
66+
fullname: the file to byte-compile
6667
ddir: if given, purported directory name (this is the
6768
directory name that will show up in error messages)
6869
force: if 1, force compilation, even if timestamps are up-to-date
6970
quiet: if 1, be quiet during compilation
70-
7171
"""
72-
7372
success = 1
7473
name = os.path.basename(fullname)
7574
if ddir is not None:
@@ -120,7 +119,6 @@ def compile_path(skip_curdir=1, maxlevels=0, force=0, quiet=0):
120119
maxlevels: max recursion level (default 0)
121120
force: as for compile_dir() (default 0)
122121
quiet: as for compile_dir() (default 0)
123-
124122
"""
125123
success = 1
126124
for dir in sys.path:

0 commit comments

Comments
 (0)