blob: 9a266f5505eab7ea287beb1e8b83e2043db9b1c4 [file] [log] [blame]
Fred Drakeacffaee1999-03-16 16:09:13 +00001\documentclass{howto}
2\usepackage{ltxmarkup}
3
4\title{Documenting Python}
5
Skip Montanaro176bda4cd2002-04-19 04:50:44 +00006\makeindex
7
Fred Drakeacffaee1999-03-16 16:09:13 +00008\input{boilerplate}
9
Fred Drakec7c9a641999-04-28 18:24:02 +000010% Now override the stuff that includes author information;
11% Guido did *not* write this one!
Fred Drakeacffaee1999-03-16 16:09:13 +000012
13\author{Fred L. Drake, Jr.}
14\authoraddress{
Fred Drakee7f343d2003-07-11 03:36:15 +000015 PythonLabs \\
16 Email: \email{fdrake@acm.org}
Fred Drakeacffaee1999-03-16 16:09:13 +000017}
Fred Drakeacffaee1999-03-16 16:09:13 +000018
19
20\begin{document}
21
22\maketitle
23
24\begin{abstract}
25\noindent
Fred Drake02997492000-09-21 05:26:43 +000026The Python language has a substantial body of
Fred Drakeacffaee1999-03-16 16:09:13 +000027documentation, much of it contributed by various authors. The markup
28used for the Python documentation is based on \LaTeX{} and requires a
29significant set of macros written specifically for documenting Python.
Fred Drake5eb992b1999-06-11 14:25:45 +000030This document describes the macros introduced to support Python
31documentation and how they should be used to support a wide range of
32output formats.
Fred Drakeacffaee1999-03-16 16:09:13 +000033
34This document describes the document classes and special markup used
35in the Python documentation. Authors may use this guide, in
36conjunction with the template files provided with the
37distribution, to create or maintain whole documents or sections.
Fred Drake8aebe192004-11-05 04:23:25 +000038
39If you're interested in contributing to Python's documentation,
40there's no need to learn \LaTeX{} if you're not so inclined; plain
41text contributions are more than welcome as well.
Fred Drakeacffaee1999-03-16 16:09:13 +000042\end{abstract}
43
44\tableofcontents
45
46
Fred Drakef1b3de82001-07-24 14:38:34 +000047\section{Introduction \label{intro}}
Fred Drakeacffaee1999-03-16 16:09:13 +000048
49 Python's documentation has long been considered to be good for a
50 free programming language. There are a number of reasons for this,
51 the most important being the early commitment of Python's creator,
52 Guido van Rossum, to providing documentation on the language and its
53 libraries, and the continuing involvement of the user community in
54 providing assistance for creating and maintaining documentation.
55
56 The involvement of the community takes many forms, from authoring to
Fred Drake7a737df1999-04-23 14:41:44 +000057 bug reports to just plain complaining when the documentation could
58 be more complete or easier to use. All of these forms of input from
59 the community have proved useful during the time I've been involved
60 in maintaining the documentation.
Fred Drakeacffaee1999-03-16 16:09:13 +000061
Fred Drake2c4e0091999-03-29 14:55:55 +000062 This document is aimed at authors and potential authors of
Fred Drake7a737df1999-04-23 14:41:44 +000063 documentation for Python. More specifically, it is for people
64 contributing to the standard documentation and developing additional
65 documents using the same tools as the standard documents. This
66 guide will be less useful for authors using the Python documentation
67 tools for topics other than Python, and less useful still for
68 authors not using the tools at all.
Fred Drakeacffaee1999-03-16 16:09:13 +000069
Fred Drake2c4e0091999-03-29 14:55:55 +000070 The material in this guide is intended to assist authors using the
71 Python documentation tools. It includes information on the source
72 distribution of the standard documentation, a discussion of the
Fred Drake7a737df1999-04-23 14:41:44 +000073 document types, reference material on the markup defined in the
74 document classes, a list of the external tools needed for processing
Fred Drake2c4e0091999-03-29 14:55:55 +000075 documents, and reference material on the tools provided with the
76 documentation resources. At the end, there is also a section
Fred Drake7a737df1999-04-23 14:41:44 +000077 discussing future directions for the Python documentation and where
78 to turn for more information.
Fred Drakeacffaee1999-03-16 16:09:13 +000079
Fred Drake8aebe192004-11-05 04:23:25 +000080 If your interest is in contributing to the Python documentation, but
81 you don't have the time or inclination to learn \LaTeX{} and the
82 markup structures documented here, there's a welcoming place for you
83 among the Python contributors as well. Any time you feel that you
84 can clarify existing documentation or provide documentation that's
85 missing, the existing documentation team will gladly work with you
86 to integrate your text, dealing with the markup for you. Please
87 don't let the material in this document stand between the
88 documentation and your desire to help out!
89
Fred Drakef1b3de82001-07-24 14:38:34 +000090\section{Directory Structure \label{directories}}
Fred Drakeacffaee1999-03-16 16:09:13 +000091
92 The source distribution for the standard Python documentation
93 contains a large number of directories. While third-party documents
94 do not need to be placed into this structure or need to be placed
95 within a similar structure, it can be helpful to know where to look
96 for examples and tools when developing new documents using the
97 Python documentation tools. This section describes this directory
98 structure.
99
100 The documentation sources are usually placed within the Python
Fred Drake7a737df1999-04-23 14:41:44 +0000101 source distribution as the top-level directory \file{Doc/}, but
102 are not dependent on the Python source distribution in any way.
Fred Drakeacffaee1999-03-16 16:09:13 +0000103
104 The \file{Doc/} directory contains a few files and several
105 subdirectories. The files are mostly self-explanatory, including a
106 \file{README} and a \file{Makefile}. The directories fall into
107 three categories:
108
109 \begin{definitions}
110 \term{Document Sources}
Fred Drakee7f343d2003-07-11 03:36:15 +0000111 The \LaTeX{} sources for each document are placed in a
112 separate directory. These directories are given short
113 names which vaguely indicate the document in each:
Fred Drake2f4bebd1999-04-28 16:43:11 +0000114
Fred Drakee7f343d2003-07-11 03:36:15 +0000115 \begin{tableii}{p{.75in}|p{3in}}{filenq}{Directory}{Document Title}
116 \lineii{api/}
Fred Drake31edf4d2000-09-07 20:06:07 +0000117 {\citetitle[../api/api.html]{The Python/C API}}
Fred Drakee7f343d2003-07-11 03:36:15 +0000118 \lineii{dist/}
Fred Drake31edf4d2000-09-07 20:06:07 +0000119 {\citetitle[../dist/dist.html]{Distributing Python Modules}}
Fred Drakee7f343d2003-07-11 03:36:15 +0000120 \lineii{doc/}
Fred Drake31edf4d2000-09-07 20:06:07 +0000121 {\citetitle[../doc/doc.html]{Documenting Python}}
Fred Drakee7f343d2003-07-11 03:36:15 +0000122 \lineii{ext/}
Fred Drake31edf4d2000-09-07 20:06:07 +0000123 {\citetitle[../ext/ext.html]{Extending and Embedding the Python Interpreter}}
Fred Drakee7f343d2003-07-11 03:36:15 +0000124 \lineii{inst/}
Fred Drake31edf4d2000-09-07 20:06:07 +0000125 {\citetitle[../inst/inst.html]{Installing Python Modules}}
Fred Drakee7f343d2003-07-11 03:36:15 +0000126 \lineii{lib/}
Fred Drake31edf4d2000-09-07 20:06:07 +0000127 {\citetitle[../lib/lib.html]{Python Library Reference}}
Fred Drakee7f343d2003-07-11 03:36:15 +0000128 \lineii{mac/}
Fred Drake31edf4d2000-09-07 20:06:07 +0000129 {\citetitle[../mac/mac.html]{Macintosh Module Reference}}
Fred Drakee7f343d2003-07-11 03:36:15 +0000130 \lineii{ref/}
Fred Drake31edf4d2000-09-07 20:06:07 +0000131 {\citetitle[../ref/ref.html]{Python Reference Manual}}
Fred Drakee7f343d2003-07-11 03:36:15 +0000132 \lineii{tut/}
Fred Drake31edf4d2000-09-07 20:06:07 +0000133 {\citetitle[../tut/tut.html]{Python Tutorial}}
Fred Drakee7f343d2003-07-11 03:36:15 +0000134 \end{tableii}
Fred Drakeacffaee1999-03-16 16:09:13 +0000135
136 \term{Format-Specific Output}
Fred Drakee7f343d2003-07-11 03:36:15 +0000137 Most output formats have a directory which contains a
138 \file{Makefile} which controls the generation of that format
139 and provides storage for the formatted documents. The only
140 variations within this category are the Portable Document
Fred Drake2c4e0091999-03-29 14:55:55 +0000141 Format (PDF) and PostScript versions are placed in the
Fred Drakee7f343d2003-07-11 03:36:15 +0000142 directories \file{paper-a4/} and \file{paper-letter/} (this
143 causes all the temporary files created by \LaTeX{} to be kept
144 in the same place for each paper size, where they can be more
145 easily ignored).
Fred Drakeacffaee1999-03-16 16:09:13 +0000146
Fred Drakee7f343d2003-07-11 03:36:15 +0000147 \begin{tableii}{p{.75in}|p{3in}}{filenq}{Directory}{Output Formats}
148 \lineii{html/}{HTML output}
149 \lineii{info/}{GNU info output}
150 \lineii{isilo/}{\ulink{iSilo}{http://www.isilo.com/}
151 documents (for Palm OS devices)}
152 \lineii{paper-a4/}{PDF and PostScript, A4 paper}
153 \lineii{paper-letter/}{PDF and PostScript, US-Letter paper}
154 \end{tableii}
Fred Drake2f4bebd1999-04-28 16:43:11 +0000155
Fred Drakeacffaee1999-03-16 16:09:13 +0000156 \term{Supplemental Files}
Fred Drakee7f343d2003-07-11 03:36:15 +0000157 Some additional directories are used to store supplemental
158 files used for the various processes. Directories are
159 included for the shared \LaTeX{} document classes, the
160 \LaTeX2HTML support, template files for various document
161 components, and the scripts used to perform various steps in
162 the formatting processes.
Fred Drake2f4bebd1999-04-28 16:43:11 +0000163
Fred Drakee7f343d2003-07-11 03:36:15 +0000164 \begin{tableii}{p{.75in}|p{3in}}{filenq}{Directory}{Contents}
Fred Drake2bc9b2f2003-09-27 07:18:52 +0000165 \lineii{commontex/}{Document content shared among documents}
166 \lineii{perl/} {Support for \LaTeX2HTML processing}
Fred Drakee7f343d2003-07-11 03:36:15 +0000167 \lineii{templates/}{Example files for source documents}
168 \lineii{texinputs/}{Style implementation for \LaTeX}
Fred Drake2bc9b2f2003-09-27 07:18:52 +0000169 \lineii{tools/} {Custom processing scripts}
Fred Drakee7f343d2003-07-11 03:36:15 +0000170 \end{tableii}
Fred Drake2f4bebd1999-04-28 16:43:11 +0000171
Fred Drakeacffaee1999-03-16 16:09:13 +0000172 \end{definitions}
173
Fred Drake2c4e0091999-03-29 14:55:55 +0000174
Fred Drakef1b3de82001-07-24 14:38:34 +0000175\section{Style Guide \label{style-guide}}
Fred Drake432cef02001-07-06 22:34:33 +0000176
177 The Python documentation should follow the \citetitle
Fred Drake192b95b2003-07-11 03:34:17 +0000178 [http://developer.apple.com/documentation/UserExperience/Conceptual/APStyleGuide/AppleStyleGuide2003.pdf]
Fred Drake432cef02001-07-06 22:34:33 +0000179 {Apple Publications Style Guide} wherever possible. This particular
180 style guide was selected mostly because it seems reasonable and is
Fred Drake192b95b2003-07-11 03:34:17 +0000181 easy to get online.
Fred Drake432cef02001-07-06 22:34:33 +0000182
183 Topics which are not covered in the Apple's style guide will be
184 discussed in this document if necessary.
185
186 Many special names are used in the Python documentation, including
187 the names of operating systems, programming languages, standards
188 bodies, and the like. Many of these were assigned \LaTeX{} macros
189 at some point in the distant past, and these macros lived on long
Fred Drake9120df32001-07-14 02:34:12 +0000190 past their usefulness. In the current markup, most of these entities
191 are not assigned any special markup, but the preferred spellings are
Fred Drake432cef02001-07-06 22:34:33 +0000192 given here to aid authors in maintaining the consistency of
193 presentation in the Python documentation.
194
Fred Drake9120df32001-07-14 02:34:12 +0000195 Other terms and words deserve special mention as well; these conventions
196 should be used to ensure consistency throughout the documentation:
197
Fred Drake432cef02001-07-06 22:34:33 +0000198 \begin{description}
Fred Drake9120df32001-07-14 02:34:12 +0000199 \item[CPU]
200 For ``central processing unit.'' Many style guides say this
201 should be spelled out on the first use (and if you must use it,
202 do so!). For the Python documentation, this abbreviation should
203 be avoided since there's no reasonable way to predict which occurance
204 will be the first seen by the reader. It is better to use the
205 word ``processor'' instead.
206
207 \item[\POSIX]
Fred Drakee7f343d2003-07-11 03:36:15 +0000208 The name assigned to a particular group of standards. This is
209 always uppercase. Use the macro \macro{POSIX} to represent this
210 name.
Fred Drake432cef02001-07-06 22:34:33 +0000211
212 \item[Python]
Fred Drakee7f343d2003-07-11 03:36:15 +0000213 The name of our favorite programming language is always
214 capitalized.
Fred Drake432cef02001-07-06 22:34:33 +0000215
216 \item[Unicode]
Fred Drakee7f343d2003-07-11 03:36:15 +0000217 The name of a character set and matching encoding. This is
218 always written capitalized.
Fred Drake9120df32001-07-14 02:34:12 +0000219
220 \item[\UNIX]
Fred Drakee7f343d2003-07-11 03:36:15 +0000221 The name of the operating system developed at AT\&T Bell Labs
222 in the early 1970s. Use the macro \macro{UNIX} to use this
223 name.
Fred Drake432cef02001-07-06 22:34:33 +0000224 \end{description}
225
226
Fred Drakeadade921999-04-22 13:05:27 +0000227\section{\LaTeX{} Primer \label{latex-primer}}
Fred Drake2c4e0091999-03-29 14:55:55 +0000228
Fred Drakeadade921999-04-22 13:05:27 +0000229 This section is a brief introduction to \LaTeX{} concepts and
230 syntax, to provide authors enough information to author documents
Fred Drake20a175a2004-10-18 21:30:40 +0000231 productively without having to become ``\TeX{}nicians.'' This does
232 not teach everything needed to know about writing \LaTeX{} for
233 Python documentation; many of the standard ``environments'' are not
234 described here (though you will learn how to mark something as an
235 environment).
Fred Drakeadade921999-04-22 13:05:27 +0000236
Fred Drake5eb992b1999-06-11 14:25:45 +0000237 Perhaps the most important concept to keep in mind while marking up
Fred Drake02997492000-09-21 05:26:43 +0000238 Python documentation is that while \TeX{} is unstructured, \LaTeX{} was
Fred Drakee7f343d2003-07-11 03:36:15 +0000239 designed as a layer on top of \TeX{} which specifically supports
Fred Drake5eb992b1999-06-11 14:25:45 +0000240 structured markup. The Python-specific markup is intended to extend
241 the structure provided by standard \LaTeX{} document classes to
242 support additional information specific to Python.
243
Fred Drakeadade921999-04-22 13:05:27 +0000244 \LaTeX{} documents contain two parts: the preamble and the body.
245 The preamble is used to specify certain metadata about the document
246 itself, such as the title, the list of authors, the date, and the
247 \emph{class} the document belongs to. Additional information used
248 to control index generation and the use of bibliographic databases
Fred Drake7a737df1999-04-23 14:41:44 +0000249 can also be placed in the preamble. For most authors, the preamble
Fred Drakeadade921999-04-22 13:05:27 +0000250 can be most easily created by copying it from an existing document
251 and modifying a few key pieces of information.
252
253 The \dfn{class} of a document is used to place a document within a
254 broad category of documents and set some fundamental formatting
255 properties. For Python documentation, two classes are used: the
256 \code{manual} class and the \code{howto} class. These classes also
257 define the additional markup used to document Python concepts and
258 structures. Specific information about these classes is provided in
Fred Drake7a737df1999-04-23 14:41:44 +0000259 section \ref{classes}, ``Document Classes,'' below. The first thing
Fred Drakeadade921999-04-22 13:05:27 +0000260 in the preamble is the declaration of the document's class.
261
262 After the class declaration, a number of \emph{macros} are used to
263 provide further information about the document and setup any
Fred Drake7a737df1999-04-23 14:41:44 +0000264 additional markup that is needed. No output is generated from the
265 preamble; it is an error to include free text in the preamble
266 because it would cause output.
Fred Drakeadade921999-04-22 13:05:27 +0000267
268 The document body follows the preamble. This contains all the
Fred Drake63568aa2000-10-19 05:36:10 +0000269 printed components of the document marked up structurally. Generic
Fred Drake4c6f17a2001-04-18 05:12:47 +0000270 \LaTeX{} structures include hierarchical sections, numbered and
271 bulleted lists, and special structures for the document abstract and
272 indexes.
Fred Drakeadade921999-04-22 13:05:27 +0000273
Fred Drakef1b3de82001-07-24 14:38:34 +0000274 \subsection{Syntax \label{latex-syntax}}
Fred Drake63568aa2000-10-19 05:36:10 +0000275
Fred Drake4c6f17a2001-04-18 05:12:47 +0000276 There are some things that an author of Python documentation needs
277 to know about \LaTeX{} syntax.
Fred Drake63568aa2000-10-19 05:36:10 +0000278
279 A \dfn{comment} is started by the ``percent'' character
280 (\character{\%}) and continues through the end of the line and all
281 leading whitespace on the following line. This is a little
282 different from any programming language I know of, so an example
283 is in order:
284
285\begin{verbatim}
286This is text.% comment
287 This is more text. % another comment
288Still more text.
289\end{verbatim}
290
291 The first non-comment character following the first comment is the
292 letter \character{T} on the second line; the leading whitespace on
293 that line is consumed as part of the first comment. This means
294 that there is no space between the first and second sentences, so
295 the period and letter \character{T} will be directly adjacent in
296 the typeset document.
297
298 Note also that though the first non-comment character after the
299 second comment is the letter \character{S}, there is whitespace
300 preceding the comment, so the two sentences are separated as
301 expected.
302
303 A \dfn{group} is an enclosure for a collection of text and
304 commands which encloses the formatting context and constrains the
305 scope of any changes to that context made by commands within the
306 group. Groups can be nested hierarchically. The formatting
307 context includes the font and the definition of additional macros
308 (or overrides of macros defined in outer groups). Syntactically,
309 groups are enclosed in braces:
310
311\begin{verbatim}
312{text in a group}
313\end{verbatim}
314
Fred Drake4c6f17a2001-04-18 05:12:47 +0000315 An alternate syntax for a group using brackets, \code{[...]}, is
Fred Drake63568aa2000-10-19 05:36:10 +0000316 used by macros and environment constructors which take optional
317 parameters; brackets do not normally hold syntactic significance.
318 A degenerate group, containing only one atomic bit of content,
319 does not need to have an explicit group, unless it is required to
320 avoid ambiguity. Since Python tends toward the explicit, groups
321 are also made explicit in the documentation markup.
322
323 Groups are used only sparingly in the Python documentation, except
324 for their use in marking parameters to macros and environments.
325
Fred Drake4c6f17a2001-04-18 05:12:47 +0000326 A \dfn{macro} is usually a simple construct which is identified by
Fred Drake63568aa2000-10-19 05:36:10 +0000327 name and can take some number of parameters. In normal \LaTeX{}
328 usage, one of these can be optional. The markup is introduced
329 using the backslash character (\character{\e}), and the name is
330 given by alphabetic characters (no digits, hyphens, or
331 underscores). Required parameters should be marked as a group,
332 and optional parameters should be marked using the alternate
333 syntax for a group.
334
Neal Norwitz750f0602004-08-01 22:36:40 +0000335 For example, a macro which takes a single parameter
Fred Drake63568aa2000-10-19 05:36:10 +0000336 would appear like this:
337
338\begin{verbatim}
339\name{parameter}
340\end{verbatim}
341
342 A macro which takes an optional parameter would be typed like this
Raymond Hettinger5232f502004-03-25 08:51:36 +0000343 when the optional parameter is given:
Fred Drake63568aa2000-10-19 05:36:10 +0000344
345\begin{verbatim}
346\name[optional]
347\end{verbatim}
348
349 If both optional and required parameters are to be required, it
350 looks like this:
351
352\begin{verbatim}
353\name[optional]{required}
354\end{verbatim}
355
356 A macro name may be followed by a space or newline; a space
357 between the macro name and any parameters will be consumed, but
358 this usage is not practiced in the Python documentation. Such a
Fred Drake4c6f17a2001-04-18 05:12:47 +0000359 space is still consumed if there are no parameters to the macro,
Fred Drake63568aa2000-10-19 05:36:10 +0000360 in which case inserting an empty group (\code{\{\}}) or explicit
361 word space (\samp{\e\ }) immediately after the macro name helps to
362 avoid running the expansion of the macro into the following text.
363 Macros which take no parameters but which should not be followed
364 by a word space do not need special treatment if the following
365 character in the document source if not a name character (such as
Fred Drake4c6f17a2001-04-18 05:12:47 +0000366 punctuation).
Fred Drake63568aa2000-10-19 05:36:10 +0000367
368 Each line of this example shows an appropriate way to write text
369 which includes a macro which takes no parameters:
370
371\begin{verbatim}
372This \UNIX{} is followed by a space.
373This \UNIX\ is also followed by a space.
374\UNIX, followed by a comma, needs no additional markup.
375\end{verbatim}
376
Fred Draked097d482000-10-20 20:51:31 +0000377 An \dfn{environment} is a larger construct than a macro, and can
Fred Drake4c6f17a2001-04-18 05:12:47 +0000378 be used for things with more content than would conveniently fit
Fred Draked097d482000-10-20 20:51:31 +0000379 in a macro parameter. They are primarily used when formatting
380 parameters need to be changed before and after a large chunk of
381 content, but the content itself needs to be highly flexible. Code
382 samples are presented using an environment, and descriptions of
Fred Drake4c6f17a2001-04-18 05:12:47 +0000383 functions, methods, and classes are also marked using environments.
Fred Draked097d482000-10-20 20:51:31 +0000384
385 Since the content of an environment is free-form and can consist
386 of several paragraphs, they are actually marked using a pair of
387 macros: \macro{begin} and \macro{end}. These macros both take the
388 name of the environment as a parameter. An example is the
389 environment used to mark the abstract of a document:
390
391\begin{verbatim}
392\begin{abstract}
393 This is the text of the abstract. It concisely explains what
394 information is found in the document.
395
396 It can consist of multiple paragraphs.
397\end{abstract}
398\end{verbatim}
399
400 An environment can also have required and optional parameters of
401 its own. These follow the parameter of the \macro{begin} macro.
402 This example shows an environment which takes a single required
403 parameter:
404
405\begin{verbatim}
Fred Drake2bbc6972001-03-28 16:51:20 +0000406\begin{datadesc}{controlnames}
Fred Draked097d482000-10-20 20:51:31 +0000407 A 33-element string array that contains the \ASCII{} mnemonics for
408 the thirty-two \ASCII{} control characters from 0 (NUL) to 0x1f
409 (US), in order, plus the mnemonic \samp{SP} for the space character.
410\end{datadesc}
411\end{verbatim}
Fred Drake63568aa2000-10-19 05:36:10 +0000412
Fred Drake4c6f17a2001-04-18 05:12:47 +0000413 There are a number of less-used marks in \LaTeX{} which are used
Fred Drakee789ea12002-03-13 02:48:24 +0000414 to enter characters which are not found in \ASCII{} or which a
415 considered special, or \emph{active} in \TeX{} or \LaTeX. Given
416 that these are often used adjacent to other characters, the markup
417 required to produce the proper character may need to be followed
418 by a space or an empty group, or the markup can be enclosed in a
419 group. Some which are found in Python documentation are:
Fred Drake63568aa2000-10-19 05:36:10 +0000420
Fred Draked097d482000-10-20 20:51:31 +0000421\begin{tableii}{c|l}{textrm}{Character}{Markup}
Fred Drakee789ea12002-03-13 02:48:24 +0000422 \lineii{\textasciicircum}{\code{\e textasciicircum}}
423 \lineii{\textasciitilde}{\code{\e textasciitilde}}
424 \lineii{\textgreater}{\code{\e textgreater}}
425 \lineii{\textless}{\code{\e textless}}
Fred Draked097d482000-10-20 20:51:31 +0000426 \lineii{\c c}{\code{\e c c}}
427 \lineii{\"o}{\code{\e"o}}
428 \lineii{\o}{\code{\e o}}
429\end{tableii}
Fred Drake63568aa2000-10-19 05:36:10 +0000430
431
Skip Montanaro176bda4cd2002-04-19 04:50:44 +0000432 \subsection{Hierarchical Structure \label{latex-structure}}
Fred Drake63568aa2000-10-19 05:36:10 +0000433
Fred Draked097d482000-10-20 20:51:31 +0000434 \LaTeX{} expects documents to be arranged in a conventional,
435 hierarchical way, with chapters, sections, sub-sections,
436 appendixes, and the like. These are marked using macros rather
437 than environments, probably because the end of a section can be
438 safely inferred when a section of equal or higher level starts.
439
440 There are six ``levels'' of sectioning in the document classes
Fred Drake4c6f17a2001-04-18 05:12:47 +0000441 used for Python documentation, and the deepest two
442 levels\footnote{The deepest levels have the highest numbers in the
443 table.} are not used. The levels are:
Fred Draked097d482000-10-20 20:51:31 +0000444
445 \begin{tableiii}{c|l|c}{textrm}{Level}{Macro Name}{Notes}
446 \lineiii{1}{\macro{chapter}}{(1)}
447 \lineiii{2}{\macro{section}}{}
448 \lineiii{3}{\macro{subsection}}{}
Fred Drakeb7a52c92000-11-27 20:10:18 +0000449 \lineiii{4}{\macro{subsubsection}}{}
Fred Draked097d482000-10-20 20:51:31 +0000450 \lineiii{5}{\macro{paragraph}}{(2)}
451 \lineiii{6}{\macro{subparagraph}}{}
452 \end{tableiii}
453
454 \noindent
455 Notes:
456
457 \begin{description}
458 \item[(1)]
459 Only used for the \code{manual} documents, as described in
460 section \ref{classes}, ``Document Classes.''
461 \item[(2)]
462 Not the same as a paragraph of text; nobody seems to use this.
463 \end{description}
Fred Drake2c4e0091999-03-29 14:55:55 +0000464
465
Fred Drake20a175a2004-10-18 21:30:40 +0000466 \subsection{Common Environments \label{latex-environments}}
467
468 \LaTeX{} provides a variety of environments even without the
469 additional markup provided by the Python-specific document classes
470 introducted in the next section. The following environments are
471 provided as part of standard \LaTeX{} and are being used in the
472 standard Python documentation; descriptions will be added here as
473 time allows.
474
475\begin{verbatim}
476abstract
477alltt
478description
479displaymath
480document
481enumerate
482figure
483flushleft
484itemize
485list
486math
487quotation
488quote
489sloppypar
490verbatim
491\end{verbatim}
492
493
Fred Drakeadade921999-04-22 13:05:27 +0000494\section{Document Classes \label{classes}}
Fred Drakeacffaee1999-03-16 16:09:13 +0000495
496 Two \LaTeX{} document classes are defined specifically for use with
497 the Python documentation. The \code{manual} class is for large
498 documents which are sectioned into chapters, and the \code{howto}
499 class is for smaller documents.
500
501 The \code{manual} documents are larger and are used for most of the
502 standard documents. This document class is based on the standard
503 \LaTeX{} \code{report} class and is formatted very much like a long
Fred Drake698d5201999-11-10 15:54:57 +0000504 technical report. The \citetitle[../ref/ref.html]{Python Reference
505 Manual} is a good example of a \code{manual} document, and the
506 \citetitle[../lib/lib.html]{Python Library Reference} is a large
507 example.
Fred Drakeacffaee1999-03-16 16:09:13 +0000508
509 The \code{howto} documents are shorter, and don't have the large
510 structure of the \code{manual} documents. This class is based on
511 the standard \LaTeX{} \code{article} class and is formatted somewhat
512 like the Linux Documentation Project's ``HOWTO'' series as done
513 originally using the LinuxDoc software. The original intent for the
514 document class was that it serve a similar role as the LDP's HOWTO
515 series, but the applicability of the class turns out to be somewhat
Fred Drake02997492000-09-21 05:26:43 +0000516 broader. This class is used for ``how-to'' documents (this
Fred Drakeacffaee1999-03-16 16:09:13 +0000517 document is an example) and for shorter reference manuals for small,
518 fairly cohesive module libraries. Examples of the later use include
Fred Drake6a547c72000-09-15 22:11:24 +0000519\citetitle[http://starship.python.net/crew/fdrake/manuals/krb5py/krb5py.html]{Using
Fred Drakeacffaee1999-03-16 16:09:13 +0000520 Kerberos from Python}, which contains reference material for an
521 extension package. These documents are roughly equivalent to a
522 single chapter from a larger work.
523
524
Fred Drakef1b3de82001-07-24 14:38:34 +0000525\section{Special Markup Constructs \label{special-constructs}}
Fred Drakeacffaee1999-03-16 16:09:13 +0000526
Fred Drake2c4e0091999-03-29 14:55:55 +0000527 The Python document classes define a lot of new environments and
528 macros. This section contains the reference material for these
Fred Drake20a175a2004-10-18 21:30:40 +0000529 facilities. Documentation for ``standard'' \LaTeX{} constructs is
530 not included here, though they are used in the Python documentation.
Fred Drake2c4e0091999-03-29 14:55:55 +0000531
Fred Drakeaf2b7142000-09-14 20:11:05 +0000532 \subsection{Markup for the Preamble \label{preamble-info}}
533
534 \begin{macrodesc}{release}{\p{ver}}
535 Set the version number for the software described in the
536 document.
537 \end{macrodesc}
538
539 \begin{macrodesc}{setshortversion}{\p{sver}}
540 Specify the ``short'' version number of the documented software
541 to be \var{sver}.
542 \end{macrodesc}
543
Fred Drakee15956b2000-04-03 04:51:13 +0000544 \subsection{Meta-information Markup \label{meta-info}}
545
546 \begin{macrodesc}{sectionauthor}{\p{author}\p{email}}
547 Identifies the author of the current section. \var{author}
548 should be the author's name such that it can be used for
549 presentation (though it isn't), and \var{email} should be the
550 author's email address. The domain name portion of
551 the address should be lower case.
552
Fred Drakee7f343d2003-07-11 03:36:15 +0000553 No presentation is generated from this markup, but it is used to
Fred Drakee15956b2000-04-03 04:51:13 +0000554 help keep track of contributions.
555 \end{macrodesc}
556
Fred Drakeacffaee1999-03-16 16:09:13 +0000557 \subsection{Information Units \label{info-units}}
558
Fred Drake2f4bebd1999-04-28 16:43:11 +0000559 XXX Explain terminology, or come up with something more ``lay.''
Fred Drakeacffaee1999-03-16 16:09:13 +0000560
Fred Drakeadade921999-04-22 13:05:27 +0000561 There are a number of environments used to describe specific
562 features provided by modules. Each environment requires
563 parameters needed to provide basic information about what is being
564 described, and the environment content should be the description.
565 Most of these environments make entries in the general index (if
566 one is being produced for the document); if no index entry is
567 desired, non-indexing variants are available for many of these
568 environments. The environments have names of the form
569 \code{\var{feature}desc}, and the non-indexing variants are named
570 \code{\var{feature}descni}. The available variants are explicitly
571 included in the list below.
572
573 For each of these environments, the first parameter, \var{name},
574 provides the name by which the feature is accessed.
575
576 Environments which describe features of objects within a module,
577 such as object methods or data attributes, allow an optional
578 \var{type name} parameter. When the feature is an attribute of
579 class instances, \var{type name} only needs to be given if the
580 class was not the most recently described class in the module; the
581 \var{name} value from the most recent \env{classdesc} is implied.
582 For features of built-in or extension types, the \var{type name}
Fred Drake7a737df1999-04-23 14:41:44 +0000583 value should always be provided. Another special case includes
584 methods and members of general ``protocols,'' such as the
585 formatter and writer protocols described for the
586 \module{formatter} module: these may be documented without any
587 specific implementation classes, and will always require the
588 \var{type name} parameter to be provided.
Fred Drakeadade921999-04-22 13:05:27 +0000589
Fred Drake7be440d2000-09-16 21:23:25 +0000590 \begin{envdesc}{cfuncdesc}{\p{type}\p{name}\p{args}}
591 Environment used to described a C function. The \var{type}
592 should be specified as a \keyword{typedef} name, \code{struct
593 \var{tag}}, or the name of a primitive type. If it is a pointer
Fred Drake02997492000-09-21 05:26:43 +0000594 type, the trailing asterisk should not be preceded by a space.
Fred Drake7be440d2000-09-16 21:23:25 +0000595 \var{name} should be the name of the function (or function-like
596 pre-processor macro), and \var{args} should give the types and
597 names of the parameters. The names need to be given so they may
598 be used in the description.
599 \end{envdesc}
600
Fred Drake1251b0e2002-04-15 20:10:23 +0000601 \begin{envdesc}{cmemberdesc}{\p{container}\p{type}\p{name}}
602 Description for a structure member. \var{container} should be
603 the \keyword{typedef} name, if there is one, otherwise if should
604 be \samp{struct \var{tag}}. The type of the member should given
605 as \var{type}, and the name should be given as \var{name}. The
606 text of the description should include the range of values
607 allowed, how the value should be interpreted, and whether the
608 value can be changed. References to structure members in text
609 should use the \macro{member} macro.
610 \end{envdesc}
611
Fred Drake79bf99c2002-04-09 20:17:42 +0000612 \begin{envdesc}{csimplemacrodesc}{\p{name}}
613 Documentation for a ``simple'' macro. Simple macros are macros
614 which are used for code expansion, but which do not take
615 arguments so cannot be described as functions. This is not to
616 be used for simple constant definitions. Examples of it's use
617 in the Python documentation include
618 \csimplemacro{PyObject_HEAD} and
619 \csimplemacro{Py_BEGIN_ALLOW_THREADS}.
620 \end{envdesc}
621
Fred Drake7be440d2000-09-16 21:23:25 +0000622 \begin{envdesc}{ctypedesc}{\op{tag}\p{name}}
623 Environment used to described a C type. The \var{name}
624 parameter should be the \keyword{typedef} name. If the type is
625 defined as a \keyword{struct} without a \keyword{typedef},
626 \var{name} should have the form \code{struct \var{tag}}.
627 \var{name} will be added to the index unless \var{tag} is
628 provided, in which case \var{tag} will be used instead.
629 \var{tag} should not be used for a \keyword{typedef} name.
630 \end{envdesc}
631
632 \begin{envdesc}{cvardesc}{\p{type}\p{name}}
633 Description of a global C variable. \var{type} should be the
634 \keyword{typedef} name, \code{struct \var{tag}}, or the name of
635 a primitive type. If variable has a pointer type, the trailing
Fred Drake02997492000-09-21 05:26:43 +0000636 asterisk should \emph{not} be preceded by a space.
Fred Drake7be440d2000-09-16 21:23:25 +0000637 \end{envdesc}
638
Fred Drakeadade921999-04-22 13:05:27 +0000639 \begin{envdesc}{datadesc}{\p{name}}
640 This environment is used to document global data in a module,
641 including both variables and values used as ``defined
642 constants.'' Class and object attributes are not documented
643 using this environment.
Fred Drakeacffaee1999-03-16 16:09:13 +0000644 \end{envdesc}
Fred Drake7a737df1999-04-23 14:41:44 +0000645 \begin{envdesc}{datadescni}{\p{name}}
Fred Drakeacffaee1999-03-16 16:09:13 +0000646 Like \env{datadesc}, but without creating any index entries.
647 \end{envdesc}
648
Fred Drake9f2376d2001-05-11 01:01:12 +0000649 \begin{envdesc}{excclassdesc}{\p{name}\p{constructor parameters}}
650 Descibe an exception defined by a class. \var{constructor
651 parameters} should not include the \var{self} parameter or
652 the parentheses used in the call syntax. To describe an
653 exception class without describing the parameters to its
654 constructor, use the \env{excdesc} environment.
655 \end{envdesc}
656
Fred Drakeadade921999-04-22 13:05:27 +0000657 \begin{envdesc}{excdesc}{\p{name}}
Neal Norwitz847207a2003-05-29 02:17:23 +0000658 Describe an exception. In the case of class exceptions, the
Fred Drake9f2376d2001-05-11 01:01:12 +0000659 constructor parameters are not described; use \env{excclassdesc}
660 to describe an exception class and its constructor.
Fred Drakeacffaee1999-03-16 16:09:13 +0000661 \end{envdesc}
662
Fred Drakeadade921999-04-22 13:05:27 +0000663 \begin{envdesc}{funcdesc}{\p{name}\p{parameters}}
664 Describe a module-level function. \var{parameters} should
665 not include the parentheses used in the call syntax. Object
666 methods are not documented using this environment. Bound object
667 methods placed in the module namespace as part of the public
668 interface of the module are documented using this, as they are
669 equivalent to normal functions for most purposes.
670
671 The description should include information about the parameters
672 required and how they are used (especially whether mutable
673 objects passed as parameters are modified), side effects, and
674 possible exceptions. A small example may be provided.
Fred Drakeacffaee1999-03-16 16:09:13 +0000675 \end{envdesc}
Fred Drakeadade921999-04-22 13:05:27 +0000676 \begin{envdesc}{funcdescni}{\p{name}\p{parameters}}
Fred Drakeacffaee1999-03-16 16:09:13 +0000677 Like \env{funcdesc}, but without creating any index entries.
678 \end{envdesc}
679
Fred Drakeadade921999-04-22 13:05:27 +0000680 \begin{envdesc}{classdesc}{\p{name}\p{constructor parameters}}
681 Describe a class and its constructor. \var{constructor
682 parameters} should not include the \var{self} parameter or
683 the parentheses used in the call syntax.
Fred Drakeacffaee1999-03-16 16:09:13 +0000684 \end{envdesc}
685
Fred Drake9f2376d2001-05-11 01:01:12 +0000686 \begin{envdesc}{classdesc*}{\p{name}}
687 Describe a class without describing the constructor. This can
688 be used to describe classes that are merely containers for
689 attributes or which should never be instantiated or subclassed
690 by user code.
691 \end{envdesc}
692
Fred Drakeadade921999-04-22 13:05:27 +0000693 \begin{envdesc}{memberdesc}{\op{type name}\p{name}}
694 Describe an object data attribute. The description should
695 include information about the type of the data to be expected
696 and whether it may be changed directly.
Fred Drakeacffaee1999-03-16 16:09:13 +0000697 \end{envdesc}
Fred Drakeadade921999-04-22 13:05:27 +0000698 \begin{envdesc}{memberdescni}{\op{type name}\p{name}}
Fred Drakeacffaee1999-03-16 16:09:13 +0000699 Like \env{memberdesc}, but without creating any index entries.
700 \end{envdesc}
701
Fred Drakeadade921999-04-22 13:05:27 +0000702 \begin{envdesc}{methoddesc}{\op{type name}\p{name}\p{parameters}}
703 Describe an object method. \var{parameters} should not include
704 the \var{self} parameter or the parentheses used in the call
705 syntax. The description should include similar information to
706 that described for \env{funcdesc}.
Fred Drakeacffaee1999-03-16 16:09:13 +0000707 \end{envdesc}
Fred Drakeadade921999-04-22 13:05:27 +0000708 \begin{envdesc}{methoddescni}{\op{type name}\p{name}\p{parameters}}
Fred Drakeacffaee1999-03-16 16:09:13 +0000709 Like \env{methoddesc}, but without creating any index entries.
710 \end{envdesc}
711
712
Fred Drakef1b3de82001-07-24 14:38:34 +0000713 \subsection{Showing Code Examples \label{showing-examples}}
Fred Drake5eb992b1999-06-11 14:25:45 +0000714
715 Examples of Python source code or interactive sessions are
716 represented as \env{verbatim} environments. This environment
717 is a standard part of \LaTeX{}. It is important to only use
718 spaces for indentation in code examples since \TeX{} drops tabs
719 instead of converting them to spaces.
720
721 Representing an interactive session requires including the prompts
722 and output along with the Python code. No special markup is
Fred Drake63568aa2000-10-19 05:36:10 +0000723 required for interactive sessions. After the last line of input
724 or output presented, there should not be an ``unused'' primary
725 prompt; this is an example of what \emph{not} to do:
726
727\begin{verbatim}
728>>> 1 + 1
7292
Fred Drakee7f343d2003-07-11 03:36:15 +0000730>>>
Fred Drake63568aa2000-10-19 05:36:10 +0000731\end{verbatim}
Fred Drake5eb992b1999-06-11 14:25:45 +0000732
733 Within the \env{verbatim} environment, characters special to
734 \LaTeX{} do not need to be specially marked in any way. The entire
735 example will be presented in a monospaced font; no attempt at
736 ``pretty-printing'' is made, as the environment must work for
Fred Drake63568aa2000-10-19 05:36:10 +0000737 non-Python code and non-code displays. There should be no blank
738 lines at the top or bottom of any \env{verbatim} display.
Fred Drake5eb992b1999-06-11 14:25:45 +0000739
Fred Drake66eed242001-06-18 14:59:58 +0000740 Longer displays of verbatim text may be included by storing the
741 example text in an external file containing only plain text. The
742 file may be included using the standard \macro{verbatiminput}
743 macro; this macro takes a single argument naming the file
744 containing the text. For example, to include the Python source
745 file \file{example.py}, use:
746
747\begin{verbatim}
748\verbatiminput{example.py}
749\end{verbatim}
750
751 Use of \macro{verbatiminput} allows easier use of special editing
752 modes for the included file. The file should be placed in the
753 same directory as the \LaTeX{} files for the document.
754
Fred Drake5eb992b1999-06-11 14:25:45 +0000755 The Python Documentation Special Interest Group has discussed a
756 number of approaches to creating pretty-printed code displays and
757 interactive sessions; see the Doc-SIG area on the Python Web site
758 for more information on this topic.
759
760
Fred Drakef1b3de82001-07-24 14:38:34 +0000761 \subsection{Inline Markup \label{inline-markup}}
Fred Drakeacffaee1999-03-16 16:09:13 +0000762
Fred Drake87f768e1999-05-17 15:22:45 +0000763 The macros described in this section are used to mark just about
764 anything interesting in the document text. They may be used in
765 headings (though anything involving hyperlinks should be avoided
766 there) as well as in the body text.
Fred Drake2f4bebd1999-04-28 16:43:11 +0000767
768 \begin{macrodesc}{bfcode}{\p{text}}
769 Like \macro{code}, but also makes the font bold-face.
770 \end{macrodesc}
771
772 \begin{macrodesc}{cdata}{\p{name}}
773 The name of a C-language variable.
774 \end{macrodesc}
775
776 \begin{macrodesc}{cfunction}{\p{name}}
777 The name of a C-language function. \var{name} should include the
778 function name and the trailing parentheses.
779 \end{macrodesc}
780
781 \begin{macrodesc}{character}{\p{char}}
782 A character when discussing the character rather than a one-byte
783 string value. The character will be typeset as with \macro{samp}.
784 \end{macrodesc}
785
Fred Drake29a710f1999-11-10 22:51:18 +0000786 \begin{macrodesc}{citetitle}{\op{url}\p{title}}
787 A title for a referenced publication. If \var{url} is specified,
788 the title will be made into a hyperlink when formatted as HTML.
789 \end{macrodesc}
790
Fred Drake2f4bebd1999-04-28 16:43:11 +0000791 \begin{macrodesc}{class}{\p{name}}
792 A class name; a dotted name may be used.
793 \end{macrodesc}
794
795 \begin{macrodesc}{code}{\p{text}}
796 A short code fragment or literal constant value. Typically, it
797 should not include any spaces since no quotation marks are
798 added.
799 \end{macrodesc}
800
801 \begin{macrodesc}{constant}{\p{name}}
802 The name of a ``defined'' constant. This may be a C-language
803 \code{\#define} or a Python variable that is not intended to be
804 changed.
805 \end{macrodesc}
806
Fred Drake79bf99c2002-04-09 20:17:42 +0000807 \begin{macrodesc}{csimplemacro}{\p{name}}
808 The name of a ``simple'' macro. Simple macros are macros
809 which are used for code expansion, but which do not take
810 arguments so cannot be described as functions. This is not to
811 be used for simple constant definitions. Examples of it's use
812 in the Python documentation include
813 \csimplemacro{PyObject_HEAD} and
814 \csimplemacro{Py_BEGIN_ALLOW_THREADS}.
815 \end{macrodesc}
816
Fred Drake2f4bebd1999-04-28 16:43:11 +0000817 \begin{macrodesc}{ctype}{\p{name}}
818 The name of a C \keyword{typedef} or structure. For structures
819 defined without a \keyword{typedef}, use \code{\e ctype\{struct
820 struct_tag\}} to make it clear that the \keyword{struct} is
821 required.
822 \end{macrodesc}
823
824 \begin{macrodesc}{deprecated}{\p{version}\p{what to do}}
Fred Drakee7f343d2003-07-11 03:36:15 +0000825 Declare whatever is being described as being deprecated starting
Fred Drake2f4bebd1999-04-28 16:43:11 +0000826 with release \var{version}. The text given as \var{what to do}
Fred Drakef79f2f92002-05-21 16:27:20 +0000827 should recommend something to use instead. It should be
828 complete sentences. The entire deprecation notice will be
829 presented as a separate paragraph; it should either preceed or
830 succeed the description of the deprecated feature.
Fred Drake2f4bebd1999-04-28 16:43:11 +0000831 \end{macrodesc}
832
833 \begin{macrodesc}{dfn}{\p{term}}
Fred Drakee7f343d2003-07-11 03:36:15 +0000834 Mark the defining instance of \var{term} in the text. (No index
Fred Drake2f4bebd1999-04-28 16:43:11 +0000835 entries are generated.)
836 \end{macrodesc}
837
Fred Draked1fb7791999-05-17 16:33:54 +0000838 \begin{macrodesc}{e}{}
Fred Drake27da2912004-02-09 21:00:29 +0000839 Produces a backslash. This is convenient in \macro{code},
Fred Drake29f59332004-02-10 18:30:22 +0000840 \macro{file}, and similar macros, and the \env{alltt}
841 environment, and is only defined there. To
Fred Drake27da2912004-02-09 21:00:29 +0000842 create a backslash in ordinary text (such as the contents of the
843 \macro{citetitle} macro), use the standard \macro{textbackslash}
844 macro.
Fred Draked1fb7791999-05-17 16:33:54 +0000845 \end{macrodesc}
846
Fred Drake2f4bebd1999-04-28 16:43:11 +0000847 \begin{macrodesc}{email}{\p{address}}
848 An email address. Note that this is \emph{not} hyperlinked in
Fred Drakee15956b2000-04-03 04:51:13 +0000849 any of the possible output formats. The domain name portion of
850 the address should be lower case.
Fred Drake2f4bebd1999-04-28 16:43:11 +0000851 \end{macrodesc}
852
853 \begin{macrodesc}{emph}{\p{text}}
854 Emphasized text; this will be presented in an italic font.
855 \end{macrodesc}
856
857 \begin{macrodesc}{envvar}{\p{name}}
858 An environment variable. Index entries are generated.
859 \end{macrodesc}
860
861 \begin{macrodesc}{exception}{\p{name}}
862 The name of an exception. A dotted name may be used.
863 \end{macrodesc}
864
865 \begin{macrodesc}{file}{\p{file or dir}}
866 The name of a file or directory. In the PDF and PostScript
867 outputs, single quotes and a font change are used to indicate
868 the file name, but no quotes are used in the HTML output.
Fred Drake64a5aaf2001-10-20 04:18:14 +0000869 \warning{The \macro{file} macro cannot be used in the
870 content of a section title due to processing limitations.}
Fred Drake2f4bebd1999-04-28 16:43:11 +0000871 \end{macrodesc}
872
873 \begin{macrodesc}{filenq}{\p{file or dir}}
874 Like \macro{file}, but single quotes are never used. This can
Fred Drakee7f343d2003-07-11 03:36:15 +0000875 be used in conjunction with tables if a column will only contain
Fred Drake2f4bebd1999-04-28 16:43:11 +0000876 file or directory names.
Fred Drake64a5aaf2001-10-20 04:18:14 +0000877 \warning{The \macro{filenq} macro cannot be used in the
878 content of a section title due to processing limitations.}
Fred Drake2f4bebd1999-04-28 16:43:11 +0000879 \end{macrodesc}
880
881 \begin{macrodesc}{function}{\p{name}}
882 The name of a Python function; dotted names may be used.
883 \end{macrodesc}
884
Fred Drake432cef02001-07-06 22:34:33 +0000885 \begin{macrodesc}{infinity}{}
886 The symbol for mathematical infinity: \infinity. Some Web
887 browsers are not able to render the HTML representation of this
888 symbol properly, but support is growing.
889 \end{macrodesc}
890
Fred Drake2f4bebd1999-04-28 16:43:11 +0000891 \begin{macrodesc}{kbd}{\p{key sequence}}
892 Mark a sequence of keystrokes. What form \var{key sequence}
893 takes may depend on platform- or application-specific
Fred Drake07178d22001-07-12 02:08:29 +0000894 conventions. When there are no relevant conventions, the names
895 of modifier keys should be spelled out, to improve accessibility
896 for new users and non-native speakers. For example, an
897 \program{xemacs} key sequence may be marked like
898 \code{\e kbd\{C-x C-f\}}, but without reference to a specific
899 application or platform, the same sequence should be marked as
900 \code{\e kbd\{Control-x Control-f\}}.
Fred Drake2f4bebd1999-04-28 16:43:11 +0000901 \end{macrodesc}
902
903 \begin{macrodesc}{keyword}{\p{name}}
904 The name of a keyword in a programming language.
905 \end{macrodesc}
906
Fred Drake8b3a7b52001-09-26 17:01:58 +0000907 \begin{macrodesc}{mailheader}{\p{name}}
908 The name of an \rfc{822}-style mail header. This markup does
909 not imply that the header is being used in an email message, but
910 can be used to refer to any header of the same ``style.'' This
911 is also used for headers defined by the various MIME
912 specifications. The header name should be entered in the same
913 way it would normally be found in practice, with the
914 camel-casing conventions being preferred where there is more
Fred Drake203d91a2001-09-26 18:43:20 +0000915 than one common usage. The colon which follows the name of the
916 header should not be included.
917 For example: \code{\e mailheader\{Content-Type\}}.
Fred Drake8b3a7b52001-09-26 17:01:58 +0000918 \end{macrodesc}
919
Fred Drake2f4bebd1999-04-28 16:43:11 +0000920 \begin{macrodesc}{makevar}{\p{name}}
921 The name of a \program{make} variable.
922 \end{macrodesc}
923
924 \begin{macrodesc}{manpage}{\p{name}\p{section}}
925 A reference to a \UNIX{} manual page.
926 \end{macrodesc}
927
928 \begin{macrodesc}{member}{\p{name}}
929 The name of a data attribute of an object.
930 \end{macrodesc}
931
932 \begin{macrodesc}{method}{\p{name}}
933 The name of a method of an object. \var{name} should include the
934 method name and the trailing parentheses. A dotted name may be
935 used.
936 \end{macrodesc}
937
938 \begin{macrodesc}{mimetype}{\p{name}}
Fred Drake8b3a7b52001-09-26 17:01:58 +0000939 The name of a MIME type, or a component of a MIME type (the
940 major or minor portion, taken alone).
Fred Drake2f4bebd1999-04-28 16:43:11 +0000941 \end{macrodesc}
942
943 \begin{macrodesc}{module}{\p{name}}
Fred Drake2b853412000-04-11 19:08:30 +0000944 The name of a module; a dotted name may be used. This should
945 also be used for package names.
Fred Drake2f4bebd1999-04-28 16:43:11 +0000946 \end{macrodesc}
947
948 \begin{macrodesc}{newsgroup}{\p{name}}
Fred Drake9120df32001-07-14 02:34:12 +0000949 The name of a Usenet newsgroup.
Fred Drake2f4bebd1999-04-28 16:43:11 +0000950 \end{macrodesc}
951
Fred Drake92350b32001-10-09 18:01:23 +0000952 \begin{macrodesc}{note}{\p{text}}
953 An especially important bit of information about an API that a
954 user should be aware of when using whatever bit of API the
955 note pertains to. This should be the last thing in the
956 paragraph as the end of the note is not visually marked in
Fred Drake64a5aaf2001-10-20 04:18:14 +0000957 any way. The content of \var{text} should be written in
958 complete sentences and include all appropriate punctuation.
Fred Drake92350b32001-10-09 18:01:23 +0000959 \end{macrodesc}
960
Fred Drake432cef02001-07-06 22:34:33 +0000961 \begin{macrodesc}{pep}{\p{number}}
962 A reference to a Python Enhancement Proposal. This generates
963 appropriate index entries. The text \samp{PEP \var{number}} is
964 generated; in the HTML output, this text is a hyperlink to an
965 online copy of the specified PEP.
966 \end{macrodesc}
967
968 \begin{macrodesc}{plusminus}{}
969 The symbol for indicating a value that may take a positive or
970 negative value of a specified magnitude, typically represented
971 by a plus sign placed over a minus sign. For example:
Fred Drake203d91a2001-09-26 18:43:20 +0000972 \code{\e plusminus 3\%{}}.
Fred Drake432cef02001-07-06 22:34:33 +0000973 \end{macrodesc}
974
Fred Drake2f4bebd1999-04-28 16:43:11 +0000975 \begin{macrodesc}{program}{\p{name}}
976 The name of an executable program. This may differ from the
Fred Drakee7f343d2003-07-11 03:36:15 +0000977 file name for the executable for some platforms. In particular,
978 the \file{.exe} (or other) extension should be omitted for
Martin v. Löwis36a4d8c2002-10-10 18:24:54 +0000979 Windows programs.
Fred Drake2f4bebd1999-04-28 16:43:11 +0000980 \end{macrodesc}
981
Fred Drake29a710f1999-11-10 22:51:18 +0000982 \begin{macrodesc}{programopt}{\p{option}}
Fred Drakece444982000-04-11 18:52:52 +0000983 A command-line option to an executable program. Use this only
Greg Ward8b46c712002-06-29 01:23:45 +0000984 for ``short'' options, and include the leading hyphen.
Fred Drakece444982000-04-11 18:52:52 +0000985 \end{macrodesc}
986
987 \begin{macrodesc}{longprogramopt}{\p{option}}
988 A long command-line option to an executable program. This
989 should only be used for long option names which will be prefixed
990 by two hyphens; the hyphens should not be provided as part of
991 \var{option}.
Fred Drake29a710f1999-11-10 22:51:18 +0000992 \end{macrodesc}
993
Fred Drake2f4bebd1999-04-28 16:43:11 +0000994 \begin{macrodesc}{refmodule}{\op{key}\p{name}}
Fred Drakee7f343d2003-07-11 03:36:15 +0000995 Like \macro{module}, but create a hyperlink to the documentation
Fred Drake2f4bebd1999-04-28 16:43:11 +0000996 for the named module. Note that the corresponding
997 \macro{declaremodule} must be in the same document. If the
998 \macro{declaremodule} defines a module key different from the
999 module name, it must also be provided as \var{key} to the
1000 \macro{refmodule} macro.
1001 \end{macrodesc}
1002
1003 \begin{macrodesc}{regexp}{\p{string}}
1004 Mark a regular expression.
1005 \end{macrodesc}
1006
1007 \begin{macrodesc}{rfc}{\p{number}}
Fred Drakee7f343d2003-07-11 03:36:15 +00001008 A reference to an Internet Request for Comments. This generates
Fred Drake2f4bebd1999-04-28 16:43:11 +00001009 appropriate index entries. The text \samp{RFC \var{number}} is
1010 generated; in the HTML output, this text is a hyperlink to an
1011 online copy of the specified RFC.
1012 \end{macrodesc}
1013
1014 \begin{macrodesc}{samp}{\p{text}}
1015 A short code sample, but possibly longer than would be given
Fred Drakee7f343d2003-07-11 03:36:15 +00001016 using \macro{code}. Since quotation marks are added, spaces are
Fred Drake2f4bebd1999-04-28 16:43:11 +00001017 acceptable.
1018 \end{macrodesc}
1019
Fred Drakeaf2b7142000-09-14 20:11:05 +00001020 \begin{macrodesc}{shortversion}{}
1021 The ``short'' version number of the documented software, as
1022 specified using the \macro{setshortversion} macro in the
1023 preamble. For Python, the short version number for a release is
1024 the first three characters of the \code{sys.version} value. For
1025 example, versions 2.0b1 and 2.0.1 both have a short version of
1026 2.0. This may not apply for all packages; if
1027 \macro{setshortversion} is not used, this produces an empty
1028 expansion. See also the \macro{version} macro.
1029 \end{macrodesc}
1030
Fred Drake2f4bebd1999-04-28 16:43:11 +00001031 \begin{macrodesc}{strong}{\p{text}}
1032 Strongly emphasized text; this will be presented using a bold
1033 font.
1034 \end{macrodesc}
1035
Fred Drake432cef02001-07-06 22:34:33 +00001036 \begin{macrodesc}{ulink}{\p{text}\p{url}}
1037 A hypertext link with a target specified by a URL, but for which
1038 the link text should not be the title of the resource. For
1039 resources being referenced by name, use the \macro{citetitle}
1040 macro. Not all formatted versions support arbitrary hypertext
1041 links. Note that many characters are special to \LaTeX{} and
1042 this macro does not always do the right thing. In particular,
1043 the tilde character (\character{\~}) is mis-handled; encoding it
1044 as a hex-sequence does work, use \samp{\%7e} in place of the
1045 tilde character.
1046 \end{macrodesc}
1047
Fred Draked1fb7791999-05-17 16:33:54 +00001048 \begin{macrodesc}{url}{\p{url}}
Fred Drakee7f343d2003-07-11 03:36:15 +00001049 A URL (or URN). The URL will be presented as text. In the HTML
Fred Draked1fb7791999-05-17 16:33:54 +00001050 and PDF formatted versions, the URL will also be a hyperlink.
Fred Drake432cef02001-07-06 22:34:33 +00001051 This can be used when referring to external resources without
1052 specific titles; references to resources which have titles
1053 should be marked using the \macro{citetitle} macro. See the
1054 comments about special characters in the description of the
1055 \macro{ulink} macro for special considerations.
Fred Draked1fb7791999-05-17 16:33:54 +00001056 \end{macrodesc}
1057
Fred Drake2f4bebd1999-04-28 16:43:11 +00001058 \begin{macrodesc}{var}{\p{name}}
1059 The name of a variable or formal parameter in running text.
1060 \end{macrodesc}
1061
1062 \begin{macrodesc}{version}{}
Fred Drakeaf2b7142000-09-14 20:11:05 +00001063 The version number of the described software, as specified using
1064 \macro{release} in the preamble. See also the
1065 \macro{shortversion} macro.
Fred Drake2f4bebd1999-04-28 16:43:11 +00001066 \end{macrodesc}
Fred Drakeacffaee1999-03-16 16:09:13 +00001067
Fred Drake92350b32001-10-09 18:01:23 +00001068 \begin{macrodesc}{warning}{\p{text}}
1069 An important bit of information about an API that a user should
1070 be very aware of when using whatever bit of API the warning
1071 pertains to. This should be the last thing in the paragraph as
Fred Drake64a5aaf2001-10-20 04:18:14 +00001072 the end of the warning is not visually marked in any way. The
1073 content of \var{text} should be written in complete sentences
1074 and include all appropriate punctuation. This differs from
1075 \macro{note} in that it is recommended over \macro{note} for
1076 information regarding security.
Fred Drake92350b32001-10-09 18:01:23 +00001077 \end{macrodesc}
1078
Fred Drakec0ed9c42004-07-13 21:04:26 +00001079 The following two macros are used to describe information that's
1080 associated with changes from one release to another. For features
1081 which are described by a single paragraph, these are typically
1082 added as separate source lines at the end of the paragraph. When
1083 adding these to features described by multiple paragraphs, they
1084 are usually collected in a single separate paragraph after the
1085 description. When both \macro{versionadded} and
1086 \macro{versionchanged} are used, \macro{versionadded} should come
1087 first; the versions should be listed in chronological order. Both
1088 of these should come before availability statements. The location
1089 should be selected so the explanation makes sense and may vary as
1090 needed.
1091
1092 \begin{macrodesc}{versionadded}{\op{explanation}\p{version}}
1093 The version of Python which added the described feature to the
1094 library or C API. \var{explanation} should be a \emph{brief}
1095 explanation of the change consisting of a capitalized sentence
1096 fragment; a period will be appended by the formatting process.
1097 When this applies to an entire module, it should be placed at
1098 the top of the module section before any prose.
1099 \end{macrodesc}
1100
1101 \begin{macrodesc}{versionchanged}{\op{explanation}\p{version}}
1102 The version of Python in which the named feature was changed in
1103 some way (new parameters, changed side effects, etc.).
1104 \var{explanation} should be a \emph{brief} explanation of the
1105 change consisting of a capitalized sentence fragment; a
1106 period will be appended by the formatting process. This should
1107 not generally be applied to modules.
1108 \end{macrodesc}
1109
Fred Drakeacffaee1999-03-16 16:09:13 +00001110
Fred Drake6ca33772001-12-14 22:50:06 +00001111 \subsection{Miscellaneous Text Markup \label{misc-text-markup}}
1112
1113 In addition to the inline markup, some additional ``block'' markup
1114 is defined to make it easier to bring attention to various bits of
1115 text. The markup described here serves this purpose, and is
1116 intended to be used when marking one or more paragraphs or other
1117 block constructs (such as \env{verbatim} environments).
1118
1119 \begin{envdesc}{notice}{\op{type}}
1120 Label some paragraphs as being worthy of additional attention from
1121 the reader. What sort of attention is warrented can be indicated
1122 by specifying the \var{type} of the notice. The only values
1123 defined for \var{type} are \code{note} and \code{warning}; these
1124 are equivalent in intent to the inline markup of the same name.
1125 If \var{type} is omitted, \code{note} is used. Additional values
1126 may be defined in the future.
1127 \end{envdesc}
1128
1129
Fred Drakef1b3de82001-07-24 14:38:34 +00001130 \subsection{Module-specific Markup \label{module-markup}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001131
1132 The markup described in this section is used to provide information
1133 about a module being documented. A typical use of this markup
1134 appears at the top of the section used to document a module. A
1135 typical example might look like this:
1136
1137\begin{verbatim}
1138\section{\module{spam} ---
1139 Access to the SPAM facility}
1140
1141\declaremodule{extension}{spam}
Fred Drake2c4e0091999-03-29 14:55:55 +00001142 \platform{Unix}
Fred Drake9120df32001-07-14 02:34:12 +00001143\modulesynopsis{Access to the SPAM facility of \UNIX.}
Fred Drake2c4e0091999-03-29 14:55:55 +00001144\moduleauthor{Jane Doe}{jane.doe@frobnitz.org}
Fred Drakeacffaee1999-03-16 16:09:13 +00001145\end{verbatim}
1146
Fred Drake7932ed02000-08-11 17:37:33 +00001147 Python packages\index{packages} --- collections of modules that can
1148 be described as a unit --- are documented using the same markup as
1149 modules. The name for a module in a package should be typed in
Fred Drake432cef02001-07-06 22:34:33 +00001150 ``fully qualified'' form (it should include the package name).
Fred Drake7932ed02000-08-11 17:37:33 +00001151 For example, a module ``foo'' in package ``bar'' should be marked as
Fred Drake203d91a2001-09-26 18:43:20 +00001152 \code{\e module\{bar.foo\}}, and the beginning of the reference
Fred Drake7932ed02000-08-11 17:37:33 +00001153 section would appear as:
1154
1155\begin{verbatim}
1156\section{\module{bar.foo} ---
1157 Module from the \module{bar} package}
1158
1159\declaremodule{extension}{bar.foo}
1160\modulesynopsis{Nifty module from the \module{bar} package.}
1161\moduleauthor{Jane Doe}{jane.doe@frobnitz.org}
1162\end{verbatim}
1163
1164 Note that the name of a package is also marked using
1165 \macro{module}.
1166
Fred Drakeadade921999-04-22 13:05:27 +00001167 \begin{macrodesc}{declaremodule}{\op{key}\p{type}\p{name}}
Fred Drake87f768e1999-05-17 15:22:45 +00001168 Requires two parameters: module type (\samp{standard},
1169 \samp{builtin}, \samp{extension}, or \samp{}), and the module
1170 name. An optional parameter should be given as the basis for the
1171 module's ``key'' used for linking to or referencing the section.
1172 The ``key'' should only be given if the module's name contains any
1173 underscores, and should be the name with the underscores stripped.
1174 Note that the \var{type} parameter must be one of the values
1175 listed above or an error will be printed. For modules which are
1176 contained in packages, the fully-qualified name should be given as
1177 \var{name} parameter. This should be the first thing after the
1178 \macro{section} used to introduce the module.
Fred Drakeacffaee1999-03-16 16:09:13 +00001179 \end{macrodesc}
1180
Fred Drakeadade921999-04-22 13:05:27 +00001181 \begin{macrodesc}{platform}{\p{specifier}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001182 Specifies the portability of the module. \var{specifier} is a
1183 comma-separated list of keys that specify what platforms the
1184 module is available on. The keys are short identifiers;
1185 examples that are in use include \samp{IRIX}, \samp{Mac},
1186 \samp{Windows}, and \samp{Unix}. It is important to use a key
Fred Drake7a737df1999-04-23 14:41:44 +00001187 which has already been used when applicable. This is used to
1188 provide annotations in the Module Index and the HTML and GNU info
1189 output.
Fred Drakeacffaee1999-03-16 16:09:13 +00001190 \end{macrodesc}
1191
Fred Drakeadade921999-04-22 13:05:27 +00001192 \begin{macrodesc}{modulesynopsis}{\p{text}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001193 The \var{text} is a short, ``one line'' description of the
1194 module that can be used as part of the chapter introduction.
Fred Drakeadade921999-04-22 13:05:27 +00001195 This is must be placed after \macro{declaremodule}.
Fred Drakeacffaee1999-03-16 16:09:13 +00001196 The synopsis is used in building the contents of the table
1197 inserted as the \macro{localmoduletable}. No text is
1198 produced at the point of the markup.
1199 \end{macrodesc}
1200
Fred Drakeadade921999-04-22 13:05:27 +00001201 \begin{macrodesc}{moduleauthor}{\p{name}\p{email}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001202 This macro is used to encode information about who authored a
1203 module. This is currently not used to generate output, but can be
1204 used to help determine the origin of the module.
1205 \end{macrodesc}
1206
1207
Fred Drakef1b3de82001-07-24 14:38:34 +00001208 \subsection{Library-level Markup \label{library-markup}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001209
1210 This markup is used when describing a selection of modules. For
Fred Drake698d5201999-11-10 15:54:57 +00001211 example, the \citetitle[../mac/mac.html]{Macintosh Library
1212 Modules} document uses this to help provide an overview of the
1213 modules in the collection, and many chapters in the
1214 \citetitle[../lib/lib.html]{Python Library Reference} use it for
Fred Drakeacffaee1999-03-16 16:09:13 +00001215 the same purpose.
1216
1217 \begin{macrodesc}{localmoduletable}{}
Fred Drake2c4e0091999-03-29 14:55:55 +00001218 If a \file{.syn} file exists for the current
Fred Drakeacffaee1999-03-16 16:09:13 +00001219 chapter (or for the entire document in \code{howto} documents), a
1220 \env{synopsistable} is created with the contents loaded from the
1221 \file{.syn} file.
1222 \end{macrodesc}
1223
1224
Fred Drakef1b3de82001-07-24 14:38:34 +00001225 \subsection{Table Markup \label{table-markup}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001226
1227 There are three general-purpose table environments defined which
1228 should be used whenever possible. These environments are defined
1229 to provide tables of specific widths and some convenience for
1230 formatting. These environments are not meant to be general
1231 replacements for the standard \LaTeX{} table environments, but can
1232 be used for an advantage when the documents are processed using
1233 the tools for Python documentation processing. In particular, the
1234 generated HTML looks good! There is also an advantage for the
Fred Drake67f193f2001-07-09 16:04:03 +00001235 eventual conversion of the documentation to XML (see section
Fred Drake2c4e0091999-03-29 14:55:55 +00001236 \ref{futures}, ``Future Directions'').
Fred Drakeacffaee1999-03-16 16:09:13 +00001237
1238 Each environment is named \env{table\var{cols}}, where \var{cols}
1239 is the number of columns in the table specified in lower-case
1240 Roman numerals. Within each of these environments, an additional
1241 macro, \macro{line\var{cols}}, is defined, where \var{cols}
1242 matches the \var{cols} value of the corresponding table
Fred Drake2c4e0091999-03-29 14:55:55 +00001243 environment. These are supported for \var{cols} values of
1244 \code{ii}, \code{iii}, and \code{iv}. These environments are all
Fred Drakeda72b932000-09-21 15:58:02 +00001245 built on top of the \env{tabular} environment. Variants based on
1246 the \env{longtable} environment are also provided.
Fred Drakeacffaee1999-03-16 16:09:13 +00001247
Fred Drake2b853412000-04-11 19:08:30 +00001248 Note that all tables in the standard Python documentation use
1249 vertical lines between columns, and this must be specified in the
1250 markup for each table. A general border around the outside of the
1251 table is not used, but would be the responsibility of the
Fred Drakeda72b932000-09-21 15:58:02 +00001252 processor; the document markup should not include an exterior
1253 border.
1254
1255 The \env{longtable}-based variants of the table environments are
1256 formatted with extra space before and after, so should only be
1257 used on tables which are long enough that splitting over multiple
1258 pages is reasonable; tables with fewer than twenty rows should
1259 never by marked using the long flavors of the table environments.
1260 The header row is repeated across the top of each part of the
1261 table.
Fred Drake2b853412000-04-11 19:08:30 +00001262
Fred Drakeadade921999-04-22 13:05:27 +00001263 \begin{envdesc}{tableii}{\p{colspec}\p{col1font}\p{heading1}\p{heading2}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001264 Create a two-column table using the \LaTeX{} column specifier
1265 \var{colspec}. The column specifier should indicate vertical
1266 bars between columns as appropriate for the specific table, but
1267 should not specify vertical bars on the outside of the table
1268 (that is considered a stylesheet issue). The \var{col1font}
1269 parameter is used as a stylistic treatment of the first column
1270 of the table: the first column is presented as
1271 \code{\e\var{col1font}\{column1\}}. To avoid treating the first
Fred Drakeadade921999-04-22 13:05:27 +00001272 column specially, \var{col1font} may be \samp{textrm}. The
Fred Drakeacffaee1999-03-16 16:09:13 +00001273 column headings are taken from the values \var{heading1} and
1274 \var{heading2}.
1275 \end{envdesc}
1276
Fred Drakeda72b932000-09-21 15:58:02 +00001277 \begin{envdesc}{longtableii}{\unspecified}
1278 Like \env{tableii}, but produces a table which may be broken
1279 across page boundaries. The parameters are the same as for
1280 \env{tableii}.
1281 \end{envdesc}
1282
Fred Drakeadade921999-04-22 13:05:27 +00001283 \begin{macrodesc}{lineii}{\p{column1}\p{column2}}
Fred Drakeda72b932000-09-21 15:58:02 +00001284 Create a single table row within a \env{tableii} or
1285 \env{longtableii} environment.
Fred Drakeacffaee1999-03-16 16:09:13 +00001286 The text for the first column will be generated by applying the
1287 macro named by the \var{col1font} value when the \env{tableii}
1288 was opened.
1289 \end{macrodesc}
1290
Fred Drakeadade921999-04-22 13:05:27 +00001291 \begin{envdesc}{tableiii}{\p{colspec}\p{col1font}\p{heading1}\p{heading2}\p{heading3}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001292 Like the \env{tableii} environment, but with a third column.
1293 The heading for the third column is given by \var{heading3}.
1294 \end{envdesc}
1295
Fred Drakeda72b932000-09-21 15:58:02 +00001296 \begin{envdesc}{longtableiii}{\unspecified}
1297 Like \env{tableiii}, but produces a table which may be broken
1298 across page boundaries. The parameters are the same as for
1299 \env{tableiii}.
1300 \end{envdesc}
1301
Fred Drakeadade921999-04-22 13:05:27 +00001302 \begin{macrodesc}{lineiii}{\p{column1}\p{column2}\p{column3}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001303 Like the \macro{lineii} macro, but with a third column. The
1304 text for the third column is given by \var{column3}.
1305 \end{macrodesc}
1306
Fred Drakeadade921999-04-22 13:05:27 +00001307 \begin{envdesc}{tableiv}{\p{colspec}\p{col1font}\p{heading1}\p{heading2}\p{heading3}\p{heading4}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001308 Like the \env{tableiii} environment, but with a fourth column.
1309 The heading for the fourth column is given by \var{heading4}.
1310 \end{envdesc}
1311
Fred Drakeda72b932000-09-21 15:58:02 +00001312 \begin{envdesc}{longtableiv}{\unspecified}
1313 Like \env{tableiv}, but produces a table which may be broken
1314 across page boundaries. The parameters are the same as for
1315 \env{tableiv}.
1316 \end{envdesc}
1317
Fred Drakeadade921999-04-22 13:05:27 +00001318 \begin{macrodesc}{lineiv}{\p{column1}\p{column2}\p{column3}\p{column4}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001319 Like the \macro{lineiii} macro, but with a fourth column. The
1320 text for the fourth column is given by \var{column4}.
1321 \end{macrodesc}
1322
Fred Drakef269e592001-07-17 23:05:57 +00001323 \begin{envdesc}{tablev}{\p{colspec}\p{col1font}\p{heading1}\p{heading2}\p{heading3}\p{heading4}\p{heading5}}
1324 Like the \env{tableiv} environment, but with a fifth column.
1325 The heading for the fifth column is given by \var{heading5}.
1326 \end{envdesc}
1327
1328 \begin{envdesc}{longtablev}{\unspecified}
1329 Like \env{tablev}, but produces a table which may be broken
1330 across page boundaries. The parameters are the same as for
1331 \env{tablev}.
1332 \end{envdesc}
1333
1334 \begin{macrodesc}{linev}{\p{column1}\p{column2}\p{column3}\p{column4}\p{column5}}
1335 Like the \macro{lineiv} macro, but with a fifth column. The
1336 text for the fifth column is given by \var{column5}.
1337 \end{macrodesc}
1338
Fred Drakeacffaee1999-03-16 16:09:13 +00001339
1340 An additional table-like environment is \env{synopsistable}. The
1341 table generated by this environment contains two columns, and each
1342 row is defined by an alternate definition of
Fred Drakee15956b2000-04-03 04:51:13 +00001343 \macro{modulesynopsis}. This environment is not normally used by
1344 authors, but is created by the \macro{localmoduletable} macro.
Fred Drakeacffaee1999-03-16 16:09:13 +00001345
Fred Drake0cac5f62001-08-14 21:36:19 +00001346 Here is a small example of a table given in the documentation for
1347 the \module{warnings} module; markup inside the table cells is
1348 minimal so the markup for the table itself is readily discernable.
1349 Here is the markup for the table:
1350
1351\begin{verbatim}
1352\begin{tableii}{l|l}{exception}{Class}{Description}
1353 \lineii{Warning}
1354 {This is the base class of all warning category classes. It
1355 is a subclass of \exception{Exception}.}
1356 \lineii{UserWarning}
1357 {The default category for \function{warn()}.}
1358 \lineii{DeprecationWarning}
1359 {Base category for warnings about deprecated features.}
1360 \lineii{SyntaxWarning}
1361 {Base category for warnings about dubious syntactic
1362 features.}
1363 \lineii{RuntimeWarning}
1364 {Base category for warnings about dubious runtime features.}
Barry Warsawb8c20a72002-08-14 16:40:54 +00001365 \lineii{FutureWarning}
Fred Drakee7f343d2003-07-11 03:36:15 +00001366 {Base category for warnings about constructs that will change
1367 semantically in the future.}
Fred Drake0cac5f62001-08-14 21:36:19 +00001368\end{tableii}
1369\end{verbatim}
1370
1371 Here is the resulting table:
1372
1373\begin{tableii}{l|l}{exception}{Class}{Description}
1374 \lineii{Warning}
1375 {This is the base class of all warning category classes. It
1376 is a subclass of \exception{Exception}.}
1377 \lineii{UserWarning}
1378 {The default category for \function{warn()}.}
1379 \lineii{DeprecationWarning}
1380 {Base category for warnings about deprecated features.}
1381 \lineii{SyntaxWarning}
1382 {Base category for warnings about dubious syntactic
1383 features.}
1384 \lineii{RuntimeWarning}
1385 {Base category for warnings about dubious runtime features.}
1386\end{tableii}
1387
1388 Note that the class names are implicitly marked using the
1389 \macro{exception} macro, since that is given as the \var{col1font}
1390 value for the \env{tableii} environment. To create a table using
1391 different markup for the first column, use \code{textrm} for the
1392 \var{col1font} value and mark each entry individually.
1393
1394 To add a horizontal line between vertical sections of a table, use
1395 the standard \macro{hline} macro between the rows which should be
1396 separated:
1397
1398\begin{verbatim}
1399\begin{tableii}{l|l}{constant}{Language}{Audience}
1400 \lineii{APL}{Masochists.}
1401 \lineii{BASIC}{First-time programmers on PC hardware.}
1402 \lineii{C}{\UNIX{} \&\ Linux kernel developers.}
1403 \hline
1404 \lineii{Python}{Everyone!}
1405\end{tableii}
1406\end{verbatim}
1407
1408 Note that not all presentation formats are capable of displaying a
1409 horizontal rule in this position. This is how the table looks in
1410 the format you're reading now:
1411
1412\begin{tableii}{l|l}{constant}{Language}{Audience}
1413 \lineii{APL}{Masochists.}
1414 \lineii{C}{\UNIX{} \&\ Linux kernel developers.}
1415 \lineii{JavaScript}{Web developers.}
1416 \hline
1417 \lineii{Python}{Everyone!}
1418\end{tableii}
1419
Fred Drakeacffaee1999-03-16 16:09:13 +00001420
1421 \subsection{Reference List Markup \label{references}}
1422
1423 Many sections include a list of references to module documentation
1424 or external documents. These lists are created using the
Fred Drake5ed35fd2001-11-30 18:09:54 +00001425 \env{seealso} or \env{seealso*} environments. These environments
1426 define some additional macros to support creating reference
1427 entries in a reasonable manner.
Fred Drakeacffaee1999-03-16 16:09:13 +00001428
Fred Drake5802e482000-07-06 05:24:41 +00001429 The \env{seealso} environment is typically placed in a section
1430 just before any sub-sections. This is done to ensure that
1431 reference links related to the section are not hidden in a
Fred Drake5ed35fd2001-11-30 18:09:54 +00001432 subsection in the hypertext renditions of the documentation. For
1433 the HTML output, it is shown as a ``side bar,'' boxed off from the
1434 main flow of the text. The \env{seealso*} environment is
1435 different in that it should be used when a list of references is
1436 being presented as part of the primary content; it is not
1437 specially set off from the text.
Fred Drake5802e482000-07-06 05:24:41 +00001438
Fred Drakeacffaee1999-03-16 16:09:13 +00001439 \begin{envdesc}{seealso}{}
1440 This environment creates a ``See also:'' heading and defines the
1441 markup used to describe individual references.
1442 \end{envdesc}
1443
Fred Drake5ed35fd2001-11-30 18:09:54 +00001444 \begin{envdesc}{seealso*}{}
1445 This environment is used to create a list of references which
1446 form part of the main content. It is not given a special
1447 header and is not set off from the main flow of the text. It
1448 provides the same additional markup used to describe individual
1449 references.
1450 \end{envdesc}
1451
Fred Drake48449982000-09-12 17:52:33 +00001452 For each of the following macros, \var{why} should be one or more
1453 complete sentences, starting with a capital letter (unless it
1454 starts with an identifier, which should not be modified), and
Fred Drake4f687b32004-01-08 14:57:27 +00001455 ending with the appropriate punctuation.
Fred Drake5802e482000-07-06 05:24:41 +00001456
Fred Drakeb7cf3782000-09-12 19:58:10 +00001457 These macros are only defined within the content of the
Fred Drake5ed35fd2001-11-30 18:09:54 +00001458 \env{seealso} and \env{seealso*} environments.
Fred Drakeb7cf3782000-09-12 19:58:10 +00001459
Fred Drake4f687b32004-01-08 14:57:27 +00001460 \begin{macrodesc}{seelink}{\p{url}\p{linktext}\p{why}}
1461 References to specific on-line resources should be given using
1462 the \macro{seelink} macro if they don't have a meaningful title
1463 but there is some short description of what's at the end of the
1464 link. Online documents which have identifiable titles should be
1465 referenced using the \macro{seetitle} macro, using the optional
1466 parameter to that macro to provide the URL.
1467 \end{macrodesc}
1468
Fred Drakeadade921999-04-22 13:05:27 +00001469 \begin{macrodesc}{seemodule}{\op{key}\p{name}\p{why}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001470 Refer to another module. \var{why} should be a brief
1471 explanation of why the reference may be interesting. The module
1472 name is given in \var{name}, with the link key given in
1473 \var{key} if necessary. In the HTML and PDF conversions, the
1474 module name will be a hyperlink to the referred-to module.
Fred Drake64a5aaf2001-10-20 04:18:14 +00001475 \note{The module must be documented in the same
1476 document (the corresponding \macro{declaremodule} is required).}
Fred Drakeacffaee1999-03-16 16:09:13 +00001477 \end{macrodesc}
1478
Fred Drake08c5d0c2000-09-11 05:22:30 +00001479 \begin{macrodesc}{seepep}{\p{number}\p{title}\p{why}}
1480 Refer to an Python Enhancement Proposal (PEP). \var{number}
1481 should be the official number assigned by the PEP Editor,
1482 \var{title} should be the human-readable title of the PEP as
Fred Drake5802e482000-07-06 05:24:41 +00001483 found in the official copy of the document, and \var{why} should
Fred Drake08c5d0c2000-09-11 05:22:30 +00001484 explain what's interesting about the PEP. This should be used
1485 to refer the reader to PEPs which specify interfaces or language
1486 features relevant to the material in the annotated section of the
1487 documentation.
1488 \end{macrodesc}
1489
1490 \begin{macrodesc}{seerfc}{\p{number}\p{title}\p{why}}
1491 Refer to an IETF Request for Comments (RFC). Otherwise very
1492 similar to \macro{seepep}. This should be used
1493 to refer the reader to PEPs which specify protocols or data
Fred Drake5802e482000-07-06 05:24:41 +00001494 formats relevant to the material in the annotated section of the
1495 documentation.
1496 \end{macrodesc}
1497
Fred Drakeadade921999-04-22 13:05:27 +00001498 \begin{macrodesc}{seetext}{\p{text}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001499 Add arbitrary text \var{text} to the ``See also:'' list. This
1500 can be used to refer to off-line materials or on-line materials
Fred Drake5802e482000-07-06 05:24:41 +00001501 using the \macro{url} macro. This should consist of one or more
1502 complete sentences.
1503 \end{macrodesc}
1504
Fred Drake48449982000-09-12 17:52:33 +00001505 \begin{macrodesc}{seetitle}{\op{url}\p{title}\p{why}}
1506 Add a reference to an external document named \var{title}. If
1507 \var{url} is given, the title is made a hyperlink in the HTML
1508 version of the documentation, and displayed below the title in
1509 the typeset versions of the documentation.
1510 \end{macrodesc}
1511
Fred Drake5802e482000-07-06 05:24:41 +00001512 \begin{macrodesc}{seeurl}{\p{url}\p{why}}
1513 References to specific on-line resources should be given using
Fred Drake5ed35fd2001-11-30 18:09:54 +00001514 the \macro{seeurl} macro if they don't have a meaningful title.
1515 Online documents which have identifiable titles should be
1516 referenced using the \macro{seetitle} macro, using the optional
1517 parameter to that macro to provide the URL.
Fred Drakeacffaee1999-03-16 16:09:13 +00001518 \end{macrodesc}
1519
1520
1521 \subsection{Index-generating Markup \label{indexing}}
1522
1523 Effective index generation for technical documents can be very
Fred Drakee15956b2000-04-03 04:51:13 +00001524 difficult, especially for someone familiar with the topic but not
Fred Drakeacffaee1999-03-16 16:09:13 +00001525 the creation of indexes. Much of the difficulty arises in the
1526 area of terminology: including the terms an expert would use for a
1527 concept is not sufficient. Coming up with the terms that a novice
Fred Drake2c4e0091999-03-29 14:55:55 +00001528 would look up is fairly difficult for an author who, typically, is
Fred Drakeacffaee1999-03-16 16:09:13 +00001529 an expert in the area she is writing on.
1530
Fred Drake2c4e0091999-03-29 14:55:55 +00001531 The truly difficult aspects of index generation are not areas with
1532 which the documentation tools can help. However, ease
Fred Drakee15956b2000-04-03 04:51:13 +00001533 of producing the index once content decisions are made is within
Fred Drakeacffaee1999-03-16 16:09:13 +00001534 the scope of the tools. Markup is provided which the processing
1535 software is able to use to generate a variety of kinds of index
1536 entry with minimal effort. Additionally, many of the environments
Fred Drake7a737df1999-04-23 14:41:44 +00001537 described in section \ref{info-units}, ``Information Units,'' will
Fred Drakeacffaee1999-03-16 16:09:13 +00001538 generate appropriate entries into the general and module indexes.
1539
1540 The following macro can be used to control the generation of index
Fred Drakeadade921999-04-22 13:05:27 +00001541 data, and should be used in the document preamble:
Fred Drakeacffaee1999-03-16 16:09:13 +00001542
1543 \begin{macrodesc}{makemodindex}{}
Fred Drakeadade921999-04-22 13:05:27 +00001544 This should be used in the document preamble if a ``Module
Fred Drakeacffaee1999-03-16 16:09:13 +00001545 Index'' is desired for a document containing reference material
1546 on many modules. This causes a data file
Fred Draked1fb7791999-05-17 16:33:54 +00001547 \code{lib\var{jobname}.idx} to be created from the
Fred Drakeacffaee1999-03-16 16:09:13 +00001548 \macro{declaremodule} macros. This file can be processed by the
1549 \program{makeindex} program to generate a file which can be
1550 \macro{input} into the document at the desired location of the
1551 module index.
1552 \end{macrodesc}
1553
1554 There are a number of macros that are useful for adding index
1555 entries for particular concepts, many of which are specific to
1556 programming languages or even Python.
1557
Fred Drakeadade921999-04-22 13:05:27 +00001558 \begin{macrodesc}{bifuncindex}{\p{name}}
Fred Drakeec8b9051999-04-23 20:01:17 +00001559 Add an index entry referring to a built-in function named
1560 \var{name}; parentheses should not be included after
Fred Drake2c4e0091999-03-29 14:55:55 +00001561 \var{name}.
Fred Drakeacffaee1999-03-16 16:09:13 +00001562 \end{macrodesc}
1563
Fred Drakeadade921999-04-22 13:05:27 +00001564 \begin{macrodesc}{exindex}{\p{exception}}
Fred Drake2c4e0091999-03-29 14:55:55 +00001565 Add a reference to an exception named \var{exception}. The
Neal Norwitz847207a2003-05-29 02:17:23 +00001566 exception should be class-based.
Fred Drakeacffaee1999-03-16 16:09:13 +00001567 \end{macrodesc}
1568
Fred Drakeadade921999-04-22 13:05:27 +00001569 \begin{macrodesc}{kwindex}{\p{keyword}}
Fred Drake2c4e0091999-03-29 14:55:55 +00001570 Add a reference to a language keyword (not a keyword parameter
1571 in a function or method call).
Fred Drakeacffaee1999-03-16 16:09:13 +00001572 \end{macrodesc}
1573
Fred Drakeadade921999-04-22 13:05:27 +00001574 \begin{macrodesc}{obindex}{\p{object type}}
Fred Drake2c4e0091999-03-29 14:55:55 +00001575 Add an index entry for a built-in object type.
Fred Drakeacffaee1999-03-16 16:09:13 +00001576 \end{macrodesc}
1577
Fred Drakeadade921999-04-22 13:05:27 +00001578 \begin{macrodesc}{opindex}{\p{operator}}
Fred Drake2c4e0091999-03-29 14:55:55 +00001579 Add a reference to an operator, such as \samp{+}.
Fred Drakeacffaee1999-03-16 16:09:13 +00001580 \end{macrodesc}
1581
Fred Drakeadade921999-04-22 13:05:27 +00001582 \begin{macrodesc}{refmodindex}{\op{key}\p{module}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001583 Add an index entry for module \var{module}; if \var{module}
1584 contains an underscore, the optional parameter \var{key} should
1585 be provided as the same string with underscores removed. An
1586 index entry ``\var{module} (module)'' will be generated. This
1587 is intended for use with non-standard modules implemented in
1588 Python.
1589 \end{macrodesc}
1590
Fred Drakeadade921999-04-22 13:05:27 +00001591 \begin{macrodesc}{refexmodindex}{\op{key}\p{module}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001592 As for \macro{refmodindex}, but the index entry will be
1593 ``\var{module} (extension module).'' This is intended for use
1594 with non-standard modules not implemented in Python.
1595 \end{macrodesc}
1596
Fred Drakeadade921999-04-22 13:05:27 +00001597 \begin{macrodesc}{refbimodindex}{\op{key}\p{module}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001598 As for \macro{refmodindex}, but the index entry will be
1599 ``\var{module} (built-in module).'' This is intended for use
1600 with standard modules not implemented in Python.
1601 \end{macrodesc}
1602
Fred Drakeadade921999-04-22 13:05:27 +00001603 \begin{macrodesc}{refstmodindex}{\op{key}\p{module}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001604 As for \macro{refmodindex}, but the index entry will be
1605 ``\var{module} (standard module).'' This is intended for use
1606 with standard modules implemented in Python.
1607 \end{macrodesc}
1608
Fred Drakeadade921999-04-22 13:05:27 +00001609 \begin{macrodesc}{stindex}{\p{statement}}
Fred Drake2c4e0091999-03-29 14:55:55 +00001610 Add an index entry for a statement type, such as \keyword{print}
Fred Drakeadade921999-04-22 13:05:27 +00001611 or \keyword{try}/\keyword{finally}.
1612
1613 XXX Need better examples of difference from \macro{kwindex}.
Fred Drakeacffaee1999-03-16 16:09:13 +00001614 \end{macrodesc}
1615
1616
1617 Additional macros are provided which are useful for conveniently
1618 creating general index entries which should appear at many places
1619 in the index by rotating a list of words. These are simple macros
1620 that simply use \macro{index} to build some number of index
1621 entries. Index entries build using these macros contain both
1622 primary and secondary text.
1623
Fred Drakeadade921999-04-22 13:05:27 +00001624 \begin{macrodesc}{indexii}{\p{word1}\p{word2}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001625 Build two index entries. This is exactly equivalent to using
Fred Drakee7f343d2003-07-11 03:36:15 +00001626 \code{\e index\{\var{word1}!\var{word2}\}} and
Fred Drakeacffaee1999-03-16 16:09:13 +00001627 \code{\e index\{\var{word2}!\var{word1}\}}.
1628 \end{macrodesc}
1629
Fred Drakeadade921999-04-22 13:05:27 +00001630 \begin{macrodesc}{indexiii}{\p{word1}\p{word2}\p{word3}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001631 Build three index entries. This is exactly equivalent to using
1632 \code{\e index\{\var{word1}!\var{word2} \var{word3}\}},
1633 \code{\e index\{\var{word2}!\var{word3}, \var{word1}\}}, and
1634 \code{\e index\{\var{word3}!\var{word1} \var{word2}\}}.
1635 \end{macrodesc}
1636
Fred Drakeadade921999-04-22 13:05:27 +00001637 \begin{macrodesc}{indexiv}{\p{word1}\p{word2}\p{word3}\p{word4}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001638 Build four index entries. This is exactly equivalent to using
1639 \code{\e index\{\var{word1}!\var{word2} \var{word3} \var{word4}\}},
1640 \code{\e index\{\var{word2}!\var{word3} \var{word4}, \var{word1}\}},
1641 \code{\e index\{\var{word3}!\var{word4}, \var{word1} \var{word2}\}},
1642 and
1643 \code{\e index\{\var{word4}!\var{word1} \var{word2} \var{word3}\}}.
1644 \end{macrodesc}
1645
Fred Drake432cef02001-07-06 22:34:33 +00001646 \subsection{Grammar Production Displays \label{grammar-displays}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001647
Fred Drake432cef02001-07-06 22:34:33 +00001648 Special markup is available for displaying the productions of a
1649 formal grammar. The markup is simple and does not attempt to
1650 model all aspects of BNF (or any derived forms), but provides
1651 enough to allow context-free grammars to be displayed in a way
1652 that causes uses of a symbol to be rendered as hyperlinks to the
1653 definition of the symbol. There is one environment and a pair of
1654 macros:
Fred Drakeacffaee1999-03-16 16:09:13 +00001655
Fred Drake432cef02001-07-06 22:34:33 +00001656 \begin{envdesc}{productionlist}{\op{language}}
1657 This environment is used to enclose a group of productions. The
1658 two macros are only defined within this environment. If a
1659 document descibes more than one language, the optional parameter
1660 \var{language} should be used to distinguish productions between
1661 languages. The value of the parameter should be a short name
1662 that can be used as part of a filename; colons or other
1663 characters that can't be used in filename across platforms
1664 should be included.
1665 \end{envdesc}
Fred Drakeacffaee1999-03-16 16:09:13 +00001666
Fred Drake432cef02001-07-06 22:34:33 +00001667 \begin{macrodesc}{production}{\p{name}\p{definition}}
1668 A production rule in the grammar. The rule defines the symbol
1669 \var{name} to be \var{definition}. \var{name} should not
1670 contain any markup, and the use of hyphens in a document which
1671 supports more than one grammar is undefined. \var{definition}
1672 may contain \macro{token} macros and any additional content
1673 needed to describe the grammatical model of \var{symbol}. Only
1674 one \macro{production} may be used to define a symbol ---
1675 multiple definitions are not allowed.
1676 \end{macrodesc}
Fred Drakeacffaee1999-03-16 16:09:13 +00001677
Fred Drake432cef02001-07-06 22:34:33 +00001678 \begin{macrodesc}{token}{\p{name}}
1679 The name of a symbol defined by a \macro{production} macro, used
1680 in the \var{definition} of a symbol. Where possible, this will
1681 be rendered as a hyperlink to the definition of the symbol
1682 \var{name}.
1683 \end{macrodesc}
Fred Drake42934682000-04-03 15:00:28 +00001684
Fred Drake432cef02001-07-06 22:34:33 +00001685 Note that the entire grammar does not need to be defined in a
1686 single \env{productionlist} environment; any number of
1687 groupings may be used to describe the grammar. Every use of the
1688 \macro{token} must correspond to a \macro{production}.
1689
1690 The following is an example taken from the
1691 \citetitle[../ref/identifiers.html]{Python Reference Manual}:
1692
1693\begin{verbatim}
1694\begin{productionlist}
1695 \production{identifier}
1696 {(\token{letter}|"_") (\token{letter} | \token{digit} | "_")*}
1697 \production{letter}
1698 {\token{lowercase} | \token{uppercase}}
1699 \production{lowercase}
1700 {"a"..."z"}
1701 \production{uppercase}
1702 {"A"..."Z"}
1703 \production{digit}
1704 {"0"..."9"}
1705\end{productionlist}
1706\end{verbatim}
1707
1708
Fred Drakee1341582002-09-25 18:44:21 +00001709\subsection{Graphical Interface Components \label{gui-markup}}
Fred Drake432cef02001-07-06 22:34:33 +00001710
1711 The components of graphical interfaces will be assigned markup, but
Fred Drakee1341582002-09-25 18:44:21 +00001712 most of the specifics have not been determined.
1713
Fred Drakef0f6d122004-01-23 08:52:28 +00001714 \begin{macrodesc}{guilabel}{\p{label}}
1715 Labels presented as part of an interactive user interface should
1716 be marked using \macro{guilabel}. This includes labels from
1717 text-based interfaces such as those created using \code{curses} or
1718 other text-based libraries. Any label used in the interface
1719 should be marked with this macro, including button labels, window
1720 titles, field names, menu and menu selection names, and even
1721 values in selection lists.
1722 \end{macrodesc}
1723
Fred Drakee1341582002-09-25 18:44:21 +00001724 \begin{macrodesc}{menuselection}{\p{menupath}}
1725 Menu selections should be marked using a combination of
1726 \macro{menuselection} and \macro{sub}. This macro is used to mark
1727 a complete sequence of menu selections, including selecting
1728 submenus and choosing a specific operation, or any subsequence of
1729 such a sequence. The names of individual selections should be
1730 separated by occurances of \macro{sub}.
1731
1732 For example, to mark the selection ``\menuselection{Start \sub
1733 Programs}'', use this markup:
1734
1735\begin{verbatim}
1736\menuselection{Start \sub Programs}
1737\end{verbatim}
1738
1739 When including a selection that includes some trailing indicator,
1740 such as the ellipsis some operating systems use to indicate that
1741 the command opens a dialog, the indicator should be omitted from
1742 the selection name.
Fred Drakef0f6d122004-01-23 08:52:28 +00001743
1744 Individual selection names within the \macro{menuselection} should
1745 not be marked using \macro{guilabel} since that's implied by using
1746 \macro{menuselection}.
Fred Drakee1341582002-09-25 18:44:21 +00001747 \end{macrodesc}
1748
1749 \begin{macrodesc}{sub}{}
1750 Separator for menu selections that include multiple levels. This
1751 macro is only defined within the context of the
1752 \macro{menuselection} macro.
1753 \end{macrodesc}
Fred Drakeacffaee1999-03-16 16:09:13 +00001754
1755
Fred Drakef1b3de82001-07-24 14:38:34 +00001756\section{Processing Tools \label{tools}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001757
Fred Drakef1b3de82001-07-24 14:38:34 +00001758 \subsection{External Tools \label{tools-external}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001759
1760 Many tools are needed to be able to process the Python
1761 documentation if all supported formats are required. This
Fred Drakeadade921999-04-22 13:05:27 +00001762 section lists the tools used and when each is required. Consult
1763 the \file{Doc/README} file to see if there are specific version
1764 requirements for any of these.
Fred Drakeacffaee1999-03-16 16:09:13 +00001765
1766 \begin{description}
1767 \item[\program{dvips}]
1768 This program is a typical part of \TeX{} installations. It is
1769 used to generate PostScript from the ``device independent''
Fred Drake2c4e0091999-03-29 14:55:55 +00001770 \file{.dvi} files. It is needed for the conversion to
Fred Drakeacffaee1999-03-16 16:09:13 +00001771 PostScript.
1772
1773 \item[\program{emacs}]
1774 Emacs is the kitchen sink of programmers' editors, and a damn
1775 fine kitchen sink it is. It also comes with some of the
1776 processing needed to support the proper menu structures for
1777 Texinfo documents when an info conversion is desired. This is
Fred Drake2c4e0091999-03-29 14:55:55 +00001778 needed for the info conversion. Using \program{xemacs}
Fred Drakeacffaee1999-03-16 16:09:13 +00001779 instead of FSF \program{emacs} may lead to instability in the
1780 conversion, but that's because nobody seems to maintain the
1781 Emacs Texinfo code in a portable manner.
1782
1783 \item[\program{latex}]
Fred Drakeb5f17f22001-08-28 18:09:11 +00001784 \LaTeX{} is a large and extensible macro package by Leslie
1785 Lamport, based on \TeX, a world-class typesetter by Donald
1786 Knuth. It is used for the conversion to PostScript, and is
1787 needed for the HTML conversion as well (\LaTeX2HTML requires
1788 one of the intermediate files it creates).
Fred Drakeacffaee1999-03-16 16:09:13 +00001789
1790 \item[\program{latex2html}]
1791 Probably the longest Perl script anyone ever attempted to
1792 maintain. This converts \LaTeX{} documents to HTML documents,
1793 and does a pretty reasonable job. It is required for the
1794 conversions to HTML and GNU info.
1795
1796 \item[\program{lynx}]
1797 This is a text-mode Web browser which includes an
1798 HTML-to-plain text conversion. This is used to convert
1799 \code{howto} documents to text.
1800
1801 \item[\program{make}]
1802 Just about any version should work for the standard documents,
1803 but GNU \program{make} is required for the experimental
1804 processes in \file{Doc/tools/sgmlconv/}, at least while
Fred Drakeb5f17f22001-08-28 18:09:11 +00001805 they're experimental. This is not required for running the
Fred Drakef9dc0432001-08-29 02:34:10 +00001806 \program{mkhowto} script.
Fred Drakeacffaee1999-03-16 16:09:13 +00001807
1808 \item[\program{makeindex}]
1809 This is a standard program for converting \LaTeX{} index data
1810 to a formatted index; it should be included with all \LaTeX{}
1811 installations. It is needed for the PDF and PostScript
1812 conversions.
1813
1814 \item[\program{makeinfo}]
1815 GNU \program{makeinfo} is used to convert Texinfo documents to
1816 GNU info files. Since Texinfo is used as an intermediate
1817 format in the info conversion, this program is needed in that
1818 conversion.
1819
1820 \item[\program{pdflatex}]
1821 pdf\TeX{} is a relatively new variant of \TeX, and is used to
1822 generate the PDF version of the manuals. It is typically
1823 installed as part of most of the large \TeX{} distributions.
Fred Drake7a737df1999-04-23 14:41:44 +00001824 \program{pdflatex} is pdf\TeX{} using the \LaTeX{} format.
Fred Drakeacffaee1999-03-16 16:09:13 +00001825
1826 \item[\program{perl}]
1827 Perl is required for \LaTeX2HTML{} and one of the scripts used
1828 to post-process \LaTeX2HTML output, as well as the
Fred Drake2c4e0091999-03-29 14:55:55 +00001829 HTML-to-Texinfo conversion. This is required for
Fred Drakeacffaee1999-03-16 16:09:13 +00001830 the HTML and GNU info conversions.
1831
1832 \item[\program{python}]
1833 Python is used for many of the scripts in the
1834 \file{Doc/tools/} directory; it is required for all
1835 conversions. This shouldn't be a problem if you're interested
1836 in writing documentation for Python!
1837 \end{description}
1838
1839
Fred Drakef1b3de82001-07-24 14:38:34 +00001840 \subsection{Internal Tools \label{tools-internal}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001841
1842 This section describes the various scripts that are used to
1843 implement various stages of document processing or to orchestrate
Fred Drake2c4e0091999-03-29 14:55:55 +00001844 entire build sequences. Most of these tools are only useful
Fred Drakeacffaee1999-03-16 16:09:13 +00001845 in the context of building the standard documentation, but some
1846 are more general.
1847
1848 \begin{description}
1849 \item[\program{mkhowto}]
Fred Drake87f768e1999-05-17 15:22:45 +00001850 This is the primary script used to format third-party
Fred Drakee7f343d2003-07-11 03:36:15 +00001851 documents. It contains all the logic needed to ``get it
1852 right.'' The proper way to use this script is to make a
1853 symbolic link to it or run it in place; the actual script file
1854 must be stored as part of the documentation source tree,
Fred Drakeefb3a162003-10-01 04:15:09 +00001855 though it may be used to format documents outside the tree.
1856 Use \program{mkhowto} \longprogramopt{help} for a list of
Fred Draked2a727f1999-05-27 21:45:54 +00001857 command line options.
Fred Drake87f768e1999-05-17 15:22:45 +00001858
Fred Draked1fb7791999-05-17 16:33:54 +00001859 \program{mkhowto} can be used for both \code{howto} and
Fred Draked80032b2002-09-25 21:41:22 +00001860 \code{manual} class documents. It is usually a good idea to
1861 always use the latest version of this tool rather than a
Fred Drakeefb3a162003-10-01 04:15:09 +00001862 version from an older source release of Python. It can be
1863 used to generate DVI, HTML, PDF, PostScript, and plain text
1864 documents. The GNU info and iSilo formats will be supported
1865 by this script in some future version.
1866
1867 Use the \longprogramopt{help} option on this script's command
1868 line to get a summary of options for this script.
Fred Draked1fb7791999-05-17 16:33:54 +00001869
Fred Drakee7f343d2003-07-11 03:36:15 +00001870 XXX Need more here.
Fred Drakeacffaee1999-03-16 16:09:13 +00001871 \end{description}
1872
1873
Fred Drakeeb2b8332002-05-01 22:05:30 +00001874 \subsection{Working on Cygwin \label{cygwin}}
1875
Fred Drakeeb2b8332002-05-01 22:05:30 +00001876 Installing the required tools under Cygwin under Cygwin can be a
1877 little tedious, if only because many packages are more difficult
1878 to install under Cygwin.
1879
1880 Using the Cygwin installer, make sure your Cygwin installation
1881 includes Perl, Python, and the \TeX{} packages. Perl and Python
Fred Drakea66b6c12003-07-16 13:50:28 +00001882 are located under \menuselection{Interpreters} in the installer.
Fred Drakeeb2b8332002-05-01 22:05:30 +00001883 The \TeX{} packages are located in the \menuselection{Text}
Fred Drakea66b6c12003-07-16 13:50:28 +00001884 section; installing the \code{tetex-beta}, \code{texmf},
1885 \code{texmf-base}, and \code{texmf-extra} ensures that all the
1886 required packages are available. (There may be a more minimal
1887 set, but I've not spent time trying to minimize the installation.)
Fred Drakeeb2b8332002-05-01 22:05:30 +00001888
1889 The netpbm package is used by \LaTeX2HTML, and \emph{must} be
1890 installed before \LaTeX2HTML can be successfully installed, even
1891 though they will never be used for most Python documentation.
1892 References to download locations are located in the \ulink{netpbm
1893 README}{http://netpbm.sourceforge.net/README}. Install according
1894 to the instructions.
1895
1896 \LaTeX2HTML can be installed from the source archive, but only
1897 after munging one of the files in the distribution. Edit the file
1898 \file{L2hos.pm} in the top level of the unpacked distribution;
1899 near the bottom of the file, change the text
1900 \code{\$\textasciicircum{}O} with the text \code{'unix'}. Proceed
1901 using this command to build and install the software:
1902
1903\begin{verbatim}
Fred Drakec7c9a3a2004-05-10 18:39:32 +00001904% ./configure && make install
Fred Drakeeb2b8332002-05-01 22:05:30 +00001905\end{verbatim}
1906
Fred Drakeefb3a162003-10-01 04:15:09 +00001907 You should now be able to build at least the DVI, HTML, PDF, and
Fred Drake77c18952002-05-02 21:10:48 +00001908 PostScript versions of the formatted documentation.
1909
Fred Drakeeb2b8332002-05-01 22:05:30 +00001910
Fred Drake40b9df22003-10-11 05:25:24 +00001911\section{Including Graphics \label{graphics}}
1912
1913 The standard documentation included with Python makes no use of
1914 diagrams or images; this is intentional. The outside tools used to
1915 format the documentation have not always been suited to working with
1916 graphics. As the tools have evolved and been improved by their
1917 maintainers, support for graphics has improved.
1918
1919 The internal tools, starting with the \program{mkhowto} script, do
1920 not provide any direct support for graphics. However,
1921 \program{mkhowto} will not interfere with graphics support in the
1922 external tools.
1923
1924 Experience using graphics together with these tools and the
1925 \code{howto} and \code{manual} document classes is not extensive,
1926 but has been known to work. The basic approach is this:
1927
1928 \begin{enumerate}
1929 \item Create the image or graphic using your favorite
1930 application.
1931
1932 \item Convert the image to a format supported by the conversion to
1933 your desired output format. If you want to generate HTML or
1934 PostScript, you can convert the image or graphic to
1935 encapsulated PostScript (a \file{.eps} file); \LaTeX2HTML
1936 can convert that to a \file{.gif} file; it may be possible
1937 to provide a \file{.gif} file directly. If you want to
1938 generate PDF, you need to provide an ``encapsulated'' PDF
1939 file. This can be generated from encapsulated PostScript
1940 using the \program{epstopdf} tool provided with the te\TeX{}
1941 distribution on Linux and \UNIX.
1942
1943 \item In your document, add this line to ``import'' the general
1944 graphics support package \code{graphicx}:
1945
1946\begin{verbatim}
1947\usepackage{graphicx}
1948\end{verbatim}
1949
1950 \item Where you want to include your graphic or image, include
1951 markup similar to this:
1952
1953\begin{verbatim}
1954\begin{figure}
1955 \centering
1956 \includegraphics[width=5in]{myimage}
1957 \caption{Description of my image}
1958\end{figure}
1959\end{verbatim}
1960
1961 In particular, note for the \macro{includegraphics} macro
1962 that no file extension is provided. If you're only
1963 interested in one target format, you can include the
1964 extension of the appropriate input file, but to allow
1965 support for multiple formats, omitting the extension makes
1966 life easier.
1967
1968 \item Run \program{mkhowto} normally.
1969 \end{enumerate}
1970
1971 If you're working on systems which support some sort of
1972 \program{make} facility, you can use that to ensure the intermediate
1973 graphic formats are kept up to date. This example shows a
1974 \file{Makefile} used to format a document containing a diagram
1975 created using the \program{dia} application:
1976
1977\begin{verbatim}
1978default: pdf
1979all: html pdf ps
1980
1981html: mydoc/mydoc.html
1982pdf: mydoc.pdf
1983ps: mydoc.ps
1984
1985mydoc/mydoc.html: mydoc.tex mygraphic.eps
1986 mkhowto --html $<
1987
1988mydoc.pdf: mydoc.tex mygraphic.pdf
1989 mkhowto --pdf $<
1990
1991mydoc.ps: mydoc.tex mygraphic.eps
1992 mkhowto --postscript $<
1993
1994.SUFFIXES: .dia .eps .pdf
1995
1996.dia.eps:
1997 dia --nosplash --export $@ $<
1998
1999.eps.pdf:
2000 epstopdf $<
2001\end{verbatim} % $ <-- bow to font-lock
2002
2003
Fred Drakeacffaee1999-03-16 16:09:13 +00002004\section{Future Directions \label{futures}}
2005
2006 The history of the Python documentation is full of changes, most of
2007 which have been fairly small and evolutionary. There has been a
2008 great deal of discussion about making large changes in the markup
2009 languages and tools used to process the documentation. This section
2010 deals with the nature of the changes and what appears to be the most
2011 likely path of future development.
2012
2013 \subsection{Structured Documentation \label{structured}}
2014
2015 Most of the small changes to the \LaTeX{} markup have been made
2016 with an eye to divorcing the markup from the presentation, making
2017 both a bit more maintainable. Over the course of 1998, a large
2018 number of changes were made with exactly this in mind; previously,
2019 changes had been made but in a less systematic manner and with
2020 more concern for not needing to update the existing content. The
2021 result has been a highly structured and semantically loaded markup
2022 language implemented in \LaTeX. With almost no basic \TeX{} or
2023 \LaTeX{} markup in use, however, the markup syntax is about the
2024 only evidence of \LaTeX{} in the actual document sources.
2025
2026 One side effect of this is that while we've been able to use
2027 standard ``engines'' for manipulating the documents, such as
2028 \LaTeX{} and \LaTeX2HTML, most of the actual transformations have
Fred Drake7a737df1999-04-23 14:41:44 +00002029 been created specifically for Python. The \LaTeX{} document
2030 classes and \LaTeX2HTML support are both complete implementations
2031 of the specific markup designed for these documents.
Fred Drakeacffaee1999-03-16 16:09:13 +00002032
2033 Combining highly customized markup with the somewhat esoteric
2034 systems used to process the documents leads us to ask some
2035 questions: Can we do this more easily? and, Can we do this
2036 better? After a great deal of discussion with the community, we
2037 have determined that actively pursuing modern structured
Fred Drake2c4e0091999-03-29 14:55:55 +00002038 documentation systems is worth some investment of time.
Fred Drakeacffaee1999-03-16 16:09:13 +00002039
2040 There appear to be two real contenders in this arena: the Standard
2041 General Markup Language (SGML), and the Extensible Markup Language
2042 (XML). Both of these standards have advantages and disadvantages,
2043 and many advantages are shared.
2044
2045 SGML offers advantages which may appeal most to authors,
2046 especially those using ordinary text editors. There are also
2047 additional abilities to define content models. A number of
Fred Drake67f193f2001-07-09 16:04:03 +00002048 high-quality tools with demonstrated maturity are available, but
Fred Drakeacffaee1999-03-16 16:09:13 +00002049 most are not free; for those which are, portability issues remain
2050 a problem.
2051
2052 The advantages of XML include the availability of a large number
2053 of evolving tools. Unfortunately, many of the associated
2054 standards are still evolving, and the tools will have to follow
2055 along. This means that developing a robust tool set that uses
2056 more than the basic XML 1.0 recommendation is not possible in the
2057 short term. The promised availability of a wide variety of
2058 high-quality tools which support some of the most important
2059 related standards is not immediate. Many tools are likely to be
Fred Drake67f193f2001-07-09 16:04:03 +00002060 free, and the portability issues of those which are, are not
2061 expected to be significant.
Fred Drakeacffaee1999-03-16 16:09:13 +00002062
Fred Drake67f193f2001-07-09 16:04:03 +00002063 It turns out that converting to an XML or SGML system holds
2064 promise for translators as well; how much can be done to ease the
2065 burden on translators remains to be seen, and may have some impact
2066 on the schema and specific technologies used.
2067
2068 XXX Eventual migration to XML.
2069
2070 The documentation will be moved to XML in the future, and tools
2071 are being written which will convert the documentation from the
2072 current format to something close to a finished version, to the
2073 extent that the desired information is already present in the
2074 documentation. Some XSLT stylesheets have been started for
2075 presenting a preliminary XML version as HTML, but the results are
Fred Drakee7f343d2003-07-11 03:36:15 +00002076 fairly rough.
Fred Drake67f193f2001-07-09 16:04:03 +00002077
2078 The timeframe for the conversion is not clear since there doesn't
2079 seem to be much time available to work on this, but the appearant
2080 benefits are growing more substantial at a moderately rapid pace.
2081
Fred Drakeacffaee1999-03-16 16:09:13 +00002082
2083 \subsection{Discussion Forums \label{discussion}}
2084
2085 Discussion of the future of the Python documentation and related
Fred Drake7a737df1999-04-23 14:41:44 +00002086 topics takes place in the Documentation Special Interest Group, or
2087 ``Doc-SIG.'' Information on the group, including mailing list
2088 archives and subscription information, is available at
Fred Drakeacffaee1999-03-16 16:09:13 +00002089 \url{http://www.python.org/sigs/doc-sig/}. The SIG is open to all
2090 interested parties.
2091
2092 Comments and bug reports on the standard documents should be sent
Fred Drake9d843082003-07-30 02:55:28 +00002093 to \email{docs@python.org}. This may include comments
Fred Drakeadade921999-04-22 13:05:27 +00002094 about formatting, content, grammatical and spelling errors, or
Fred Draked1fb7791999-05-17 16:33:54 +00002095 this document. You can also send comments on this document
2096 directly to the author at \email{fdrake@acm.org}.
Fred Drakeacffaee1999-03-16 16:09:13 +00002097
Skip Montanaro176bda4cd2002-04-19 04:50:44 +00002098\input{doc.ind}
2099
Fred Drakeacffaee1999-03-16 16:09:13 +00002100\end{document}