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 | |
Fred Drake | 0618f5e | 1998-08-11 17:43:45 +0000 | [diff] [blame] | 4 | % ==== 0. ==== |
| 5 | % Copy this file to <mydir>/lib<mymodule>.tex, and edit that file |
| 6 | % according to the instructions below. |
| 7 | |
Guido van Rossum | 6a11eb4 | 1992-06-03 17:59:07 +0000 | [diff] [blame] | 8 | |
Guido van Rossum | 51bbdfb | 1995-03-01 14:07:08 +0000 | [diff] [blame] | 9 | % ==== 1. ==== |
Fred Drake | 295da24 | 1998-08-10 19:42:37 +0000 | [diff] [blame] | 10 | % 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 Rossum | 51bbdfb | 1995-03-01 14:07:08 +0000 | [diff] [blame] | 14 | |
Fred Drake | 295da24 | 1998-08-10 19:42:37 +0000 | [diff] [blame] | 15 | \section{\module{spam} --- |
Fred Drake | 5eecd7b | 1998-12-22 18:15:04 +0000 | [diff] [blame^] | 16 | Short descrition, for section title.} |
Guido van Rossum | 51bbdfb | 1995-03-01 14:07:08 +0000 | [diff] [blame] | 17 | |
Fred Drake | 295da24 | 1998-08-10 19:42:37 +0000 | [diff] [blame] | 18 | % 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 Drake | 07bcd99 | 1998-04-03 21:25:16 +0000 | [diff] [blame] | 26 | |
Fred Drake | 295da24 | 1998-08-10 19:42:37 +0000 | [diff] [blame] | 27 | % These apply to all modules: |
Fred Drake | 07bcd99 | 1998-04-03 21:25:16 +0000 | [diff] [blame] | 28 | |
Fred Drake | 295da24 | 1998-08-10 19:42:37 +0000 | [diff] [blame] | 29 | \moduleauthor{name}{email} % Author of the module code; |
| 30 | % omit if not known. |
Fred Drake | 5eecd7b | 1998-12-22 18:15:04 +0000 | [diff] [blame^] | 31 | \sectionauthor{name}{email} % Author of the documentation, |
| 32 | % even if not a module section. |
Guido van Rossum | 6a11eb4 | 1992-06-03 17:59:07 +0000 | [diff] [blame] | 33 | |
Fred Drake | b91e934 | 1998-07-23 17:59:49 +0000 | [diff] [blame] | 34 | |
Fred Drake | 295da24 | 1998-08-10 19:42:37 +0000 | [diff] [blame] | 35 | % Leave at least one blank line after this, to simplify ad-hoc tools |
| 36 | % that are sometimes used to massage these files. |
Fred Drake | b91e934 | 1998-07-23 17:59:49 +0000 | [diff] [blame] | 37 | \modulesynopsis{This is a one-line descrition, for the chapter header.} |
| 38 | |
Guido van Rossum | 6a11eb4 | 1992-06-03 17:59:07 +0000 | [diff] [blame] | 39 | |
Guido van Rossum | 51bbdfb | 1995-03-01 14:07:08 +0000 | [diff] [blame] | 40 | % ==== 2. ==== |
| 41 | % Give a short overview of what the module does. |
| 42 | % If it is platform specific, mention this. |
| 43 | % Mention other important restrictions or general operating principles. |
| 44 | % For example: |
| 45 | |
Fred Drake | d10d0fa | 1998-02-24 21:43:05 +0000 | [diff] [blame] | 46 | The \module{spam} module defines operations for handling cans of Spam. |
Guido van Rossum | 51bbdfb | 1995-03-01 14:07:08 +0000 | [diff] [blame] | 47 | It knows the four generally available Spam varieties and understands |
| 48 | both can sizes. |
| 49 | |
Fred Drake | 4b3f031 | 1996-12-13 22:04:31 +0000 | [diff] [blame] | 50 | Because spamification requires \UNIX{} process management, the module |
| 51 | is only available on genuine \UNIX{} systems. |
Guido van Rossum | 6a11eb4 | 1992-06-03 17:59:07 +0000 | [diff] [blame] | 52 | |
| 53 | |
Guido van Rossum | 51bbdfb | 1995-03-01 14:07:08 +0000 | [diff] [blame] | 54 | % ==== 3. ==== |
| 55 | % List the public functions defined by the module. Begin with a |
| 56 | % standard phrase. You may also list the exceptions and other data |
| 57 | % items defined in the module, insofar as they are important for the |
| 58 | % user. |
| 59 | |
Fred Drake | d10d0fa | 1998-02-24 21:43:05 +0000 | [diff] [blame] | 60 | The \module{spam} module defines the following functions: |
Guido van Rossum | 51bbdfb | 1995-03-01 14:07:08 +0000 | [diff] [blame] | 61 | |
| 62 | % ---- 3.1. ---- |
Guido van Rossum | 51bbdfb | 1995-03-01 14:07:08 +0000 | [diff] [blame] | 63 | % For each function, use a ``funcdesc'' block. This has exactly two |
| 64 | % parameters (each parameters is contained in a set of curly braces): |
| 65 | % the first parameter is the function name (this automatically |
| 66 | % generates an index entry); the second parameter is the function's |
| 67 | % argument list. If there are no arguments, use an empty pair of |
| 68 | % curly braces. If there is more than one argument, separate the |
| 69 | % arguments with backslash-comma. Optional parts of the parameter |
| 70 | % list are contained in \optional{...} (this generates a set of square |
| 71 | % brackets around its parameter). Arguments are automatically set in |
| 72 | % italics in the parameter list. Each argument should be mentioned at |
| 73 | % least once in the description; each usage (even inside \code{...}) |
| 74 | % should be enclosed in \var{...}. |
| 75 | |
Fred Drake | 07bcd99 | 1998-04-03 21:25:16 +0000 | [diff] [blame] | 76 | \begin{funcdesc}{open}{filename\optional{, mode\optional{, buffersize}}} |
Guido van Rossum | 51bbdfb | 1995-03-01 14:07:08 +0000 | [diff] [blame] | 77 | Open the file \var{filename} as a can of Spam. The optional |
| 78 | \var{mode} and \var{buffersize} arguments specify the read-write mode |
| 79 | (\code{'r'} (default) or \code{'w'}) and the buffer size (default: |
| 80 | system dependent). |
| 81 | \end{funcdesc} |
| 82 | |
Fred Drake | 07bcd99 | 1998-04-03 21:25:16 +0000 | [diff] [blame] | 83 | % ---- 3.2. ---- |
Guido van Rossum | 51bbdfb | 1995-03-01 14:07:08 +0000 | [diff] [blame] | 84 | % Data items are described using a ``datadesc'' block. This has only |
| 85 | % one parameter: the item's name. |
| 86 | |
| 87 | \begin{datadesc}{cansize} |
| 88 | The default can size, in ounces. Legal values are 7 and 12. The |
| 89 | default varies per supermarket. This variable should not be changed |
Fred Drake | d10d0fa | 1998-02-24 21:43:05 +0000 | [diff] [blame] | 90 | once the \function{open()} function has been called. |
Guido van Rossum | 51bbdfb | 1995-03-01 14:07:08 +0000 | [diff] [blame] | 91 | \end{datadesc} |
| 92 | |
Fred Drake | 07bcd99 | 1998-04-03 21:25:16 +0000 | [diff] [blame] | 93 | % --- 3.3. --- |
Guido van Rossum | 51bbdfb | 1995-03-01 14:07:08 +0000 | [diff] [blame] | 94 | % Exceptions are described using a ``excdesc'' block. This has only |
| 95 | % one parameter: the exception name. |
| 96 | |
| 97 | \begin{excdesc}{error} |
| 98 | Exception raised when an operation fails for a Spam specific reason. |
| 99 | The exception argument is a string describing the reason of the |
| 100 | failure. |
| 101 | \end{excdesc} |
| 102 | |
Fred Drake | 07bcd99 | 1998-04-03 21:25:16 +0000 | [diff] [blame] | 103 | % ---- 3.4. ---- |
| 104 | % Other standard environments: |
| 105 | % |
| 106 | % classdesc - Python classes; same arguments are funcdesc |
| 107 | % methoddesc - methods, like funcdesc but has an optional parameter |
| 108 | % to give the type name: \begin{methoddesc}[mytype]{name}{args} |
| 109 | % By default, the type name will be the name of the |
| 110 | % last class defined using classdesc. The type name |
| 111 | % is required if the type is implemented in C (because |
| 112 | % there's no classdesc) or if the class isn't directly |
| 113 | % documented (if it's private). |
| 114 | % memberdesc - data members, like datadesc, but with an optional |
| 115 | % type name like methoddesc. |
Guido van Rossum | 6a11eb4 | 1992-06-03 17:59:07 +0000 | [diff] [blame] | 116 | |
| 117 | |
Guido van Rossum | 51bbdfb | 1995-03-01 14:07:08 +0000 | [diff] [blame] | 118 | % ==== 4. ==== |
| 119 | % Now is probably a good time for a complete example. (Alternatively, |
| 120 | % an example giving the flavor of the module may be given before the |
| 121 | % detailed list of functions.) |
Guido van Rossum | 6a11eb4 | 1992-06-03 17:59:07 +0000 | [diff] [blame] | 122 | |
Guido van Rossum | 51bbdfb | 1995-03-01 14:07:08 +0000 | [diff] [blame] | 123 | Example: |
Guido van Rossum | 6a11eb4 | 1992-06-03 17:59:07 +0000 | [diff] [blame] | 124 | |
Fred Drake | 1947991 | 1998-02-13 06:58:54 +0000 | [diff] [blame] | 125 | \begin{verbatim} |
Guido van Rossum | 51bbdfb | 1995-03-01 14:07:08 +0000 | [diff] [blame] | 126 | >>> import spam |
| 127 | >>> can = spam.open('/etc/passwd') |
| 128 | >>> can.empty() |
| 129 | >>> can.close() |
Fred Drake | 1947991 | 1998-02-13 06:58:54 +0000 | [diff] [blame] | 130 | \end{verbatim} |
Fred Drake | 07bcd99 | 1998-04-03 21:25:16 +0000 | [diff] [blame] | 131 | % Note that there is no trailing ">>> " prompt shown. |
| 132 | |
Guido van Rossum | 51bbdfb | 1995-03-01 14:07:08 +0000 | [diff] [blame] | 133 | % ==== 5. ==== |
| 134 | % If your module defines new object types (for a built-in module) or |
| 135 | % classes (for a module written in Python), you should list the |
| 136 | % 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] | 137 | % separate subsection. |
Guido van Rossum | 51bbdfb | 1995-03-01 14:07:08 +0000 | [diff] [blame] | 138 | |
Guido van Rossum | 470be14 | 1995-03-17 16:07:09 +0000 | [diff] [blame] | 139 | \subsection{Spam Objects} |
Fred Drake | 07bcd99 | 1998-04-03 21:25:16 +0000 | [diff] [blame] | 140 | \label{spam-objects} |
| 141 | % This label is generally useful for referencing this section, but is |
| 142 | % also used to give a filename when generating HTML. |
Guido van Rossum | 51bbdfb | 1995-03-01 14:07:08 +0000 | [diff] [blame] | 143 | |
Fred Drake | 07bcd99 | 1998-04-03 21:25:16 +0000 | [diff] [blame] | 144 | Spam objects, as returned by \function{open()} above, have the |
| 145 | following methods: |
Guido van Rossum | 51bbdfb | 1995-03-01 14:07:08 +0000 | [diff] [blame] | 146 | |
Fred Drake | 07bcd99 | 1998-04-03 21:25:16 +0000 | [diff] [blame] | 147 | \begin{methoddesc}[spam]{empty}{} |
Guido van Rossum | 51bbdfb | 1995-03-01 14:07:08 +0000 | [diff] [blame] | 148 | Empty the can into the trash. |
Fred Drake | 07bcd99 | 1998-04-03 21:25:16 +0000 | [diff] [blame] | 149 | \end{methoddesc} |