blob: 5c702e5a9565c468ec3acaee9aae62b1270f6698 [file] [log] [blame]
Guido van Rossum51bbdfb1995-03-01 14:07:08 +00001% Template for a library manual section.
2% PLEASE REMOVE THE COMMENTS AFTER USING THE TEMPLATE
Guido van Rossum6a11eb41992-06-03 17:59:07 +00003
4
Guido van Rossum51bbdfb1995-03-01 14:07:08 +00005% ==== 1. ====
6% Choose one of the following section headers and index entries;
7% \section{} generates the section header,
8% \bimodindex{} or \stmodundex{} generates an index entry for this module
9
10\section{Built-in module \sectcode{spam}} % If implemented in C
11\bimodindex[spam}
12
13\section{Standard module \sectcode{spam}} % If implemented in Python
14\stmodindex{spam}
Guido van Rossum6a11eb41992-06-03 17:59:07 +000015
16
Guido van Rossum51bbdfb1995-03-01 14:07:08 +000017% ==== 2. ====
18% Give a short overview of what the module does.
19% If it is platform specific, mention this.
20% Mention other important restrictions or general operating principles.
21% For example:
22
23The \code{spam} module defines operations for handling cans of Spam.
24It knows the four generally available Spam varieties and understands
25both can sizes.
26
27Because spamification requires UNIX process management, the module is
28only available on genuine UNIX systems.
Guido van Rossum6a11eb41992-06-03 17:59:07 +000029
30
Guido van Rossum51bbdfb1995-03-01 14:07:08 +000031% ==== 3. ====
32% List the public functions defined by the module. Begin with a
33% standard phrase. You may also list the exceptions and other data
34% items defined in the module, insofar as they are important for the
35% user.
36
37The \code{spam} module defines the following functions:
38
39% ---- 3.1. ----
40% Redefine the ``indexsubitem'' macro to point to this module:
41
42\renewcommand{\indexsubitem}{(in module spam)}
43
44% ---- 3.2. ----
45% For each function, use a ``funcdesc'' block. This has exactly two
46% parameters (each parameters is contained in a set of curly braces):
47% the first parameter is the function name (this automatically
48% generates an index entry); the second parameter is the function's
49% argument list. If there are no arguments, use an empty pair of
50% curly braces. If there is more than one argument, separate the
51% arguments with backslash-comma. Optional parts of the parameter
52% list are contained in \optional{...} (this generates a set of square
53% brackets around its parameter). Arguments are automatically set in
54% italics in the parameter list. Each argument should be mentioned at
55% least once in the description; each usage (even inside \code{...})
56% should be enclosed in \var{...}.
57
58\begin{funcdesc}{open}{filename\optional{\, mode\, buffersize}}
59Open the file \var{filename} as a can of Spam. The optional
60\var{mode} and \var{buffersize} arguments specify the read-write mode
61(\code{'r'} (default) or \code{'w'}) and the buffer size (default:
62system dependent).
63\end{funcdesc}
64
65% ---- 3.3. ----
66% Data items are described using a ``datadesc'' block. This has only
67% one parameter: the item's name.
68
69\begin{datadesc}{cansize}
70The default can size, in ounces. Legal values are 7 and 12. The
71default varies per supermarket. This variable should not be changed
72once the \code{open()} function has been called.
73\end{datadesc}
74
75% --- 3.4. ---
76% Exceptions are described using a ``excdesc'' block. This has only
77% one parameter: the exception name.
78
79\begin{excdesc}{error}
80Exception raised when an operation fails for a Spam specific reason.
81The exception argument is a string describing the reason of the
82failure.
83\end{excdesc}
84
85% ---- 3.5. ----
86% There is no standard block type for classes. I generally use
87% ``funcdesc'' blocks, since class instantiation looks very much like
88% a function call.
Guido van Rossum6a11eb41992-06-03 17:59:07 +000089
90
Guido van Rossum51bbdfb1995-03-01 14:07:08 +000091% ==== 4. ====
92% Now is probably a good time for a complete example. (Alternatively,
93% an example giving the flavor of the module may be given before the
94% detailed list of functions.)
Guido van Rossum6a11eb41992-06-03 17:59:07 +000095
Guido van Rossum51bbdfb1995-03-01 14:07:08 +000096Example:
Guido van Rossum6a11eb41992-06-03 17:59:07 +000097
Guido van Rossum51bbdfb1995-03-01 14:07:08 +000098\begin{verbatim}
99>>> import spam
100>>> can = spam.open('/etc/passwd')
101>>> can.empty()
102>>> can.close()
103\end{verbatim}
Guido van Rossum6a11eb41992-06-03 17:59:07 +0000104
Guido van Rossum51bbdfb1995-03-01 14:07:08 +0000105% ==== 5. ====
106% If your module defines new object types (for a built-in module) or
107% classes (for a module written in Python), you should list the
108% methods and instance variables (if any) of each type or class in a
109% separate subsection. It is important to redefine ``indexsubitem''
110% for each subsection.
111
112\subsection{Spam methods}
113
114Spam objects (returned by \code{open()} above) have the following
115methods.
116
117\renewcommand{\indexsubitem}{(spam method)}
118
119\begin{funcdesc}{empty}{}
120Empty the can into the trash.
121\end{funcdesc}