blob: d190506a8e378c305e3ebdc0fc29840b6ae8a0f6 [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;
Fred Drake07bcd991998-04-03 21:25:16 +00007% \section generates the section header,
8% \bimodindex or \stmodindex generates an index entry for this
Fred Draked9dbfbd1997-12-15 21:20:03 +00009% module. Note that these should only be used for the defining entry
10% for the module. Other references to the module should use
Fred Drake07bcd991998-04-03 21:25:16 +000011% \refbimodindex, \refstmodindex, \refexmodindex or \refmodindex, as
12% appropriate. (Just prepend "ref" to the csname of the \*modindex
13% macro used in the module definition.)
14%
15% The \label{module-spam} line is for the \seealso command.
Guido van Rossum51bbdfb1995-03-01 14:07:08 +000016
Fred Drake07bcd991998-04-03 21:25:16 +000017\section{Built-in Module \module{spam}} % If implemented in C, in
18\bimodindex{spam} % standard library
Guido van Rossum51bbdfb1995-03-01 14:07:08 +000019
Fred Drake07bcd991998-04-03 21:25:16 +000020\section{Standard Module \module{spam}} % If implemented in Python, in
21\stmodindex{spam} % standard library
22
23\section{Extension Module \module{spam}}% If implemented in C, but not
24\exmodindex{spam} % in standard library
25
26\section{Module \module{spam}} % If implemented in Python, but not
27\modindex{spam} % in standard library
Guido van Rossum6a11eb41992-06-03 17:59:07 +000028
Guido van Rossum1c78cf31997-07-18 21:07:34 +000029\label{module-spam}
Guido van Rossum6a11eb41992-06-03 17:59:07 +000030
Guido van Rossum51bbdfb1995-03-01 14:07:08 +000031% ==== 2. ====
32% Give a short overview of what the module does.
33% If it is platform specific, mention this.
34% Mention other important restrictions or general operating principles.
35% For example:
36
Fred Draked10d0fa1998-02-24 21:43:05 +000037The \module{spam} module defines operations for handling cans of Spam.
Guido van Rossum51bbdfb1995-03-01 14:07:08 +000038It knows the four generally available Spam varieties and understands
39both can sizes.
40
Fred Drake4b3f0311996-12-13 22:04:31 +000041Because spamification requires \UNIX{} process management, the module
42is only available on genuine \UNIX{} systems.
Guido van Rossum6a11eb41992-06-03 17:59:07 +000043
44
Guido van Rossum51bbdfb1995-03-01 14:07:08 +000045% ==== 3. ====
46% List the public functions defined by the module. Begin with a
47% standard phrase. You may also list the exceptions and other data
48% items defined in the module, insofar as they are important for the
49% user.
50
Fred Draked10d0fa1998-02-24 21:43:05 +000051The \module{spam} module defines the following functions:
Guido van Rossum51bbdfb1995-03-01 14:07:08 +000052
53% ---- 3.1. ----
Guido van Rossum51bbdfb1995-03-01 14:07:08 +000054% For each function, use a ``funcdesc'' block. This has exactly two
55% parameters (each parameters is contained in a set of curly braces):
56% the first parameter is the function name (this automatically
57% generates an index entry); the second parameter is the function's
58% argument list. If there are no arguments, use an empty pair of
59% curly braces. If there is more than one argument, separate the
60% arguments with backslash-comma. Optional parts of the parameter
61% list are contained in \optional{...} (this generates a set of square
62% brackets around its parameter). Arguments are automatically set in
63% italics in the parameter list. Each argument should be mentioned at
64% least once in the description; each usage (even inside \code{...})
65% should be enclosed in \var{...}.
66
Fred Drake07bcd991998-04-03 21:25:16 +000067\begin{funcdesc}{open}{filename\optional{, mode\optional{, buffersize}}}
Guido van Rossum51bbdfb1995-03-01 14:07:08 +000068Open the file \var{filename} as a can of Spam. The optional
69\var{mode} and \var{buffersize} arguments specify the read-write mode
70(\code{'r'} (default) or \code{'w'}) and the buffer size (default:
71system dependent).
72\end{funcdesc}
73
Fred Drake07bcd991998-04-03 21:25:16 +000074% ---- 3.2. ----
Guido van Rossum51bbdfb1995-03-01 14:07:08 +000075% Data items are described using a ``datadesc'' block. This has only
76% one parameter: the item's name.
77
78\begin{datadesc}{cansize}
79The default can size, in ounces. Legal values are 7 and 12. The
80default varies per supermarket. This variable should not be changed
Fred Draked10d0fa1998-02-24 21:43:05 +000081once the \function{open()} function has been called.
Guido van Rossum51bbdfb1995-03-01 14:07:08 +000082\end{datadesc}
83
Fred Drake07bcd991998-04-03 21:25:16 +000084% --- 3.3. ---
Guido van Rossum51bbdfb1995-03-01 14:07:08 +000085% Exceptions are described using a ``excdesc'' block. This has only
86% one parameter: the exception name.
87
88\begin{excdesc}{error}
89Exception raised when an operation fails for a Spam specific reason.
90The exception argument is a string describing the reason of the
91failure.
92\end{excdesc}
93
Fred Drake07bcd991998-04-03 21:25:16 +000094% ---- 3.4. ----
95% Other standard environments:
96%
97% classdesc - Python classes; same arguments are funcdesc
98% methoddesc - methods, like funcdesc but has an optional parameter
99% to give the type name: \begin{methoddesc}[mytype]{name}{args}
100% By default, the type name will be the name of the
101% last class defined using classdesc. The type name
102% is required if the type is implemented in C (because
103% there's no classdesc) or if the class isn't directly
104% documented (if it's private).
105% memberdesc - data members, like datadesc, but with an optional
106% type name like methoddesc.
Guido van Rossum6a11eb41992-06-03 17:59:07 +0000107
108
Guido van Rossum51bbdfb1995-03-01 14:07:08 +0000109% ==== 4. ====
110% Now is probably a good time for a complete example. (Alternatively,
111% an example giving the flavor of the module may be given before the
112% detailed list of functions.)
Guido van Rossum6a11eb41992-06-03 17:59:07 +0000113
Guido van Rossum51bbdfb1995-03-01 14:07:08 +0000114Example:
Guido van Rossum6a11eb41992-06-03 17:59:07 +0000115
Fred Drake19479911998-02-13 06:58:54 +0000116\begin{verbatim}
Guido van Rossum51bbdfb1995-03-01 14:07:08 +0000117>>> import spam
118>>> can = spam.open('/etc/passwd')
119>>> can.empty()
120>>> can.close()
Fred Drake19479911998-02-13 06:58:54 +0000121\end{verbatim}
Fred Drake07bcd991998-04-03 21:25:16 +0000122% Note that there is no trailing ">>> " prompt shown.
123
Guido van Rossum51bbdfb1995-03-01 14:07:08 +0000124% ==== 5. ====
125% If your module defines new object types (for a built-in module) or
126% classes (for a module written in Python), you should list the
127% methods and instance variables (if any) of each type or class in a
Fred Drake07bcd991998-04-03 21:25:16 +0000128% separate subsection.
Guido van Rossum51bbdfb1995-03-01 14:07:08 +0000129
Guido van Rossum470be141995-03-17 16:07:09 +0000130\subsection{Spam Objects}
Fred Drake07bcd991998-04-03 21:25:16 +0000131\label{spam-objects}
132% This label is generally useful for referencing this section, but is
133% also used to give a filename when generating HTML.
Guido van Rossum51bbdfb1995-03-01 14:07:08 +0000134
Fred Drake07bcd991998-04-03 21:25:16 +0000135Spam objects, as returned by \function{open()} above, have the
136following methods:
Guido van Rossum51bbdfb1995-03-01 14:07:08 +0000137
Fred Drake07bcd991998-04-03 21:25:16 +0000138\begin{methoddesc}[spam]{empty}{}
Guido van Rossum51bbdfb1995-03-01 14:07:08 +0000139Empty the can into the trash.
Fred Drake07bcd991998-04-03 21:25:16 +0000140\end{methoddesc}