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