Guido van Rossum | 51bbdfb | 1995-03-01 14:07:08 +0000 | [diff] [blame] | 1 | % Template for a library manual section. |
| 2 | % PLEASE REMOVE THE COMMENTS AFTER USING THE TEMPLATE |
Guido van Rossum | 6a11eb4 | 1992-06-03 17:59:07 +0000 | [diff] [blame] | 3 | |
| 4 | |
Guido van Rossum | 51bbdfb | 1995-03-01 14:07:08 +0000 | [diff] [blame] | 5 | % ==== 1. ==== |
Fred Drake | 295da24 | 1998-08-10 19:42:37 +0000 | [diff] [blame] | 6 | % 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 Rossum | 51bbdfb | 1995-03-01 14:07:08 +0000 | [diff] [blame] | 10 | |
Fred Drake | 295da24 | 1998-08-10 19:42:37 +0000 | [diff] [blame] | 11 | \section{\module{spam} --- |
| 12 | Short one-line descrition, for section title.} |
Guido van Rossum | 51bbdfb | 1995-03-01 14:07:08 +0000 | [diff] [blame] | 13 | |
Fred Drake | 295da24 | 1998-08-10 19:42:37 +0000 | [diff] [blame] | 14 | % 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 Drake | 07bcd99 | 1998-04-03 21:25:16 +0000 | [diff] [blame] | 22 | |
Fred Drake | 295da24 | 1998-08-10 19:42:37 +0000 | [diff] [blame] | 23 | % These apply to all modules: |
Fred Drake | 07bcd99 | 1998-04-03 21:25:16 +0000 | [diff] [blame] | 24 | |
Fred Drake | 295da24 | 1998-08-10 19:42:37 +0000 | [diff] [blame] | 25 | \moduleauthor{name}{email} % Author of the module code; |
| 26 | % omit if not known. |
| 27 | \sectionauthor{name}{email} % Author of the documentation. |
Guido van Rossum | 6a11eb4 | 1992-06-03 17:59:07 +0000 | [diff] [blame] | 28 | |
Fred Drake | b91e934 | 1998-07-23 17:59:49 +0000 | [diff] [blame] | 29 | |
Fred Drake | 295da24 | 1998-08-10 19:42:37 +0000 | [diff] [blame] | 30 | % Leave at least one blank line after this, to simplify ad-hoc tools |
| 31 | % that are sometimes used to massage these files. |
Fred Drake | b91e934 | 1998-07-23 17:59:49 +0000 | [diff] [blame] | 32 | \modulesynopsis{This is a one-line descrition, for the chapter header.} |
| 33 | |
Guido van Rossum | 6a11eb4 | 1992-06-03 17:59:07 +0000 | [diff] [blame] | 34 | |
Guido van Rossum | 51bbdfb | 1995-03-01 14:07:08 +0000 | [diff] [blame] | 35 | % ==== 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 Drake | d10d0fa | 1998-02-24 21:43:05 +0000 | [diff] [blame] | 41 | The \module{spam} module defines operations for handling cans of Spam. |
Guido van Rossum | 51bbdfb | 1995-03-01 14:07:08 +0000 | [diff] [blame] | 42 | It knows the four generally available Spam varieties and understands |
| 43 | both can sizes. |
| 44 | |
Fred Drake | 4b3f031 | 1996-12-13 22:04:31 +0000 | [diff] [blame] | 45 | Because spamification requires \UNIX{} process management, the module |
| 46 | is only available on genuine \UNIX{} systems. |
Guido van Rossum | 6a11eb4 | 1992-06-03 17:59:07 +0000 | [diff] [blame] | 47 | |
| 48 | |
Guido van Rossum | 51bbdfb | 1995-03-01 14:07:08 +0000 | [diff] [blame] | 49 | % ==== 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 Drake | d10d0fa | 1998-02-24 21:43:05 +0000 | [diff] [blame] | 55 | The \module{spam} module defines the following functions: |
Guido van Rossum | 51bbdfb | 1995-03-01 14:07:08 +0000 | [diff] [blame] | 56 | |
| 57 | % ---- 3.1. ---- |
Guido van Rossum | 51bbdfb | 1995-03-01 14:07:08 +0000 | [diff] [blame] | 58 | % 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 Drake | 07bcd99 | 1998-04-03 21:25:16 +0000 | [diff] [blame] | 71 | \begin{funcdesc}{open}{filename\optional{, mode\optional{, buffersize}}} |
Guido van Rossum | 51bbdfb | 1995-03-01 14:07:08 +0000 | [diff] [blame] | 72 | Open 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: |
| 75 | system dependent). |
| 76 | \end{funcdesc} |
| 77 | |
Fred Drake | 07bcd99 | 1998-04-03 21:25:16 +0000 | [diff] [blame] | 78 | % ---- 3.2. ---- |
Guido van Rossum | 51bbdfb | 1995-03-01 14:07:08 +0000 | [diff] [blame] | 79 | % Data items are described using a ``datadesc'' block. This has only |
| 80 | % one parameter: the item's name. |
| 81 | |
| 82 | \begin{datadesc}{cansize} |
| 83 | The default can size, in ounces. Legal values are 7 and 12. The |
| 84 | default varies per supermarket. This variable should not be changed |
Fred Drake | d10d0fa | 1998-02-24 21:43:05 +0000 | [diff] [blame] | 85 | once the \function{open()} function has been called. |
Guido van Rossum | 51bbdfb | 1995-03-01 14:07:08 +0000 | [diff] [blame] | 86 | \end{datadesc} |
| 87 | |
Fred Drake | 07bcd99 | 1998-04-03 21:25:16 +0000 | [diff] [blame] | 88 | % --- 3.3. --- |
Guido van Rossum | 51bbdfb | 1995-03-01 14:07:08 +0000 | [diff] [blame] | 89 | % Exceptions are described using a ``excdesc'' block. This has only |
| 90 | % one parameter: the exception name. |
| 91 | |
| 92 | \begin{excdesc}{error} |
| 93 | Exception raised when an operation fails for a Spam specific reason. |
| 94 | The exception argument is a string describing the reason of the |
| 95 | failure. |
| 96 | \end{excdesc} |
| 97 | |
Fred Drake | 07bcd99 | 1998-04-03 21:25:16 +0000 | [diff] [blame] | 98 | % ---- 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 Rossum | 6a11eb4 | 1992-06-03 17:59:07 +0000 | [diff] [blame] | 111 | |
| 112 | |
Guido van Rossum | 51bbdfb | 1995-03-01 14:07:08 +0000 | [diff] [blame] | 113 | % ==== 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 Rossum | 6a11eb4 | 1992-06-03 17:59:07 +0000 | [diff] [blame] | 117 | |
Guido van Rossum | 51bbdfb | 1995-03-01 14:07:08 +0000 | [diff] [blame] | 118 | Example: |
Guido van Rossum | 6a11eb4 | 1992-06-03 17:59:07 +0000 | [diff] [blame] | 119 | |
Fred Drake | 1947991 | 1998-02-13 06:58:54 +0000 | [diff] [blame] | 120 | \begin{verbatim} |
Guido van Rossum | 51bbdfb | 1995-03-01 14:07:08 +0000 | [diff] [blame] | 121 | >>> import spam |
| 122 | >>> can = spam.open('/etc/passwd') |
| 123 | >>> can.empty() |
| 124 | >>> can.close() |
Fred Drake | 1947991 | 1998-02-13 06:58:54 +0000 | [diff] [blame] | 125 | \end{verbatim} |
Fred Drake | 07bcd99 | 1998-04-03 21:25:16 +0000 | [diff] [blame] | 126 | % Note that there is no trailing ">>> " prompt shown. |
| 127 | |
Guido van Rossum | 51bbdfb | 1995-03-01 14:07:08 +0000 | [diff] [blame] | 128 | % ==== 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 Drake | 07bcd99 | 1998-04-03 21:25:16 +0000 | [diff] [blame] | 132 | % separate subsection. |
Guido van Rossum | 51bbdfb | 1995-03-01 14:07:08 +0000 | [diff] [blame] | 133 | |
Guido van Rossum | 470be14 | 1995-03-17 16:07:09 +0000 | [diff] [blame] | 134 | \subsection{Spam Objects} |
Fred Drake | 07bcd99 | 1998-04-03 21:25:16 +0000 | [diff] [blame] | 135 | \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 Rossum | 51bbdfb | 1995-03-01 14:07:08 +0000 | [diff] [blame] | 138 | |
Fred Drake | 07bcd99 | 1998-04-03 21:25:16 +0000 | [diff] [blame] | 139 | Spam objects, as returned by \function{open()} above, have the |
| 140 | following methods: |
Guido van Rossum | 51bbdfb | 1995-03-01 14:07:08 +0000 | [diff] [blame] | 141 | |
Fred Drake | 07bcd99 | 1998-04-03 21:25:16 +0000 | [diff] [blame] | 142 | \begin{methoddesc}[spam]{empty}{} |
Guido van Rossum | 51bbdfb | 1995-03-01 14:07:08 +0000 | [diff] [blame] | 143 | Empty the can into the trash. |
Fred Drake | 07bcd99 | 1998-04-03 21:25:16 +0000 | [diff] [blame] | 144 | \end{methoddesc} |