blob: 107848f68b3fe6d3531564a3efed27b7320b3013 [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
Fred Drake0618f5e1998-08-11 17:43:45 +00004% ==== 0. ====
5% Copy this file to <mydir>/lib<mymodule>.tex, and edit that file
6% according to the instructions below.
7
Guido van Rossum6a11eb41992-06-03 17:59:07 +00008
Guido van Rossum51bbdfb1995-03-01 14:07:08 +00009% ==== 1. ====
Fred Drake295da241998-08-10 19:42:37 +000010% The section prologue. Give the section a title and provide some
11% meta-information. References to the module should use
12% \refbimodindex, \refstmodindex, \refexmodindex or \refmodindex, as
13% appropriate.
Guido van Rossum51bbdfb1995-03-01 14:07:08 +000014
Fred Drake295da241998-08-10 19:42:37 +000015\section{\module{spam} ---
Fred Drake46a94381999-03-02 16:24:22 +000016 Short descrition, for section title}
Guido van Rossum51bbdfb1995-03-01 14:07:08 +000017
Fred Drake295da241998-08-10 19:42:37 +000018% Choose one of these to specify the module module name. If there's
19% an underscore in the name, use
20% \declaremodule[modname]{...}{mod_name} instead.
21%
22\declaremodule{builtin}{spam} % standard library, in C
23\declaremodule{standard}{spam} % standard library, in Python
24\declaremodule{extension}{spam} % not standard, in C
25\declaremodule{}{spam} % not standard, in Python
Fred Drake07bcd991998-04-03 21:25:16 +000026
Fred Drake46a94381999-03-02 16:24:22 +000027% Portability statement: Uncomment and fill in the parameter to specify the
28% availability of the module. The parameter can be Unix, IRIX, SunOS, Mac,
29% Windows, or lots of other stuff. When ``Mac'' is specified, the availability
30% statement will say ``Macintosh'' and the Module Index may say ``Mac''.
31% Please use a name that has already been used whenever applicable. If this
32% is omitted, no availability statement is produced or implied.
33%
34% \platform{UNIX}
35
Fred Drake295da241998-08-10 19:42:37 +000036% These apply to all modules:
Fred Drake07bcd991998-04-03 21:25:16 +000037
Fred Drake295da241998-08-10 19:42:37 +000038\moduleauthor{name}{email} % Author of the module code;
39 % omit if not known.
Fred Drake5eecd7b1998-12-22 18:15:04 +000040\sectionauthor{name}{email} % Author of the documentation,
41 % even if not a module section.
Guido van Rossum6a11eb41992-06-03 17:59:07 +000042
Fred Drakeb91e9341998-07-23 17:59:49 +000043
Fred Drake295da241998-08-10 19:42:37 +000044% Leave at least one blank line after this, to simplify ad-hoc tools
45% that are sometimes used to massage these files.
Fred Drakeb91e9341998-07-23 17:59:49 +000046\modulesynopsis{This is a one-line descrition, for the chapter header.}
47
Guido van Rossum6a11eb41992-06-03 17:59:07 +000048
Guido van Rossum51bbdfb1995-03-01 14:07:08 +000049% ==== 2. ====
50% Give a short overview of what the module does.
51% If it is platform specific, mention this.
52% Mention other important restrictions or general operating principles.
53% For example:
54
Fred Draked10d0fa1998-02-24 21:43:05 +000055The \module{spam} module defines operations for handling cans of Spam.
Guido van Rossum51bbdfb1995-03-01 14:07:08 +000056It knows the four generally available Spam varieties and understands
57both can sizes.
58
Fred Drake4b3f0311996-12-13 22:04:31 +000059Because spamification requires \UNIX{} process management, the module
60is only available on genuine \UNIX{} systems.
Guido van Rossum6a11eb41992-06-03 17:59:07 +000061
62
Guido van Rossum51bbdfb1995-03-01 14:07:08 +000063% ==== 3. ====
64% List the public functions defined by the module. Begin with a
65% standard phrase. You may also list the exceptions and other data
66% items defined in the module, insofar as they are important for the
67% user.
68
Fred Draked10d0fa1998-02-24 21:43:05 +000069The \module{spam} module defines the following functions:
Guido van Rossum51bbdfb1995-03-01 14:07:08 +000070
71% ---- 3.1. ----
Guido van Rossum51bbdfb1995-03-01 14:07:08 +000072% For each function, use a ``funcdesc'' block. This has exactly two
73% parameters (each parameters is contained in a set of curly braces):
74% the first parameter is the function name (this automatically
75% generates an index entry); the second parameter is the function's
76% argument list. If there are no arguments, use an empty pair of
77% curly braces. If there is more than one argument, separate the
78% arguments with backslash-comma. Optional parts of the parameter
79% list are contained in \optional{...} (this generates a set of square
80% brackets around its parameter). Arguments are automatically set in
81% italics in the parameter list. Each argument should be mentioned at
82% least once in the description; each usage (even inside \code{...})
83% should be enclosed in \var{...}.
84
Fred Drake07bcd991998-04-03 21:25:16 +000085\begin{funcdesc}{open}{filename\optional{, mode\optional{, buffersize}}}
Guido van Rossum51bbdfb1995-03-01 14:07:08 +000086Open the file \var{filename} as a can of Spam. The optional
87\var{mode} and \var{buffersize} arguments specify the read-write mode
88(\code{'r'} (default) or \code{'w'}) and the buffer size (default:
89system dependent).
90\end{funcdesc}
91
Fred Drake07bcd991998-04-03 21:25:16 +000092% ---- 3.2. ----
Guido van Rossum51bbdfb1995-03-01 14:07:08 +000093% Data items are described using a ``datadesc'' block. This has only
94% one parameter: the item's name.
95
96\begin{datadesc}{cansize}
97The default can size, in ounces. Legal values are 7 and 12. The
98default varies per supermarket. This variable should not be changed
Fred Draked10d0fa1998-02-24 21:43:05 +000099once the \function{open()} function has been called.
Guido van Rossum51bbdfb1995-03-01 14:07:08 +0000100\end{datadesc}
101
Fred Drake07bcd991998-04-03 21:25:16 +0000102% --- 3.3. ---
Guido van Rossum51bbdfb1995-03-01 14:07:08 +0000103% Exceptions are described using a ``excdesc'' block. This has only
104% one parameter: the exception name.
105
106\begin{excdesc}{error}
107Exception raised when an operation fails for a Spam specific reason.
108The exception argument is a string describing the reason of the
109failure.
110\end{excdesc}
111
Fred Drake07bcd991998-04-03 21:25:16 +0000112% ---- 3.4. ----
113% Other standard environments:
114%
115% classdesc - Python classes; same arguments are funcdesc
116% methoddesc - methods, like funcdesc but has an optional parameter
117% to give the type name: \begin{methoddesc}[mytype]{name}{args}
118% By default, the type name will be the name of the
119% last class defined using classdesc. The type name
120% is required if the type is implemented in C (because
121% there's no classdesc) or if the class isn't directly
122% documented (if it's private).
123% memberdesc - data members, like datadesc, but with an optional
124% type name like methoddesc.
Guido van Rossum6a11eb41992-06-03 17:59:07 +0000125
126
Guido van Rossum51bbdfb1995-03-01 14:07:08 +0000127% ==== 4. ====
128% Now is probably a good time for a complete example. (Alternatively,
129% an example giving the flavor of the module may be given before the
130% detailed list of functions.)
Guido van Rossum6a11eb41992-06-03 17:59:07 +0000131
Skip Montanaro8968a822000-07-06 13:43:37 +0000132\subsection{Example}
133\nodename{Spam Example}
134
135The following example demonstrates how to open a can of spam using the
136\module{spam} module.
Guido van Rossum6a11eb41992-06-03 17:59:07 +0000137
Fred Drake19479911998-02-13 06:58:54 +0000138\begin{verbatim}
Guido van Rossum51bbdfb1995-03-01 14:07:08 +0000139>>> import spam
140>>> can = spam.open('/etc/passwd')
141>>> can.empty()
142>>> can.close()
Fred Drake19479911998-02-13 06:58:54 +0000143\end{verbatim}
Fred Drake07bcd991998-04-03 21:25:16 +0000144% Note that there is no trailing ">>> " prompt shown.
145
Guido van Rossum51bbdfb1995-03-01 14:07:08 +0000146% ==== 5. ====
147% If your module defines new object types (for a built-in module) or
148% classes (for a module written in Python), you should list the
149% methods and instance variables (if any) of each type or class in a
Fred Drake07bcd991998-04-03 21:25:16 +0000150% separate subsection.
Guido van Rossum51bbdfb1995-03-01 14:07:08 +0000151
Guido van Rossum470be141995-03-17 16:07:09 +0000152\subsection{Spam Objects}
Fred Drake07bcd991998-04-03 21:25:16 +0000153\label{spam-objects}
154% This label is generally useful for referencing this section, but is
155% also used to give a filename when generating HTML.
Guido van Rossum51bbdfb1995-03-01 14:07:08 +0000156
Fred Drake07bcd991998-04-03 21:25:16 +0000157Spam objects, as returned by \function{open()} above, have the
158following methods:
Guido van Rossum51bbdfb1995-03-01 14:07:08 +0000159
Fred Drake07bcd991998-04-03 21:25:16 +0000160\begin{methoddesc}[spam]{empty}{}
Guido van Rossum51bbdfb1995-03-01 14:07:08 +0000161Empty the can into the trash.
Fred Drake07bcd991998-04-03 21:25:16 +0000162\end{methoddesc}