blob: e82bb21d5733839c574fb09ad1a1111107c70310 [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 Drakeb91e9341998-07-23 17:59:49 +00007% \section generates the section header, \declmodule produces the
8% appropriate index entry for this module. Note that these should
9% only be used for the defining entry for the module. Other
10% references to the module should use \refbimodindex, \refstmodindex,
11% \refexmodindex or \refmodindex, as appropriate.
Guido van Rossum51bbdfb1995-03-01 14:07:08 +000012
Fred Drake07bcd991998-04-03 21:25:16 +000013\section{Built-in Module \module{spam}} % If implemented in C, in
Fred Drakeb91e9341998-07-23 17:59:49 +000014\declaremodule{builtin}{spam} % standard library
Guido van Rossum51bbdfb1995-03-01 14:07:08 +000015
Fred Drake07bcd991998-04-03 21:25:16 +000016\section{Standard Module \module{spam}} % If implemented in Python, in
Fred Drakeb91e9341998-07-23 17:59:49 +000017\declaremodule{standard}{spam} % standard library
Fred Drake07bcd991998-04-03 21:25:16 +000018
19\section{Extension Module \module{spam}}% If implemented in C, but not
Fred Drakeb91e9341998-07-23 17:59:49 +000020\declaremodule{extension}{spam} % in standard library
Fred Drake07bcd991998-04-03 21:25:16 +000021
22\section{Module \module{spam}} % If implemented in Python, but not
Fred Drakeb91e9341998-07-23 17:59:49 +000023\declaremodule{}{spam} % in standard library
Guido van Rossum6a11eb41992-06-03 17:59:07 +000024
Fred Drakeb91e9341998-07-23 17:59:49 +000025
26\modulesynopsis{This is a one-line descrition, for the chapter header.}
27
Guido van Rossum6a11eb41992-06-03 17:59:07 +000028
Guido van Rossum51bbdfb1995-03-01 14:07:08 +000029% ==== 2. ====
30% Give a short overview of what the module does.
31% If it is platform specific, mention this.
32% Mention other important restrictions or general operating principles.
33% For example:
34
Fred Draked10d0fa1998-02-24 21:43:05 +000035The \module{spam} module defines operations for handling cans of Spam.
Guido van Rossum51bbdfb1995-03-01 14:07:08 +000036It knows the four generally available Spam varieties and understands
37both can sizes.
38
Fred Drake4b3f0311996-12-13 22:04:31 +000039Because spamification requires \UNIX{} process management, the module
40is only available on genuine \UNIX{} systems.
Guido van Rossum6a11eb41992-06-03 17:59:07 +000041
42
Guido van Rossum51bbdfb1995-03-01 14:07:08 +000043% ==== 3. ====
44% List the public functions defined by the module. Begin with a
45% standard phrase. You may also list the exceptions and other data
46% items defined in the module, insofar as they are important for the
47% user.
48
Fred Draked10d0fa1998-02-24 21:43:05 +000049The \module{spam} module defines the following functions:
Guido van Rossum51bbdfb1995-03-01 14:07:08 +000050
51% ---- 3.1. ----
Guido van Rossum51bbdfb1995-03-01 14:07:08 +000052% For each function, use a ``funcdesc'' block. This has exactly two
53% parameters (each parameters is contained in a set of curly braces):
54% the first parameter is the function name (this automatically
55% generates an index entry); the second parameter is the function's
56% argument list. If there are no arguments, use an empty pair of
57% curly braces. If there is more than one argument, separate the
58% arguments with backslash-comma. Optional parts of the parameter
59% list are contained in \optional{...} (this generates a set of square
60% brackets around its parameter). Arguments are automatically set in
61% italics in the parameter list. Each argument should be mentioned at
62% least once in the description; each usage (even inside \code{...})
63% should be enclosed in \var{...}.
64
Fred Drake07bcd991998-04-03 21:25:16 +000065\begin{funcdesc}{open}{filename\optional{, mode\optional{, buffersize}}}
Guido van Rossum51bbdfb1995-03-01 14:07:08 +000066Open the file \var{filename} as a can of Spam. The optional
67\var{mode} and \var{buffersize} arguments specify the read-write mode
68(\code{'r'} (default) or \code{'w'}) and the buffer size (default:
69system dependent).
70\end{funcdesc}
71
Fred Drake07bcd991998-04-03 21:25:16 +000072% ---- 3.2. ----
Guido van Rossum51bbdfb1995-03-01 14:07:08 +000073% Data items are described using a ``datadesc'' block. This has only
74% one parameter: the item's name.
75
76\begin{datadesc}{cansize}
77The default can size, in ounces. Legal values are 7 and 12. The
78default varies per supermarket. This variable should not be changed
Fred Draked10d0fa1998-02-24 21:43:05 +000079once the \function{open()} function has been called.
Guido van Rossum51bbdfb1995-03-01 14:07:08 +000080\end{datadesc}
81
Fred Drake07bcd991998-04-03 21:25:16 +000082% --- 3.3. ---
Guido van Rossum51bbdfb1995-03-01 14:07:08 +000083% Exceptions are described using a ``excdesc'' block. This has only
84% one parameter: the exception name.
85
86\begin{excdesc}{error}
87Exception raised when an operation fails for a Spam specific reason.
88The exception argument is a string describing the reason of the
89failure.
90\end{excdesc}
91
Fred Drake07bcd991998-04-03 21:25:16 +000092% ---- 3.4. ----
93% Other standard environments:
94%
95% classdesc - Python classes; same arguments are funcdesc
96% methoddesc - methods, like funcdesc but has an optional parameter
97% to give the type name: \begin{methoddesc}[mytype]{name}{args}
98% By default, the type name will be the name of the
99% last class defined using classdesc. The type name
100% is required if the type is implemented in C (because
101% there's no classdesc) or if the class isn't directly
102% documented (if it's private).
103% memberdesc - data members, like datadesc, but with an optional
104% type name like methoddesc.
Guido van Rossum6a11eb41992-06-03 17:59:07 +0000105
106
Guido van Rossum51bbdfb1995-03-01 14:07:08 +0000107% ==== 4. ====
108% Now is probably a good time for a complete example. (Alternatively,
109% an example giving the flavor of the module may be given before the
110% detailed list of functions.)
Guido van Rossum6a11eb41992-06-03 17:59:07 +0000111
Guido van Rossum51bbdfb1995-03-01 14:07:08 +0000112Example:
Guido van Rossum6a11eb41992-06-03 17:59:07 +0000113
Fred Drake19479911998-02-13 06:58:54 +0000114\begin{verbatim}
Guido van Rossum51bbdfb1995-03-01 14:07:08 +0000115>>> import spam
116>>> can = spam.open('/etc/passwd')
117>>> can.empty()
118>>> can.close()
Fred Drake19479911998-02-13 06:58:54 +0000119\end{verbatim}
Fred Drake07bcd991998-04-03 21:25:16 +0000120% Note that there is no trailing ">>> " prompt shown.
121
Guido van Rossum51bbdfb1995-03-01 14:07:08 +0000122% ==== 5. ====
123% If your module defines new object types (for a built-in module) or
124% classes (for a module written in Python), you should list the
125% methods and instance variables (if any) of each type or class in a
Fred Drake07bcd991998-04-03 21:25:16 +0000126% separate subsection.
Guido van Rossum51bbdfb1995-03-01 14:07:08 +0000127
Guido van Rossum470be141995-03-17 16:07:09 +0000128\subsection{Spam Objects}
Fred Drake07bcd991998-04-03 21:25:16 +0000129\label{spam-objects}
130% This label is generally useful for referencing this section, but is
131% also used to give a filename when generating HTML.
Guido van Rossum51bbdfb1995-03-01 14:07:08 +0000132
Fred Drake07bcd991998-04-03 21:25:16 +0000133Spam objects, as returned by \function{open()} above, have the
134following methods:
Guido van Rossum51bbdfb1995-03-01 14:07:08 +0000135
Fred Drake07bcd991998-04-03 21:25:16 +0000136\begin{methoddesc}[spam]{empty}{}
Guido van Rossum51bbdfb1995-03-01 14:07:08 +0000137Empty the can into the trash.
Fred Drake07bcd991998-04-03 21:25:16 +0000138\end{methoddesc}