blob: 29aeb639fdc55ae0ee9b868b299745c7cbb14f6c [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,
Fred Draked9dbfbd1997-12-15 21:20:03 +00008% \bimodindex{} or \stmodindex{} generates an index entry for this
9% module. Note that these should only be used for the defining entry
10% for the module. Other references to the module should use
11% \refbimodindex{} or \refstmodindex{}.
Guido van Rossum1c78cf31997-07-18 21:07:34 +000012% The \label{module-spam} line is for the \seealso{} command.
Guido van Rossum51bbdfb1995-03-01 14:07:08 +000013
Guido van Rossum470be141995-03-17 16:07:09 +000014\section{Built-in Module \sectcode{spam}} % If implemented in C
Jack Jansenab71c3f1995-10-10 11:57:49 +000015\bimodindex{spam}
Guido van Rossum51bbdfb1995-03-01 14:07:08 +000016
Fred Drakedccd9db1997-12-17 13:44:37 +000017\section{Standard Module \sectcode{spam}} % If implemented in Python
Guido van Rossum51bbdfb1995-03-01 14:07:08 +000018\stmodindex{spam}
Guido van Rossum6a11eb41992-06-03 17:59:07 +000019
Guido van Rossum1c78cf31997-07-18 21:07:34 +000020\label{module-spam}
Guido van Rossum6a11eb41992-06-03 17:59:07 +000021
Guido van Rossum51bbdfb1995-03-01 14:07:08 +000022% ==== 2. ====
23% Give a short overview of what the module does.
24% If it is platform specific, mention this.
25% Mention other important restrictions or general operating principles.
26% For example:
27
28The \code{spam} module defines operations for handling cans of Spam.
29It knows the four generally available Spam varieties and understands
30both can sizes.
31
Fred Drake4b3f0311996-12-13 22:04:31 +000032Because spamification requires \UNIX{} process management, the module
33is only available on genuine \UNIX{} systems.
Guido van Rossum6a11eb41992-06-03 17:59:07 +000034
35
Guido van Rossum51bbdfb1995-03-01 14:07:08 +000036% ==== 3. ====
37% List the public functions defined by the module. Begin with a
38% standard phrase. You may also list the exceptions and other data
39% items defined in the module, insofar as they are important for the
40% user.
41
42The \code{spam} module defines the following functions:
43
44% ---- 3.1. ----
Guido van Rossumdc46c7f1995-03-01 15:38:16 +000045% Redefine the ``indexsubitem'' macro to point to this module
46% (alternatively, you can put this at the top of the file):
Guido van Rossum51bbdfb1995-03-01 14:07:08 +000047
48\renewcommand{\indexsubitem}{(in module spam)}
49
50% ---- 3.2. ----
51% For each function, use a ``funcdesc'' block. This has exactly two
52% parameters (each parameters is contained in a set of curly braces):
53% the first parameter is the function name (this automatically
54% generates an index entry); the second parameter is the function's
55% argument list. If there are no arguments, use an empty pair of
56% curly braces. If there is more than one argument, separate the
57% arguments with backslash-comma. Optional parts of the parameter
58% list are contained in \optional{...} (this generates a set of square
59% brackets around its parameter). Arguments are automatically set in
60% italics in the parameter list. Each argument should be mentioned at
61% least once in the description; each usage (even inside \code{...})
62% should be enclosed in \var{...}.
63
64\begin{funcdesc}{open}{filename\optional{\, mode\, buffersize}}
65Open the file \var{filename} as a can of Spam. The optional
66\var{mode} and \var{buffersize} arguments specify the read-write mode
67(\code{'r'} (default) or \code{'w'}) and the buffer size (default:
68system dependent).
69\end{funcdesc}
70
71% ---- 3.3. ----
72% Data items are described using a ``datadesc'' block. This has only
73% one parameter: the item's name.
74
75\begin{datadesc}{cansize}
76The default can size, in ounces. Legal values are 7 and 12. The
77default varies per supermarket. This variable should not be changed
78once the \code{open()} function has been called.
79\end{datadesc}
80
81% --- 3.4. ---
82% Exceptions are described using a ``excdesc'' block. This has only
83% one parameter: the exception name.
84
85\begin{excdesc}{error}
86Exception raised when an operation fails for a Spam specific reason.
87The exception argument is a string describing the reason of the
88failure.
89\end{excdesc}
90
91% ---- 3.5. ----
92% There is no standard block type for classes. I generally use
93% ``funcdesc'' blocks, since class instantiation looks very much like
94% a function call.
Guido van Rossum6a11eb41992-06-03 17:59:07 +000095
96
Guido van Rossum51bbdfb1995-03-01 14:07:08 +000097% ==== 4. ====
98% Now is probably a good time for a complete example. (Alternatively,
99% an example giving the flavor of the module may be given before the
100% detailed list of functions.)
Guido van Rossum6a11eb41992-06-03 17:59:07 +0000101
Guido van Rossum51bbdfb1995-03-01 14:07:08 +0000102Example:
Guido van Rossum6a11eb41992-06-03 17:59:07 +0000103
Guido van Rossume47da0a1997-07-17 16:34:52 +0000104\bcode\begin{verbatim}
Guido van Rossum51bbdfb1995-03-01 14:07:08 +0000105>>> import spam
106>>> can = spam.open('/etc/passwd')
107>>> can.empty()
108>>> can.close()
Guido van Rossume47da0a1997-07-17 16:34:52 +0000109\end{verbatim}\ecode
110%
Guido van Rossum51bbdfb1995-03-01 14:07:08 +0000111% ==== 5. ====
112% If your module defines new object types (for a built-in module) or
113% classes (for a module written in Python), you should list the
114% methods and instance variables (if any) of each type or class in a
115% separate subsection. It is important to redefine ``indexsubitem''
116% for each subsection.
117
Guido van Rossum470be141995-03-17 16:07:09 +0000118\subsection{Spam Objects}
Guido van Rossum51bbdfb1995-03-01 14:07:08 +0000119
120Spam objects (returned by \code{open()} above) have the following
121methods.
122
123\renewcommand{\indexsubitem}{(spam method)}
124
125\begin{funcdesc}{empty}{}
126Empty the can into the trash.
127\end{funcdesc}