blob: 4e3968889d2c48c252d3bfa043c6deb4628d477b [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} ---
16 Short one-line 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 Drake295da241998-08-10 19:42:37 +000027% These apply to all modules:
Fred Drake07bcd991998-04-03 21:25:16 +000028
Fred Drake295da241998-08-10 19:42:37 +000029\moduleauthor{name}{email} % Author of the module code;
30 % omit if not known.
31\sectionauthor{name}{email} % Author of the documentation.
Guido van Rossum6a11eb41992-06-03 17:59:07 +000032
Fred Drakeb91e9341998-07-23 17:59:49 +000033
Fred Drake295da241998-08-10 19:42:37 +000034% Leave at least one blank line after this, to simplify ad-hoc tools
35% that are sometimes used to massage these files.
Fred Drakeb91e9341998-07-23 17:59:49 +000036\modulesynopsis{This is a one-line descrition, for the chapter header.}
37
Guido van Rossum6a11eb41992-06-03 17:59:07 +000038
Guido van Rossum51bbdfb1995-03-01 14:07:08 +000039% ==== 2. ====
40% Give a short overview of what the module does.
41% If it is platform specific, mention this.
42% Mention other important restrictions or general operating principles.
43% For example:
44
Fred Draked10d0fa1998-02-24 21:43:05 +000045The \module{spam} module defines operations for handling cans of Spam.
Guido van Rossum51bbdfb1995-03-01 14:07:08 +000046It knows the four generally available Spam varieties and understands
47both can sizes.
48
Fred Drake4b3f0311996-12-13 22:04:31 +000049Because spamification requires \UNIX{} process management, the module
50is only available on genuine \UNIX{} systems.
Guido van Rossum6a11eb41992-06-03 17:59:07 +000051
52
Guido van Rossum51bbdfb1995-03-01 14:07:08 +000053% ==== 3. ====
54% List the public functions defined by the module. Begin with a
55% standard phrase. You may also list the exceptions and other data
56% items defined in the module, insofar as they are important for the
57% user.
58
Fred Draked10d0fa1998-02-24 21:43:05 +000059The \module{spam} module defines the following functions:
Guido van Rossum51bbdfb1995-03-01 14:07:08 +000060
61% ---- 3.1. ----
Guido van Rossum51bbdfb1995-03-01 14:07:08 +000062% For each function, use a ``funcdesc'' block. This has exactly two
63% parameters (each parameters is contained in a set of curly braces):
64% the first parameter is the function name (this automatically
65% generates an index entry); the second parameter is the function's
66% argument list. If there are no arguments, use an empty pair of
67% curly braces. If there is more than one argument, separate the
68% arguments with backslash-comma. Optional parts of the parameter
69% list are contained in \optional{...} (this generates a set of square
70% brackets around its parameter). Arguments are automatically set in
71% italics in the parameter list. Each argument should be mentioned at
72% least once in the description; each usage (even inside \code{...})
73% should be enclosed in \var{...}.
74
Fred Drake07bcd991998-04-03 21:25:16 +000075\begin{funcdesc}{open}{filename\optional{, mode\optional{, buffersize}}}
Guido van Rossum51bbdfb1995-03-01 14:07:08 +000076Open the file \var{filename} as a can of Spam. The optional
77\var{mode} and \var{buffersize} arguments specify the read-write mode
78(\code{'r'} (default) or \code{'w'}) and the buffer size (default:
79system dependent).
80\end{funcdesc}
81
Fred Drake07bcd991998-04-03 21:25:16 +000082% ---- 3.2. ----
Guido van Rossum51bbdfb1995-03-01 14:07:08 +000083% Data items are described using a ``datadesc'' block. This has only
84% one parameter: the item's name.
85
86\begin{datadesc}{cansize}
87The default can size, in ounces. Legal values are 7 and 12. The
88default varies per supermarket. This variable should not be changed
Fred Draked10d0fa1998-02-24 21:43:05 +000089once the \function{open()} function has been called.
Guido van Rossum51bbdfb1995-03-01 14:07:08 +000090\end{datadesc}
91
Fred Drake07bcd991998-04-03 21:25:16 +000092% --- 3.3. ---
Guido van Rossum51bbdfb1995-03-01 14:07:08 +000093% Exceptions are described using a ``excdesc'' block. This has only
94% one parameter: the exception name.
95
96\begin{excdesc}{error}
97Exception raised when an operation fails for a Spam specific reason.
98The exception argument is a string describing the reason of the
99failure.
100\end{excdesc}
101
Fred Drake07bcd991998-04-03 21:25:16 +0000102% ---- 3.4. ----
103% Other standard environments:
104%
105% classdesc - Python classes; same arguments are funcdesc
106% methoddesc - methods, like funcdesc but has an optional parameter
107% to give the type name: \begin{methoddesc}[mytype]{name}{args}
108% By default, the type name will be the name of the
109% last class defined using classdesc. The type name
110% is required if the type is implemented in C (because
111% there's no classdesc) or if the class isn't directly
112% documented (if it's private).
113% memberdesc - data members, like datadesc, but with an optional
114% type name like methoddesc.
Guido van Rossum6a11eb41992-06-03 17:59:07 +0000115
116
Guido van Rossum51bbdfb1995-03-01 14:07:08 +0000117% ==== 4. ====
118% Now is probably a good time for a complete example. (Alternatively,
119% an example giving the flavor of the module may be given before the
120% detailed list of functions.)
Guido van Rossum6a11eb41992-06-03 17:59:07 +0000121
Guido van Rossum51bbdfb1995-03-01 14:07:08 +0000122Example:
Guido van Rossum6a11eb41992-06-03 17:59:07 +0000123
Fred Drake19479911998-02-13 06:58:54 +0000124\begin{verbatim}
Guido van Rossum51bbdfb1995-03-01 14:07:08 +0000125>>> import spam
126>>> can = spam.open('/etc/passwd')
127>>> can.empty()
128>>> can.close()
Fred Drake19479911998-02-13 06:58:54 +0000129\end{verbatim}
Fred Drake07bcd991998-04-03 21:25:16 +0000130% Note that there is no trailing ">>> " prompt shown.
131
Guido van Rossum51bbdfb1995-03-01 14:07:08 +0000132% ==== 5. ====
133% If your module defines new object types (for a built-in module) or
134% classes (for a module written in Python), you should list the
135% methods and instance variables (if any) of each type or class in a
Fred Drake07bcd991998-04-03 21:25:16 +0000136% separate subsection.
Guido van Rossum51bbdfb1995-03-01 14:07:08 +0000137
Guido van Rossum470be141995-03-17 16:07:09 +0000138\subsection{Spam Objects}
Fred Drake07bcd991998-04-03 21:25:16 +0000139\label{spam-objects}
140% This label is generally useful for referencing this section, but is
141% also used to give a filename when generating HTML.
Guido van Rossum51bbdfb1995-03-01 14:07:08 +0000142
Fred Drake07bcd991998-04-03 21:25:16 +0000143Spam objects, as returned by \function{open()} above, have the
144following methods:
Guido van Rossum51bbdfb1995-03-01 14:07:08 +0000145
Fred Drake07bcd991998-04-03 21:25:16 +0000146\begin{methoddesc}[spam]{empty}{}
Guido van Rossum51bbdfb1995-03-01 14:07:08 +0000147Empty the can into the trash.
Fred Drake07bcd991998-04-03 21:25:16 +0000148\end{methoddesc}