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. ==== |
| 6 | % Choose one of the following section headers and index entries; |
| 7 | % \section{} generates the section header, |
| 8 | % \bimodindex{} or \stmodundex{} generates an index entry for this module |
| 9 | |
| 10 | \section{Built-in module \sectcode{spam}} % If implemented in C |
| 11 | \bimodindex[spam} |
| 12 | |
| 13 | \section{Standard module \sectcode{spam}} % If implemented in Python |
| 14 | \stmodindex{spam} |
Guido van Rossum | 6a11eb4 | 1992-06-03 17:59:07 +0000 | [diff] [blame] | 15 | |
| 16 | |
Guido van Rossum | 51bbdfb | 1995-03-01 14:07:08 +0000 | [diff] [blame] | 17 | % ==== 2. ==== |
| 18 | % Give a short overview of what the module does. |
| 19 | % If it is platform specific, mention this. |
| 20 | % Mention other important restrictions or general operating principles. |
| 21 | % For example: |
| 22 | |
| 23 | The \code{spam} module defines operations for handling cans of Spam. |
| 24 | It knows the four generally available Spam varieties and understands |
| 25 | both can sizes. |
| 26 | |
| 27 | Because spamification requires UNIX process management, the module is |
| 28 | only available on genuine UNIX systems. |
Guido van Rossum | 6a11eb4 | 1992-06-03 17:59:07 +0000 | [diff] [blame] | 29 | |
| 30 | |
Guido van Rossum | 51bbdfb | 1995-03-01 14:07:08 +0000 | [diff] [blame] | 31 | % ==== 3. ==== |
| 32 | % List the public functions defined by the module. Begin with a |
| 33 | % standard phrase. You may also list the exceptions and other data |
| 34 | % items defined in the module, insofar as they are important for the |
| 35 | % user. |
| 36 | |
| 37 | The \code{spam} module defines the following functions: |
| 38 | |
| 39 | % ---- 3.1. ---- |
| 40 | % Redefine the ``indexsubitem'' macro to point to this module: |
| 41 | |
| 42 | \renewcommand{\indexsubitem}{(in module spam)} |
| 43 | |
| 44 | % ---- 3.2. ---- |
| 45 | % For each function, use a ``funcdesc'' block. This has exactly two |
| 46 | % parameters (each parameters is contained in a set of curly braces): |
| 47 | % the first parameter is the function name (this automatically |
| 48 | % generates an index entry); the second parameter is the function's |
| 49 | % argument list. If there are no arguments, use an empty pair of |
| 50 | % curly braces. If there is more than one argument, separate the |
| 51 | % arguments with backslash-comma. Optional parts of the parameter |
| 52 | % list are contained in \optional{...} (this generates a set of square |
| 53 | % brackets around its parameter). Arguments are automatically set in |
| 54 | % italics in the parameter list. Each argument should be mentioned at |
| 55 | % least once in the description; each usage (even inside \code{...}) |
| 56 | % should be enclosed in \var{...}. |
| 57 | |
| 58 | \begin{funcdesc}{open}{filename\optional{\, mode\, buffersize}} |
| 59 | Open the file \var{filename} as a can of Spam. The optional |
| 60 | \var{mode} and \var{buffersize} arguments specify the read-write mode |
| 61 | (\code{'r'} (default) or \code{'w'}) and the buffer size (default: |
| 62 | system dependent). |
| 63 | \end{funcdesc} |
| 64 | |
| 65 | % ---- 3.3. ---- |
| 66 | % Data items are described using a ``datadesc'' block. This has only |
| 67 | % one parameter: the item's name. |
| 68 | |
| 69 | \begin{datadesc}{cansize} |
| 70 | The default can size, in ounces. Legal values are 7 and 12. The |
| 71 | default varies per supermarket. This variable should not be changed |
| 72 | once the \code{open()} function has been called. |
| 73 | \end{datadesc} |
| 74 | |
| 75 | % --- 3.4. --- |
| 76 | % Exceptions are described using a ``excdesc'' block. This has only |
| 77 | % one parameter: the exception name. |
| 78 | |
| 79 | \begin{excdesc}{error} |
| 80 | Exception raised when an operation fails for a Spam specific reason. |
| 81 | The exception argument is a string describing the reason of the |
| 82 | failure. |
| 83 | \end{excdesc} |
| 84 | |
| 85 | % ---- 3.5. ---- |
| 86 | % There is no standard block type for classes. I generally use |
| 87 | % ``funcdesc'' blocks, since class instantiation looks very much like |
| 88 | % a function call. |
Guido van Rossum | 6a11eb4 | 1992-06-03 17:59:07 +0000 | [diff] [blame] | 89 | |
| 90 | |
Guido van Rossum | 51bbdfb | 1995-03-01 14:07:08 +0000 | [diff] [blame] | 91 | % ==== 4. ==== |
| 92 | % Now is probably a good time for a complete example. (Alternatively, |
| 93 | % an example giving the flavor of the module may be given before the |
| 94 | % detailed list of functions.) |
Guido van Rossum | 6a11eb4 | 1992-06-03 17:59:07 +0000 | [diff] [blame] | 95 | |
Guido van Rossum | 51bbdfb | 1995-03-01 14:07:08 +0000 | [diff] [blame] | 96 | Example: |
Guido van Rossum | 6a11eb4 | 1992-06-03 17:59:07 +0000 | [diff] [blame] | 97 | |
Guido van Rossum | 51bbdfb | 1995-03-01 14:07:08 +0000 | [diff] [blame] | 98 | \begin{verbatim} |
| 99 | >>> import spam |
| 100 | >>> can = spam.open('/etc/passwd') |
| 101 | >>> can.empty() |
| 102 | >>> can.close() |
| 103 | \end{verbatim} |
Guido van Rossum | 6a11eb4 | 1992-06-03 17:59:07 +0000 | [diff] [blame] | 104 | |
Guido van Rossum | 51bbdfb | 1995-03-01 14:07:08 +0000 | [diff] [blame] | 105 | % ==== 5. ==== |
| 106 | % If your module defines new object types (for a built-in module) or |
| 107 | % classes (for a module written in Python), you should list the |
| 108 | % methods and instance variables (if any) of each type or class in a |
| 109 | % separate subsection. It is important to redefine ``indexsubitem'' |
| 110 | % for each subsection. |
| 111 | |
| 112 | \subsection{Spam methods} |
| 113 | |
| 114 | Spam objects (returned by \code{open()} above) have the following |
| 115 | methods. |
| 116 | |
| 117 | \renewcommand{\indexsubitem}{(spam method)} |
| 118 | |
| 119 | \begin{funcdesc}{empty}{} |
| 120 | Empty the can into the trash. |
| 121 | \end{funcdesc} |