blob: cff05d14ab3c10d0b116d460cd423523895c572a [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. ====
Fred Drake295da241998-08-10 19:42:37 +00006% The section prologue. Give the section a title and provide some
7% meta-information. References to the module should use
8% \refbimodindex, \refstmodindex, \refexmodindex or \refmodindex, as
9% appropriate.
Guido van Rossum51bbdfb1995-03-01 14:07:08 +000010
Fred Drake295da241998-08-10 19:42:37 +000011\section{\module{spam} ---
12 Short one-line descrition, for section title.}
Guido van Rossum51bbdfb1995-03-01 14:07:08 +000013
Fred Drake295da241998-08-10 19:42:37 +000014% Choose one of these to specify the module module name. If there's
15% an underscore in the name, use
16% \declaremodule[modname]{...}{mod_name} instead.
17%
18\declaremodule{builtin}{spam} % standard library, in C
19\declaremodule{standard}{spam} % standard library, in Python
20\declaremodule{extension}{spam} % not standard, in C
21\declaremodule{}{spam} % not standard, in Python
Fred Drake07bcd991998-04-03 21:25:16 +000022
Fred Drake295da241998-08-10 19:42:37 +000023% These apply to all modules:
Fred Drake07bcd991998-04-03 21:25:16 +000024
Fred Drake295da241998-08-10 19:42:37 +000025\moduleauthor{name}{email} % Author of the module code;
26 % omit if not known.
27\sectionauthor{name}{email} % Author of the documentation.
Guido van Rossum6a11eb41992-06-03 17:59:07 +000028
Fred Drakeb91e9341998-07-23 17:59:49 +000029
Fred Drake295da241998-08-10 19:42:37 +000030% Leave at least one blank line after this, to simplify ad-hoc tools
31% that are sometimes used to massage these files.
Fred Drakeb91e9341998-07-23 17:59:49 +000032\modulesynopsis{This is a one-line descrition, for the chapter header.}
33
Guido van Rossum6a11eb41992-06-03 17:59:07 +000034
Guido van Rossum51bbdfb1995-03-01 14:07:08 +000035% ==== 2. ====
36% Give a short overview of what the module does.
37% If it is platform specific, mention this.
38% Mention other important restrictions or general operating principles.
39% For example:
40
Fred Draked10d0fa1998-02-24 21:43:05 +000041The \module{spam} module defines operations for handling cans of Spam.
Guido van Rossum51bbdfb1995-03-01 14:07:08 +000042It knows the four generally available Spam varieties and understands
43both can sizes.
44
Fred Drake4b3f0311996-12-13 22:04:31 +000045Because spamification requires \UNIX{} process management, the module
46is only available on genuine \UNIX{} systems.
Guido van Rossum6a11eb41992-06-03 17:59:07 +000047
48
Guido van Rossum51bbdfb1995-03-01 14:07:08 +000049% ==== 3. ====
50% List the public functions defined by the module. Begin with a
51% standard phrase. You may also list the exceptions and other data
52% items defined in the module, insofar as they are important for the
53% user.
54
Fred Draked10d0fa1998-02-24 21:43:05 +000055The \module{spam} module defines the following functions:
Guido van Rossum51bbdfb1995-03-01 14:07:08 +000056
57% ---- 3.1. ----
Guido van Rossum51bbdfb1995-03-01 14:07:08 +000058% For each function, use a ``funcdesc'' block. This has exactly two
59% parameters (each parameters is contained in a set of curly braces):
60% the first parameter is the function name (this automatically
61% generates an index entry); the second parameter is the function's
62% argument list. If there are no arguments, use an empty pair of
63% curly braces. If there is more than one argument, separate the
64% arguments with backslash-comma. Optional parts of the parameter
65% list are contained in \optional{...} (this generates a set of square
66% brackets around its parameter). Arguments are automatically set in
67% italics in the parameter list. Each argument should be mentioned at
68% least once in the description; each usage (even inside \code{...})
69% should be enclosed in \var{...}.
70
Fred Drake07bcd991998-04-03 21:25:16 +000071\begin{funcdesc}{open}{filename\optional{, mode\optional{, buffersize}}}
Guido van Rossum51bbdfb1995-03-01 14:07:08 +000072Open the file \var{filename} as a can of Spam. The optional
73\var{mode} and \var{buffersize} arguments specify the read-write mode
74(\code{'r'} (default) or \code{'w'}) and the buffer size (default:
75system dependent).
76\end{funcdesc}
77
Fred Drake07bcd991998-04-03 21:25:16 +000078% ---- 3.2. ----
Guido van Rossum51bbdfb1995-03-01 14:07:08 +000079% Data items are described using a ``datadesc'' block. This has only
80% one parameter: the item's name.
81
82\begin{datadesc}{cansize}
83The default can size, in ounces. Legal values are 7 and 12. The
84default varies per supermarket. This variable should not be changed
Fred Draked10d0fa1998-02-24 21:43:05 +000085once the \function{open()} function has been called.
Guido van Rossum51bbdfb1995-03-01 14:07:08 +000086\end{datadesc}
87
Fred Drake07bcd991998-04-03 21:25:16 +000088% --- 3.3. ---
Guido van Rossum51bbdfb1995-03-01 14:07:08 +000089% Exceptions are described using a ``excdesc'' block. This has only
90% one parameter: the exception name.
91
92\begin{excdesc}{error}
93Exception raised when an operation fails for a Spam specific reason.
94The exception argument is a string describing the reason of the
95failure.
96\end{excdesc}
97
Fred Drake07bcd991998-04-03 21:25:16 +000098% ---- 3.4. ----
99% Other standard environments:
100%
101% classdesc - Python classes; same arguments are funcdesc
102% methoddesc - methods, like funcdesc but has an optional parameter
103% to give the type name: \begin{methoddesc}[mytype]{name}{args}
104% By default, the type name will be the name of the
105% last class defined using classdesc. The type name
106% is required if the type is implemented in C (because
107% there's no classdesc) or if the class isn't directly
108% documented (if it's private).
109% memberdesc - data members, like datadesc, but with an optional
110% type name like methoddesc.
Guido van Rossum6a11eb41992-06-03 17:59:07 +0000111
112
Guido van Rossum51bbdfb1995-03-01 14:07:08 +0000113% ==== 4. ====
114% Now is probably a good time for a complete example. (Alternatively,
115% an example giving the flavor of the module may be given before the
116% detailed list of functions.)
Guido van Rossum6a11eb41992-06-03 17:59:07 +0000117
Guido van Rossum51bbdfb1995-03-01 14:07:08 +0000118Example:
Guido van Rossum6a11eb41992-06-03 17:59:07 +0000119
Fred Drake19479911998-02-13 06:58:54 +0000120\begin{verbatim}
Guido van Rossum51bbdfb1995-03-01 14:07:08 +0000121>>> import spam
122>>> can = spam.open('/etc/passwd')
123>>> can.empty()
124>>> can.close()
Fred Drake19479911998-02-13 06:58:54 +0000125\end{verbatim}
Fred Drake07bcd991998-04-03 21:25:16 +0000126% Note that there is no trailing ">>> " prompt shown.
127
Guido van Rossum51bbdfb1995-03-01 14:07:08 +0000128% ==== 5. ====
129% If your module defines new object types (for a built-in module) or
130% classes (for a module written in Python), you should list the
131% methods and instance variables (if any) of each type or class in a
Fred Drake07bcd991998-04-03 21:25:16 +0000132% separate subsection.
Guido van Rossum51bbdfb1995-03-01 14:07:08 +0000133
Guido van Rossum470be141995-03-17 16:07:09 +0000134\subsection{Spam Objects}
Fred Drake07bcd991998-04-03 21:25:16 +0000135\label{spam-objects}
136% This label is generally useful for referencing this section, but is
137% also used to give a filename when generating HTML.
Guido van Rossum51bbdfb1995-03-01 14:07:08 +0000138
Fred Drake07bcd991998-04-03 21:25:16 +0000139Spam objects, as returned by \function{open()} above, have the
140following methods:
Guido van Rossum51bbdfb1995-03-01 14:07:08 +0000141
Fred Drake07bcd991998-04-03 21:25:16 +0000142\begin{methoddesc}[spam]{empty}{}
Guido van Rossum51bbdfb1995-03-01 14:07:08 +0000143Empty the can into the trash.
Fred Drake07bcd991998-04-03 21:25:16 +0000144\end{methoddesc}