blob: e4b91aca245ea30f65f9a366805d600694f3a762 [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 Drake64f164e2004-11-13 04:41:01 +0000123 {\citetitle[../ext/ext.html]
124 {Extending and Embedding the Python Interpreter}}
Fred Drakee7f343d2003-07-11 03:36:15 +0000125 \lineii{inst/}
Fred Drake31edf4d2000-09-07 20:06:07 +0000126 {\citetitle[../inst/inst.html]{Installing Python Modules}}
Fred Drakee7f343d2003-07-11 03:36:15 +0000127 \lineii{lib/}
Fred Drake31edf4d2000-09-07 20:06:07 +0000128 {\citetitle[../lib/lib.html]{Python Library Reference}}
Fred Drakee7f343d2003-07-11 03:36:15 +0000129 \lineii{mac/}
Fred Drake31edf4d2000-09-07 20:06:07 +0000130 {\citetitle[../mac/mac.html]{Macintosh Module Reference}}
Fred Drakee7f343d2003-07-11 03:36:15 +0000131 \lineii{ref/}
Fred Drake31edf4d2000-09-07 20:06:07 +0000132 {\citetitle[../ref/ref.html]{Python Reference Manual}}
Fred Drakee7f343d2003-07-11 03:36:15 +0000133 \lineii{tut/}
Fred Drake31edf4d2000-09-07 20:06:07 +0000134 {\citetitle[../tut/tut.html]{Python Tutorial}}
Fred Drake64f164e2004-11-13 04:41:01 +0000135 \lineii{whatsnew/}
136 {\citetitle[../whatsnew/whatsnew24.html]
137 {What's New in Python \shortversion}}
Fred Drakee7f343d2003-07-11 03:36:15 +0000138 \end{tableii}
Fred Drakeacffaee1999-03-16 16:09:13 +0000139
140 \term{Format-Specific Output}
Fred Drakee7f343d2003-07-11 03:36:15 +0000141 Most output formats have a directory which contains a
142 \file{Makefile} which controls the generation of that format
143 and provides storage for the formatted documents. The only
144 variations within this category are the Portable Document
Fred Drake2c4e0091999-03-29 14:55:55 +0000145 Format (PDF) and PostScript versions are placed in the
Fred Drakee7f343d2003-07-11 03:36:15 +0000146 directories \file{paper-a4/} and \file{paper-letter/} (this
147 causes all the temporary files created by \LaTeX{} to be kept
148 in the same place for each paper size, where they can be more
149 easily ignored).
Fred Drakeacffaee1999-03-16 16:09:13 +0000150
Fred Drakee7f343d2003-07-11 03:36:15 +0000151 \begin{tableii}{p{.75in}|p{3in}}{filenq}{Directory}{Output Formats}
152 \lineii{html/}{HTML output}
153 \lineii{info/}{GNU info output}
154 \lineii{isilo/}{\ulink{iSilo}{http://www.isilo.com/}
155 documents (for Palm OS devices)}
156 \lineii{paper-a4/}{PDF and PostScript, A4 paper}
157 \lineii{paper-letter/}{PDF and PostScript, US-Letter paper}
158 \end{tableii}
Fred Drake2f4bebd1999-04-28 16:43:11 +0000159
Fred Drakeacffaee1999-03-16 16:09:13 +0000160 \term{Supplemental Files}
Fred Drakee7f343d2003-07-11 03:36:15 +0000161 Some additional directories are used to store supplemental
162 files used for the various processes. Directories are
163 included for the shared \LaTeX{} document classes, the
164 \LaTeX2HTML support, template files for various document
165 components, and the scripts used to perform various steps in
166 the formatting processes.
Fred Drake2f4bebd1999-04-28 16:43:11 +0000167
Fred Drakee7f343d2003-07-11 03:36:15 +0000168 \begin{tableii}{p{.75in}|p{3in}}{filenq}{Directory}{Contents}
Fred Drake2bc9b2f2003-09-27 07:18:52 +0000169 \lineii{commontex/}{Document content shared among documents}
170 \lineii{perl/} {Support for \LaTeX2HTML processing}
Fred Drakee7f343d2003-07-11 03:36:15 +0000171 \lineii{templates/}{Example files for source documents}
172 \lineii{texinputs/}{Style implementation for \LaTeX}
Fred Drake2bc9b2f2003-09-27 07:18:52 +0000173 \lineii{tools/} {Custom processing scripts}
Fred Drakee7f343d2003-07-11 03:36:15 +0000174 \end{tableii}
Fred Drake2f4bebd1999-04-28 16:43:11 +0000175
Fred Drakeacffaee1999-03-16 16:09:13 +0000176 \end{definitions}
177
Fred Drake2c4e0091999-03-29 14:55:55 +0000178
Fred Drakef1b3de82001-07-24 14:38:34 +0000179\section{Style Guide \label{style-guide}}
Fred Drake432cef02001-07-06 22:34:33 +0000180
181 The Python documentation should follow the \citetitle
Fred Drake192b95b2003-07-11 03:34:17 +0000182 [http://developer.apple.com/documentation/UserExperience/Conceptual/APStyleGuide/AppleStyleGuide2003.pdf]
Fred Drake432cef02001-07-06 22:34:33 +0000183 {Apple Publications Style Guide} wherever possible. This particular
184 style guide was selected mostly because it seems reasonable and is
Fred Drake192b95b2003-07-11 03:34:17 +0000185 easy to get online.
Fred Drake432cef02001-07-06 22:34:33 +0000186
187 Topics which are not covered in the Apple's style guide will be
188 discussed in this document if necessary.
189
190 Many special names are used in the Python documentation, including
191 the names of operating systems, programming languages, standards
192 bodies, and the like. Many of these were assigned \LaTeX{} macros
193 at some point in the distant past, and these macros lived on long
Fred Drake9120df32001-07-14 02:34:12 +0000194 past their usefulness. In the current markup, most of these entities
195 are not assigned any special markup, but the preferred spellings are
Fred Drake432cef02001-07-06 22:34:33 +0000196 given here to aid authors in maintaining the consistency of
197 presentation in the Python documentation.
198
Fred Drake9120df32001-07-14 02:34:12 +0000199 Other terms and words deserve special mention as well; these conventions
200 should be used to ensure consistency throughout the documentation:
201
Fred Drake432cef02001-07-06 22:34:33 +0000202 \begin{description}
Fred Drake9120df32001-07-14 02:34:12 +0000203 \item[CPU]
204 For ``central processing unit.'' Many style guides say this
205 should be spelled out on the first use (and if you must use it,
206 do so!). For the Python documentation, this abbreviation should
Raymond Hettinger68804312005-01-01 00:28:46 +0000207 be avoided since there's no reasonable way to predict which occurrence
Fred Drake9120df32001-07-14 02:34:12 +0000208 will be the first seen by the reader. It is better to use the
209 word ``processor'' instead.
210
211 \item[\POSIX]
Fred Drakee7f343d2003-07-11 03:36:15 +0000212 The name assigned to a particular group of standards. This is
213 always uppercase. Use the macro \macro{POSIX} to represent this
214 name.
Fred Drake432cef02001-07-06 22:34:33 +0000215
216 \item[Python]
Fred Drakee7f343d2003-07-11 03:36:15 +0000217 The name of our favorite programming language is always
218 capitalized.
Fred Drake432cef02001-07-06 22:34:33 +0000219
220 \item[Unicode]
Fred Drakee7f343d2003-07-11 03:36:15 +0000221 The name of a character set and matching encoding. This is
222 always written capitalized.
Fred Drake9120df32001-07-14 02:34:12 +0000223
224 \item[\UNIX]
Fred Drakee7f343d2003-07-11 03:36:15 +0000225 The name of the operating system developed at AT\&T Bell Labs
226 in the early 1970s. Use the macro \macro{UNIX} to use this
227 name.
Fred Drake432cef02001-07-06 22:34:33 +0000228 \end{description}
229
230
Fred Drakeadade921999-04-22 13:05:27 +0000231\section{\LaTeX{} Primer \label{latex-primer}}
Fred Drake2c4e0091999-03-29 14:55:55 +0000232
Fred Drakeadade921999-04-22 13:05:27 +0000233 This section is a brief introduction to \LaTeX{} concepts and
234 syntax, to provide authors enough information to author documents
Fred Drake20a175a2004-10-18 21:30:40 +0000235 productively without having to become ``\TeX{}nicians.'' This does
236 not teach everything needed to know about writing \LaTeX{} for
237 Python documentation; many of the standard ``environments'' are not
238 described here (though you will learn how to mark something as an
239 environment).
Fred Drakeadade921999-04-22 13:05:27 +0000240
Fred Drake5eb992b1999-06-11 14:25:45 +0000241 Perhaps the most important concept to keep in mind while marking up
Fred Drake02997492000-09-21 05:26:43 +0000242 Python documentation is that while \TeX{} is unstructured, \LaTeX{} was
Fred Drakee7f343d2003-07-11 03:36:15 +0000243 designed as a layer on top of \TeX{} which specifically supports
Fred Drake5eb992b1999-06-11 14:25:45 +0000244 structured markup. The Python-specific markup is intended to extend
245 the structure provided by standard \LaTeX{} document classes to
246 support additional information specific to Python.
247
Fred Drakeadade921999-04-22 13:05:27 +0000248 \LaTeX{} documents contain two parts: the preamble and the body.
249 The preamble is used to specify certain metadata about the document
250 itself, such as the title, the list of authors, the date, and the
251 \emph{class} the document belongs to. Additional information used
252 to control index generation and the use of bibliographic databases
Fred Drake7a737df1999-04-23 14:41:44 +0000253 can also be placed in the preamble. For most authors, the preamble
Fred Drakeadade921999-04-22 13:05:27 +0000254 can be most easily created by copying it from an existing document
255 and modifying a few key pieces of information.
256
257 The \dfn{class} of a document is used to place a document within a
258 broad category of documents and set some fundamental formatting
259 properties. For Python documentation, two classes are used: the
260 \code{manual} class and the \code{howto} class. These classes also
261 define the additional markup used to document Python concepts and
262 structures. Specific information about these classes is provided in
Fred Drake7a737df1999-04-23 14:41:44 +0000263 section \ref{classes}, ``Document Classes,'' below. The first thing
Fred Drakeadade921999-04-22 13:05:27 +0000264 in the preamble is the declaration of the document's class.
265
266 After the class declaration, a number of \emph{macros} are used to
267 provide further information about the document and setup any
Fred Drake7a737df1999-04-23 14:41:44 +0000268 additional markup that is needed. No output is generated from the
269 preamble; it is an error to include free text in the preamble
270 because it would cause output.
Fred Drakeadade921999-04-22 13:05:27 +0000271
272 The document body follows the preamble. This contains all the
Fred Drake63568aa2000-10-19 05:36:10 +0000273 printed components of the document marked up structurally. Generic
Fred Drake4c6f17a2001-04-18 05:12:47 +0000274 \LaTeX{} structures include hierarchical sections, numbered and
275 bulleted lists, and special structures for the document abstract and
276 indexes.
Fred Drakeadade921999-04-22 13:05:27 +0000277
Fred Drakef1b3de82001-07-24 14:38:34 +0000278 \subsection{Syntax \label{latex-syntax}}
Fred Drake63568aa2000-10-19 05:36:10 +0000279
Fred Drake4c6f17a2001-04-18 05:12:47 +0000280 There are some things that an author of Python documentation needs
281 to know about \LaTeX{} syntax.
Fred Drake63568aa2000-10-19 05:36:10 +0000282
283 A \dfn{comment} is started by the ``percent'' character
284 (\character{\%}) and continues through the end of the line and all
285 leading whitespace on the following line. This is a little
286 different from any programming language I know of, so an example
287 is in order:
288
289\begin{verbatim}
290This is text.% comment
291 This is more text. % another comment
292Still more text.
293\end{verbatim}
294
295 The first non-comment character following the first comment is the
296 letter \character{T} on the second line; the leading whitespace on
297 that line is consumed as part of the first comment. This means
298 that there is no space between the first and second sentences, so
299 the period and letter \character{T} will be directly adjacent in
300 the typeset document.
301
302 Note also that though the first non-comment character after the
303 second comment is the letter \character{S}, there is whitespace
304 preceding the comment, so the two sentences are separated as
305 expected.
306
307 A \dfn{group} is an enclosure for a collection of text and
308 commands which encloses the formatting context and constrains the
309 scope of any changes to that context made by commands within the
310 group. Groups can be nested hierarchically. The formatting
311 context includes the font and the definition of additional macros
312 (or overrides of macros defined in outer groups). Syntactically,
313 groups are enclosed in braces:
314
315\begin{verbatim}
316{text in a group}
317\end{verbatim}
318
Fred Drake4c6f17a2001-04-18 05:12:47 +0000319 An alternate syntax for a group using brackets, \code{[...]}, is
Fred Drake63568aa2000-10-19 05:36:10 +0000320 used by macros and environment constructors which take optional
321 parameters; brackets do not normally hold syntactic significance.
322 A degenerate group, containing only one atomic bit of content,
323 does not need to have an explicit group, unless it is required to
324 avoid ambiguity. Since Python tends toward the explicit, groups
325 are also made explicit in the documentation markup.
326
327 Groups are used only sparingly in the Python documentation, except
328 for their use in marking parameters to macros and environments.
329
Fred Drake4c6f17a2001-04-18 05:12:47 +0000330 A \dfn{macro} is usually a simple construct which is identified by
Fred Drake63568aa2000-10-19 05:36:10 +0000331 name and can take some number of parameters. In normal \LaTeX{}
332 usage, one of these can be optional. The markup is introduced
333 using the backslash character (\character{\e}), and the name is
334 given by alphabetic characters (no digits, hyphens, or
335 underscores). Required parameters should be marked as a group,
336 and optional parameters should be marked using the alternate
337 syntax for a group.
338
Neal Norwitz750f0602004-08-01 22:36:40 +0000339 For example, a macro which takes a single parameter
Fred Drake63568aa2000-10-19 05:36:10 +0000340 would appear like this:
341
342\begin{verbatim}
343\name{parameter}
344\end{verbatim}
345
346 A macro which takes an optional parameter would be typed like this
Raymond Hettinger5232f502004-03-25 08:51:36 +0000347 when the optional parameter is given:
Fred Drake63568aa2000-10-19 05:36:10 +0000348
349\begin{verbatim}
350\name[optional]
351\end{verbatim}
352
353 If both optional and required parameters are to be required, it
354 looks like this:
355
356\begin{verbatim}
357\name[optional]{required}
358\end{verbatim}
359
360 A macro name may be followed by a space or newline; a space
361 between the macro name and any parameters will be consumed, but
362 this usage is not practiced in the Python documentation. Such a
Fred Drake4c6f17a2001-04-18 05:12:47 +0000363 space is still consumed if there are no parameters to the macro,
Fred Drake63568aa2000-10-19 05:36:10 +0000364 in which case inserting an empty group (\code{\{\}}) or explicit
365 word space (\samp{\e\ }) immediately after the macro name helps to
366 avoid running the expansion of the macro into the following text.
367 Macros which take no parameters but which should not be followed
368 by a word space do not need special treatment if the following
369 character in the document source if not a name character (such as
Fred Drake4c6f17a2001-04-18 05:12:47 +0000370 punctuation).
Fred Drake63568aa2000-10-19 05:36:10 +0000371
372 Each line of this example shows an appropriate way to write text
373 which includes a macro which takes no parameters:
374
375\begin{verbatim}
376This \UNIX{} is followed by a space.
377This \UNIX\ is also followed by a space.
378\UNIX, followed by a comma, needs no additional markup.
379\end{verbatim}
380
Fred Draked097d482000-10-20 20:51:31 +0000381 An \dfn{environment} is a larger construct than a macro, and can
Fred Drake4c6f17a2001-04-18 05:12:47 +0000382 be used for things with more content than would conveniently fit
Fred Draked097d482000-10-20 20:51:31 +0000383 in a macro parameter. They are primarily used when formatting
384 parameters need to be changed before and after a large chunk of
385 content, but the content itself needs to be highly flexible. Code
386 samples are presented using an environment, and descriptions of
Fred Drake4c6f17a2001-04-18 05:12:47 +0000387 functions, methods, and classes are also marked using environments.
Fred Draked097d482000-10-20 20:51:31 +0000388
389 Since the content of an environment is free-form and can consist
390 of several paragraphs, they are actually marked using a pair of
391 macros: \macro{begin} and \macro{end}. These macros both take the
392 name of the environment as a parameter. An example is the
393 environment used to mark the abstract of a document:
394
395\begin{verbatim}
396\begin{abstract}
397 This is the text of the abstract. It concisely explains what
398 information is found in the document.
399
400 It can consist of multiple paragraphs.
401\end{abstract}
402\end{verbatim}
403
404 An environment can also have required and optional parameters of
405 its own. These follow the parameter of the \macro{begin} macro.
406 This example shows an environment which takes a single required
407 parameter:
408
409\begin{verbatim}
Fred Drake2bbc6972001-03-28 16:51:20 +0000410\begin{datadesc}{controlnames}
Fred Draked097d482000-10-20 20:51:31 +0000411 A 33-element string array that contains the \ASCII{} mnemonics for
412 the thirty-two \ASCII{} control characters from 0 (NUL) to 0x1f
413 (US), in order, plus the mnemonic \samp{SP} for the space character.
414\end{datadesc}
415\end{verbatim}
Fred Drake63568aa2000-10-19 05:36:10 +0000416
Fred Drake4c6f17a2001-04-18 05:12:47 +0000417 There are a number of less-used marks in \LaTeX{} which are used
Fred Drakee789ea12002-03-13 02:48:24 +0000418 to enter characters which are not found in \ASCII{} or which a
419 considered special, or \emph{active} in \TeX{} or \LaTeX. Given
420 that these are often used adjacent to other characters, the markup
421 required to produce the proper character may need to be followed
422 by a space or an empty group, or the markup can be enclosed in a
423 group. Some which are found in Python documentation are:
Fred Drake63568aa2000-10-19 05:36:10 +0000424
Fred Draked097d482000-10-20 20:51:31 +0000425\begin{tableii}{c|l}{textrm}{Character}{Markup}
Fred Drakee789ea12002-03-13 02:48:24 +0000426 \lineii{\textasciicircum}{\code{\e textasciicircum}}
427 \lineii{\textasciitilde}{\code{\e textasciitilde}}
428 \lineii{\textgreater}{\code{\e textgreater}}
429 \lineii{\textless}{\code{\e textless}}
Fred Draked097d482000-10-20 20:51:31 +0000430 \lineii{\c c}{\code{\e c c}}
431 \lineii{\"o}{\code{\e"o}}
432 \lineii{\o}{\code{\e o}}
433\end{tableii}
Fred Drake63568aa2000-10-19 05:36:10 +0000434
435
Skip Montanaro176bda4cd2002-04-19 04:50:44 +0000436 \subsection{Hierarchical Structure \label{latex-structure}}
Fred Drake63568aa2000-10-19 05:36:10 +0000437
Fred Draked097d482000-10-20 20:51:31 +0000438 \LaTeX{} expects documents to be arranged in a conventional,
439 hierarchical way, with chapters, sections, sub-sections,
440 appendixes, and the like. These are marked using macros rather
441 than environments, probably because the end of a section can be
442 safely inferred when a section of equal or higher level starts.
443
444 There are six ``levels'' of sectioning in the document classes
Fred Drake4c6f17a2001-04-18 05:12:47 +0000445 used for Python documentation, and the deepest two
446 levels\footnote{The deepest levels have the highest numbers in the
447 table.} are not used. The levels are:
Fred Draked097d482000-10-20 20:51:31 +0000448
449 \begin{tableiii}{c|l|c}{textrm}{Level}{Macro Name}{Notes}
450 \lineiii{1}{\macro{chapter}}{(1)}
451 \lineiii{2}{\macro{section}}{}
452 \lineiii{3}{\macro{subsection}}{}
Fred Drakeb7a52c92000-11-27 20:10:18 +0000453 \lineiii{4}{\macro{subsubsection}}{}
Fred Draked097d482000-10-20 20:51:31 +0000454 \lineiii{5}{\macro{paragraph}}{(2)}
455 \lineiii{6}{\macro{subparagraph}}{}
456 \end{tableiii}
457
458 \noindent
459 Notes:
460
461 \begin{description}
462 \item[(1)]
463 Only used for the \code{manual} documents, as described in
464 section \ref{classes}, ``Document Classes.''
465 \item[(2)]
466 Not the same as a paragraph of text; nobody seems to use this.
467 \end{description}
Fred Drake2c4e0091999-03-29 14:55:55 +0000468
469
Fred Drake20a175a2004-10-18 21:30:40 +0000470 \subsection{Common Environments \label{latex-environments}}
471
472 \LaTeX{} provides a variety of environments even without the
473 additional markup provided by the Python-specific document classes
Raymond Hettinger68804312005-01-01 00:28:46 +0000474 introduced in the next section. The following environments are
Fred Drake20a175a2004-10-18 21:30:40 +0000475 provided as part of standard \LaTeX{} and are being used in the
476 standard Python documentation; descriptions will be added here as
477 time allows.
478
479\begin{verbatim}
480abstract
481alltt
482description
483displaymath
484document
485enumerate
486figure
487flushleft
488itemize
489list
490math
491quotation
492quote
493sloppypar
494verbatim
495\end{verbatim}
496
497
Fred Drakeadade921999-04-22 13:05:27 +0000498\section{Document Classes \label{classes}}
Fred Drakeacffaee1999-03-16 16:09:13 +0000499
500 Two \LaTeX{} document classes are defined specifically for use with
501 the Python documentation. The \code{manual} class is for large
502 documents which are sectioned into chapters, and the \code{howto}
503 class is for smaller documents.
504
505 The \code{manual} documents are larger and are used for most of the
506 standard documents. This document class is based on the standard
507 \LaTeX{} \code{report} class and is formatted very much like a long
Fred Drake698d5201999-11-10 15:54:57 +0000508 technical report. The \citetitle[../ref/ref.html]{Python Reference
509 Manual} is a good example of a \code{manual} document, and the
510 \citetitle[../lib/lib.html]{Python Library Reference} is a large
511 example.
Fred Drakeacffaee1999-03-16 16:09:13 +0000512
513 The \code{howto} documents are shorter, and don't have the large
514 structure of the \code{manual} documents. This class is based on
515 the standard \LaTeX{} \code{article} class and is formatted somewhat
516 like the Linux Documentation Project's ``HOWTO'' series as done
517 originally using the LinuxDoc software. The original intent for the
518 document class was that it serve a similar role as the LDP's HOWTO
519 series, but the applicability of the class turns out to be somewhat
Fred Drake02997492000-09-21 05:26:43 +0000520 broader. This class is used for ``how-to'' documents (this
Fred Drakeacffaee1999-03-16 16:09:13 +0000521 document is an example) and for shorter reference manuals for small,
522 fairly cohesive module libraries. Examples of the later use include
Fred Drake6a547c72000-09-15 22:11:24 +0000523\citetitle[http://starship.python.net/crew/fdrake/manuals/krb5py/krb5py.html]{Using
Fred Drakeacffaee1999-03-16 16:09:13 +0000524 Kerberos from Python}, which contains reference material for an
525 extension package. These documents are roughly equivalent to a
526 single chapter from a larger work.
527
528
Fred Drakef1b3de82001-07-24 14:38:34 +0000529\section{Special Markup Constructs \label{special-constructs}}
Fred Drakeacffaee1999-03-16 16:09:13 +0000530
Fred Drake2c4e0091999-03-29 14:55:55 +0000531 The Python document classes define a lot of new environments and
532 macros. This section contains the reference material for these
Fred Drake20a175a2004-10-18 21:30:40 +0000533 facilities. Documentation for ``standard'' \LaTeX{} constructs is
534 not included here, though they are used in the Python documentation.
Fred Drake2c4e0091999-03-29 14:55:55 +0000535
Fred Drakeaf2b7142000-09-14 20:11:05 +0000536 \subsection{Markup for the Preamble \label{preamble-info}}
537
538 \begin{macrodesc}{release}{\p{ver}}
539 Set the version number for the software described in the
540 document.
541 \end{macrodesc}
542
543 \begin{macrodesc}{setshortversion}{\p{sver}}
544 Specify the ``short'' version number of the documented software
545 to be \var{sver}.
546 \end{macrodesc}
547
Fred Drakee15956b2000-04-03 04:51:13 +0000548 \subsection{Meta-information Markup \label{meta-info}}
549
550 \begin{macrodesc}{sectionauthor}{\p{author}\p{email}}
551 Identifies the author of the current section. \var{author}
552 should be the author's name such that it can be used for
553 presentation (though it isn't), and \var{email} should be the
554 author's email address. The domain name portion of
555 the address should be lower case.
556
Fred Drakee7f343d2003-07-11 03:36:15 +0000557 No presentation is generated from this markup, but it is used to
Fred Drakee15956b2000-04-03 04:51:13 +0000558 help keep track of contributions.
559 \end{macrodesc}
560
Fred Drakeacffaee1999-03-16 16:09:13 +0000561 \subsection{Information Units \label{info-units}}
562
Fred Drake2f4bebd1999-04-28 16:43:11 +0000563 XXX Explain terminology, or come up with something more ``lay.''
Fred Drakeacffaee1999-03-16 16:09:13 +0000564
Fred Drakeadade921999-04-22 13:05:27 +0000565 There are a number of environments used to describe specific
566 features provided by modules. Each environment requires
567 parameters needed to provide basic information about what is being
568 described, and the environment content should be the description.
569 Most of these environments make entries in the general index (if
570 one is being produced for the document); if no index entry is
571 desired, non-indexing variants are available for many of these
572 environments. The environments have names of the form
573 \code{\var{feature}desc}, and the non-indexing variants are named
574 \code{\var{feature}descni}. The available variants are explicitly
575 included in the list below.
576
577 For each of these environments, the first parameter, \var{name},
578 provides the name by which the feature is accessed.
579
580 Environments which describe features of objects within a module,
581 such as object methods or data attributes, allow an optional
582 \var{type name} parameter. When the feature is an attribute of
583 class instances, \var{type name} only needs to be given if the
584 class was not the most recently described class in the module; the
585 \var{name} value from the most recent \env{classdesc} is implied.
586 For features of built-in or extension types, the \var{type name}
Fred Drake7a737df1999-04-23 14:41:44 +0000587 value should always be provided. Another special case includes
588 methods and members of general ``protocols,'' such as the
589 formatter and writer protocols described for the
590 \module{formatter} module: these may be documented without any
591 specific implementation classes, and will always require the
592 \var{type name} parameter to be provided.
Fred Drakeadade921999-04-22 13:05:27 +0000593
Fred Drake7be440d2000-09-16 21:23:25 +0000594 \begin{envdesc}{cfuncdesc}{\p{type}\p{name}\p{args}}
595 Environment used to described a C function. The \var{type}
596 should be specified as a \keyword{typedef} name, \code{struct
597 \var{tag}}, or the name of a primitive type. If it is a pointer
Fred Drake02997492000-09-21 05:26:43 +0000598 type, the trailing asterisk should not be preceded by a space.
Fred Drake7be440d2000-09-16 21:23:25 +0000599 \var{name} should be the name of the function (or function-like
600 pre-processor macro), and \var{args} should give the types and
601 names of the parameters. The names need to be given so they may
602 be used in the description.
603 \end{envdesc}
604
Fred Drake1251b0e2002-04-15 20:10:23 +0000605 \begin{envdesc}{cmemberdesc}{\p{container}\p{type}\p{name}}
606 Description for a structure member. \var{container} should be
607 the \keyword{typedef} name, if there is one, otherwise if should
608 be \samp{struct \var{tag}}. The type of the member should given
609 as \var{type}, and the name should be given as \var{name}. The
610 text of the description should include the range of values
611 allowed, how the value should be interpreted, and whether the
612 value can be changed. References to structure members in text
613 should use the \macro{member} macro.
614 \end{envdesc}
615
Fred Drake79bf99c2002-04-09 20:17:42 +0000616 \begin{envdesc}{csimplemacrodesc}{\p{name}}
617 Documentation for a ``simple'' macro. Simple macros are macros
618 which are used for code expansion, but which do not take
619 arguments so cannot be described as functions. This is not to
Neil Schemenauerc4932292005-06-18 17:54:13 +0000620 be used for simple constant definitions. Examples of its use
Fred Drake79bf99c2002-04-09 20:17:42 +0000621 in the Python documentation include
622 \csimplemacro{PyObject_HEAD} and
623 \csimplemacro{Py_BEGIN_ALLOW_THREADS}.
624 \end{envdesc}
625
Fred Drake7be440d2000-09-16 21:23:25 +0000626 \begin{envdesc}{ctypedesc}{\op{tag}\p{name}}
627 Environment used to described a C type. The \var{name}
628 parameter should be the \keyword{typedef} name. If the type is
629 defined as a \keyword{struct} without a \keyword{typedef},
630 \var{name} should have the form \code{struct \var{tag}}.
631 \var{name} will be added to the index unless \var{tag} is
632 provided, in which case \var{tag} will be used instead.
633 \var{tag} should not be used for a \keyword{typedef} name.
634 \end{envdesc}
635
636 \begin{envdesc}{cvardesc}{\p{type}\p{name}}
637 Description of a global C variable. \var{type} should be the
638 \keyword{typedef} name, \code{struct \var{tag}}, or the name of
639 a primitive type. If variable has a pointer type, the trailing
Fred Drake02997492000-09-21 05:26:43 +0000640 asterisk should \emph{not} be preceded by a space.
Fred Drake7be440d2000-09-16 21:23:25 +0000641 \end{envdesc}
642
Fred Drakeadade921999-04-22 13:05:27 +0000643 \begin{envdesc}{datadesc}{\p{name}}
644 This environment is used to document global data in a module,
645 including both variables and values used as ``defined
646 constants.'' Class and object attributes are not documented
647 using this environment.
Fred Drakeacffaee1999-03-16 16:09:13 +0000648 \end{envdesc}
Fred Drake7a737df1999-04-23 14:41:44 +0000649 \begin{envdesc}{datadescni}{\p{name}}
Fred Drakeacffaee1999-03-16 16:09:13 +0000650 Like \env{datadesc}, but without creating any index entries.
651 \end{envdesc}
652
Fred Drake9f2376d2001-05-11 01:01:12 +0000653 \begin{envdesc}{excclassdesc}{\p{name}\p{constructor parameters}}
Raymond Hettinger68804312005-01-01 00:28:46 +0000654 Describe an exception defined by a class. \var{constructor
Fred Drake9f2376d2001-05-11 01:01:12 +0000655 parameters} should not include the \var{self} parameter or
656 the parentheses used in the call syntax. To describe an
657 exception class without describing the parameters to its
658 constructor, use the \env{excdesc} environment.
659 \end{envdesc}
660
Fred Drakeadade921999-04-22 13:05:27 +0000661 \begin{envdesc}{excdesc}{\p{name}}
Neal Norwitz847207a2003-05-29 02:17:23 +0000662 Describe an exception. In the case of class exceptions, the
Fred Drake9f2376d2001-05-11 01:01:12 +0000663 constructor parameters are not described; use \env{excclassdesc}
664 to describe an exception class and its constructor.
Fred Drakeacffaee1999-03-16 16:09:13 +0000665 \end{envdesc}
666
Fred Drakeadade921999-04-22 13:05:27 +0000667 \begin{envdesc}{funcdesc}{\p{name}\p{parameters}}
668 Describe a module-level function. \var{parameters} should
669 not include the parentheses used in the call syntax. Object
670 methods are not documented using this environment. Bound object
671 methods placed in the module namespace as part of the public
672 interface of the module are documented using this, as they are
673 equivalent to normal functions for most purposes.
674
675 The description should include information about the parameters
676 required and how they are used (especially whether mutable
677 objects passed as parameters are modified), side effects, and
678 possible exceptions. A small example may be provided.
Fred Drakeacffaee1999-03-16 16:09:13 +0000679 \end{envdesc}
Fred Drakeadade921999-04-22 13:05:27 +0000680 \begin{envdesc}{funcdescni}{\p{name}\p{parameters}}
Fred Drakeacffaee1999-03-16 16:09:13 +0000681 Like \env{funcdesc}, but without creating any index entries.
682 \end{envdesc}
683
Fred Drakeadade921999-04-22 13:05:27 +0000684 \begin{envdesc}{classdesc}{\p{name}\p{constructor parameters}}
685 Describe a class and its constructor. \var{constructor
686 parameters} should not include the \var{self} parameter or
687 the parentheses used in the call syntax.
Fred Drakeacffaee1999-03-16 16:09:13 +0000688 \end{envdesc}
689
Fred Drake9f2376d2001-05-11 01:01:12 +0000690 \begin{envdesc}{classdesc*}{\p{name}}
691 Describe a class without describing the constructor. This can
692 be used to describe classes that are merely containers for
693 attributes or which should never be instantiated or subclassed
694 by user code.
695 \end{envdesc}
696
Fred Drakeadade921999-04-22 13:05:27 +0000697 \begin{envdesc}{memberdesc}{\op{type name}\p{name}}
698 Describe an object data attribute. The description should
699 include information about the type of the data to be expected
700 and whether it may be changed directly.
Fred Drakeacffaee1999-03-16 16:09:13 +0000701 \end{envdesc}
Fred Drakeadade921999-04-22 13:05:27 +0000702 \begin{envdesc}{memberdescni}{\op{type name}\p{name}}
Fred Drakeacffaee1999-03-16 16:09:13 +0000703 Like \env{memberdesc}, but without creating any index entries.
704 \end{envdesc}
705
Fred Drakeadade921999-04-22 13:05:27 +0000706 \begin{envdesc}{methoddesc}{\op{type name}\p{name}\p{parameters}}
707 Describe an object method. \var{parameters} should not include
708 the \var{self} parameter or the parentheses used in the call
709 syntax. The description should include similar information to
710 that described for \env{funcdesc}.
Fred Drakeacffaee1999-03-16 16:09:13 +0000711 \end{envdesc}
Fred Drakeadade921999-04-22 13:05:27 +0000712 \begin{envdesc}{methoddescni}{\op{type name}\p{name}\p{parameters}}
Fred Drakeacffaee1999-03-16 16:09:13 +0000713 Like \env{methoddesc}, but without creating any index entries.
714 \end{envdesc}
715
716
Fred Drakef1b3de82001-07-24 14:38:34 +0000717 \subsection{Showing Code Examples \label{showing-examples}}
Fred Drake5eb992b1999-06-11 14:25:45 +0000718
719 Examples of Python source code or interactive sessions are
720 represented as \env{verbatim} environments. This environment
721 is a standard part of \LaTeX{}. It is important to only use
722 spaces for indentation in code examples since \TeX{} drops tabs
723 instead of converting them to spaces.
724
725 Representing an interactive session requires including the prompts
726 and output along with the Python code. No special markup is
Fred Drake63568aa2000-10-19 05:36:10 +0000727 required for interactive sessions. After the last line of input
728 or output presented, there should not be an ``unused'' primary
729 prompt; this is an example of what \emph{not} to do:
730
731\begin{verbatim}
732>>> 1 + 1
7332
Fred Drakee7f343d2003-07-11 03:36:15 +0000734>>>
Fred Drake63568aa2000-10-19 05:36:10 +0000735\end{verbatim}
Fred Drake5eb992b1999-06-11 14:25:45 +0000736
737 Within the \env{verbatim} environment, characters special to
738 \LaTeX{} do not need to be specially marked in any way. The entire
739 example will be presented in a monospaced font; no attempt at
740 ``pretty-printing'' is made, as the environment must work for
Fred Drake63568aa2000-10-19 05:36:10 +0000741 non-Python code and non-code displays. There should be no blank
742 lines at the top or bottom of any \env{verbatim} display.
Fred Drake5eb992b1999-06-11 14:25:45 +0000743
Fred Drake66eed242001-06-18 14:59:58 +0000744 Longer displays of verbatim text may be included by storing the
745 example text in an external file containing only plain text. The
746 file may be included using the standard \macro{verbatiminput}
747 macro; this macro takes a single argument naming the file
748 containing the text. For example, to include the Python source
749 file \file{example.py}, use:
750
751\begin{verbatim}
752\verbatiminput{example.py}
753\end{verbatim}
754
755 Use of \macro{verbatiminput} allows easier use of special editing
756 modes for the included file. The file should be placed in the
757 same directory as the \LaTeX{} files for the document.
758
Fred Drake5eb992b1999-06-11 14:25:45 +0000759 The Python Documentation Special Interest Group has discussed a
760 number of approaches to creating pretty-printed code displays and
761 interactive sessions; see the Doc-SIG area on the Python Web site
762 for more information on this topic.
763
764
Fred Drakef1b3de82001-07-24 14:38:34 +0000765 \subsection{Inline Markup \label{inline-markup}}
Fred Drakeacffaee1999-03-16 16:09:13 +0000766
Fred Drake87f768e1999-05-17 15:22:45 +0000767 The macros described in this section are used to mark just about
768 anything interesting in the document text. They may be used in
769 headings (though anything involving hyperlinks should be avoided
770 there) as well as in the body text.
Fred Drake2f4bebd1999-04-28 16:43:11 +0000771
772 \begin{macrodesc}{bfcode}{\p{text}}
773 Like \macro{code}, but also makes the font bold-face.
774 \end{macrodesc}
775
776 \begin{macrodesc}{cdata}{\p{name}}
777 The name of a C-language variable.
778 \end{macrodesc}
779
780 \begin{macrodesc}{cfunction}{\p{name}}
781 The name of a C-language function. \var{name} should include the
782 function name and the trailing parentheses.
783 \end{macrodesc}
784
785 \begin{macrodesc}{character}{\p{char}}
786 A character when discussing the character rather than a one-byte
787 string value. The character will be typeset as with \macro{samp}.
788 \end{macrodesc}
789
Fred Drake29a710f1999-11-10 22:51:18 +0000790 \begin{macrodesc}{citetitle}{\op{url}\p{title}}
791 A title for a referenced publication. If \var{url} is specified,
792 the title will be made into a hyperlink when formatted as HTML.
793 \end{macrodesc}
794
Fred Drake2f4bebd1999-04-28 16:43:11 +0000795 \begin{macrodesc}{class}{\p{name}}
796 A class name; a dotted name may be used.
797 \end{macrodesc}
798
799 \begin{macrodesc}{code}{\p{text}}
800 A short code fragment or literal constant value. Typically, it
801 should not include any spaces since no quotation marks are
802 added.
803 \end{macrodesc}
804
805 \begin{macrodesc}{constant}{\p{name}}
806 The name of a ``defined'' constant. This may be a C-language
807 \code{\#define} or a Python variable that is not intended to be
808 changed.
809 \end{macrodesc}
810
Fred Drake79bf99c2002-04-09 20:17:42 +0000811 \begin{macrodesc}{csimplemacro}{\p{name}}
812 The name of a ``simple'' macro. Simple macros are macros
813 which are used for code expansion, but which do not take
814 arguments so cannot be described as functions. This is not to
Neil Schemenauerc4932292005-06-18 17:54:13 +0000815 be used for simple constant definitions. Examples of its use
Fred Drake79bf99c2002-04-09 20:17:42 +0000816 in the Python documentation include
817 \csimplemacro{PyObject_HEAD} and
818 \csimplemacro{Py_BEGIN_ALLOW_THREADS}.
819 \end{macrodesc}
820
Fred Drake2f4bebd1999-04-28 16:43:11 +0000821 \begin{macrodesc}{ctype}{\p{name}}
822 The name of a C \keyword{typedef} or structure. For structures
823 defined without a \keyword{typedef}, use \code{\e ctype\{struct
824 struct_tag\}} to make it clear that the \keyword{struct} is
825 required.
826 \end{macrodesc}
827
828 \begin{macrodesc}{deprecated}{\p{version}\p{what to do}}
Fred Drakee7f343d2003-07-11 03:36:15 +0000829 Declare whatever is being described as being deprecated starting
Fred Drake2f4bebd1999-04-28 16:43:11 +0000830 with release \var{version}. The text given as \var{what to do}
Fred Drakef79f2f92002-05-21 16:27:20 +0000831 should recommend something to use instead. It should be
832 complete sentences. The entire deprecation notice will be
Raymond Hettinger68804312005-01-01 00:28:46 +0000833 presented as a separate paragraph; it should either precede or
Fred Drakef79f2f92002-05-21 16:27:20 +0000834 succeed the description of the deprecated feature.
Fred Drake2f4bebd1999-04-28 16:43:11 +0000835 \end{macrodesc}
836
837 \begin{macrodesc}{dfn}{\p{term}}
Fred Drakee7f343d2003-07-11 03:36:15 +0000838 Mark the defining instance of \var{term} in the text. (No index
Fred Drake2f4bebd1999-04-28 16:43:11 +0000839 entries are generated.)
840 \end{macrodesc}
841
Fred Draked1fb7791999-05-17 16:33:54 +0000842 \begin{macrodesc}{e}{}
Fred Drake27da2912004-02-09 21:00:29 +0000843 Produces a backslash. This is convenient in \macro{code},
Fred Drake29f59332004-02-10 18:30:22 +0000844 \macro{file}, and similar macros, and the \env{alltt}
845 environment, and is only defined there. To
Fred Drake27da2912004-02-09 21:00:29 +0000846 create a backslash in ordinary text (such as the contents of the
847 \macro{citetitle} macro), use the standard \macro{textbackslash}
848 macro.
Fred Draked1fb7791999-05-17 16:33:54 +0000849 \end{macrodesc}
850
Fred Drake2f4bebd1999-04-28 16:43:11 +0000851 \begin{macrodesc}{email}{\p{address}}
852 An email address. Note that this is \emph{not} hyperlinked in
Fred Drakee15956b2000-04-03 04:51:13 +0000853 any of the possible output formats. The domain name portion of
854 the address should be lower case.
Fred Drake2f4bebd1999-04-28 16:43:11 +0000855 \end{macrodesc}
856
857 \begin{macrodesc}{emph}{\p{text}}
858 Emphasized text; this will be presented in an italic font.
859 \end{macrodesc}
860
861 \begin{macrodesc}{envvar}{\p{name}}
862 An environment variable. Index entries are generated.
863 \end{macrodesc}
864
865 \begin{macrodesc}{exception}{\p{name}}
866 The name of an exception. A dotted name may be used.
867 \end{macrodesc}
868
869 \begin{macrodesc}{file}{\p{file or dir}}
870 The name of a file or directory. In the PDF and PostScript
871 outputs, single quotes and a font change are used to indicate
872 the file name, but no quotes are used in the HTML output.
Fred Drake64a5aaf2001-10-20 04:18:14 +0000873 \warning{The \macro{file} macro cannot be used in the
874 content of a section title due to processing limitations.}
Fred Drake2f4bebd1999-04-28 16:43:11 +0000875 \end{macrodesc}
876
877 \begin{macrodesc}{filenq}{\p{file or dir}}
878 Like \macro{file}, but single quotes are never used. This can
Fred Drakee7f343d2003-07-11 03:36:15 +0000879 be used in conjunction with tables if a column will only contain
Fred Drake2f4bebd1999-04-28 16:43:11 +0000880 file or directory names.
Fred Drake64a5aaf2001-10-20 04:18:14 +0000881 \warning{The \macro{filenq} macro cannot be used in the
882 content of a section title due to processing limitations.}
Fred Drake2f4bebd1999-04-28 16:43:11 +0000883 \end{macrodesc}
884
885 \begin{macrodesc}{function}{\p{name}}
886 The name of a Python function; dotted names may be used.
887 \end{macrodesc}
888
Fred Drake432cef02001-07-06 22:34:33 +0000889 \begin{macrodesc}{infinity}{}
890 The symbol for mathematical infinity: \infinity. Some Web
891 browsers are not able to render the HTML representation of this
892 symbol properly, but support is growing.
893 \end{macrodesc}
894
Fred Drake2f4bebd1999-04-28 16:43:11 +0000895 \begin{macrodesc}{kbd}{\p{key sequence}}
896 Mark a sequence of keystrokes. What form \var{key sequence}
897 takes may depend on platform- or application-specific
Fred Drake07178d22001-07-12 02:08:29 +0000898 conventions. When there are no relevant conventions, the names
899 of modifier keys should be spelled out, to improve accessibility
900 for new users and non-native speakers. For example, an
901 \program{xemacs} key sequence may be marked like
902 \code{\e kbd\{C-x C-f\}}, but without reference to a specific
903 application or platform, the same sequence should be marked as
904 \code{\e kbd\{Control-x Control-f\}}.
Fred Drake2f4bebd1999-04-28 16:43:11 +0000905 \end{macrodesc}
906
907 \begin{macrodesc}{keyword}{\p{name}}
908 The name of a keyword in a programming language.
909 \end{macrodesc}
910
Fred Drake8b3a7b52001-09-26 17:01:58 +0000911 \begin{macrodesc}{mailheader}{\p{name}}
912 The name of an \rfc{822}-style mail header. This markup does
913 not imply that the header is being used in an email message, but
914 can be used to refer to any header of the same ``style.'' This
915 is also used for headers defined by the various MIME
916 specifications. The header name should be entered in the same
917 way it would normally be found in practice, with the
918 camel-casing conventions being preferred where there is more
Fred Drake203d91a2001-09-26 18:43:20 +0000919 than one common usage. The colon which follows the name of the
920 header should not be included.
921 For example: \code{\e mailheader\{Content-Type\}}.
Fred Drake8b3a7b52001-09-26 17:01:58 +0000922 \end{macrodesc}
923
Fred Drake2f4bebd1999-04-28 16:43:11 +0000924 \begin{macrodesc}{makevar}{\p{name}}
925 The name of a \program{make} variable.
926 \end{macrodesc}
927
928 \begin{macrodesc}{manpage}{\p{name}\p{section}}
929 A reference to a \UNIX{} manual page.
930 \end{macrodesc}
931
932 \begin{macrodesc}{member}{\p{name}}
933 The name of a data attribute of an object.
934 \end{macrodesc}
935
936 \begin{macrodesc}{method}{\p{name}}
937 The name of a method of an object. \var{name} should include the
938 method name and the trailing parentheses. A dotted name may be
939 used.
940 \end{macrodesc}
941
942 \begin{macrodesc}{mimetype}{\p{name}}
Fred Drake8b3a7b52001-09-26 17:01:58 +0000943 The name of a MIME type, or a component of a MIME type (the
944 major or minor portion, taken alone).
Fred Drake2f4bebd1999-04-28 16:43:11 +0000945 \end{macrodesc}
946
947 \begin{macrodesc}{module}{\p{name}}
Fred Drake2b853412000-04-11 19:08:30 +0000948 The name of a module; a dotted name may be used. This should
949 also be used for package names.
Fred Drake2f4bebd1999-04-28 16:43:11 +0000950 \end{macrodesc}
951
952 \begin{macrodesc}{newsgroup}{\p{name}}
Fred Drake9120df32001-07-14 02:34:12 +0000953 The name of a Usenet newsgroup.
Fred Drake2f4bebd1999-04-28 16:43:11 +0000954 \end{macrodesc}
955
Fred Drake92350b32001-10-09 18:01:23 +0000956 \begin{macrodesc}{note}{\p{text}}
957 An especially important bit of information about an API that a
958 user should be aware of when using whatever bit of API the
959 note pertains to. This should be the last thing in the
960 paragraph as the end of the note is not visually marked in
Fred Drake64a5aaf2001-10-20 04:18:14 +0000961 any way. The content of \var{text} should be written in
962 complete sentences and include all appropriate punctuation.
Fred Drake92350b32001-10-09 18:01:23 +0000963 \end{macrodesc}
964
Fred Drake432cef02001-07-06 22:34:33 +0000965 \begin{macrodesc}{pep}{\p{number}}
966 A reference to a Python Enhancement Proposal. This generates
967 appropriate index entries. The text \samp{PEP \var{number}} is
968 generated; in the HTML output, this text is a hyperlink to an
969 online copy of the specified PEP.
970 \end{macrodesc}
971
972 \begin{macrodesc}{plusminus}{}
973 The symbol for indicating a value that may take a positive or
974 negative value of a specified magnitude, typically represented
975 by a plus sign placed over a minus sign. For example:
Fred Drake203d91a2001-09-26 18:43:20 +0000976 \code{\e plusminus 3\%{}}.
Fred Drake432cef02001-07-06 22:34:33 +0000977 \end{macrodesc}
978
Fred Drake2f4bebd1999-04-28 16:43:11 +0000979 \begin{macrodesc}{program}{\p{name}}
980 The name of an executable program. This may differ from the
Fred Drakee7f343d2003-07-11 03:36:15 +0000981 file name for the executable for some platforms. In particular,
982 the \file{.exe} (or other) extension should be omitted for
Martin v. Löwis36a4d8c2002-10-10 18:24:54 +0000983 Windows programs.
Fred Drake2f4bebd1999-04-28 16:43:11 +0000984 \end{macrodesc}
985
Fred Drake29a710f1999-11-10 22:51:18 +0000986 \begin{macrodesc}{programopt}{\p{option}}
Fred Drakece444982000-04-11 18:52:52 +0000987 A command-line option to an executable program. Use this only
Greg Ward8b46c712002-06-29 01:23:45 +0000988 for ``short'' options, and include the leading hyphen.
Fred Drakece444982000-04-11 18:52:52 +0000989 \end{macrodesc}
990
991 \begin{macrodesc}{longprogramopt}{\p{option}}
992 A long command-line option to an executable program. This
993 should only be used for long option names which will be prefixed
994 by two hyphens; the hyphens should not be provided as part of
995 \var{option}.
Fred Drake29a710f1999-11-10 22:51:18 +0000996 \end{macrodesc}
997
Fred Drake2f4bebd1999-04-28 16:43:11 +0000998 \begin{macrodesc}{refmodule}{\op{key}\p{name}}
Fred Drakee7f343d2003-07-11 03:36:15 +0000999 Like \macro{module}, but create a hyperlink to the documentation
Fred Drake2f4bebd1999-04-28 16:43:11 +00001000 for the named module. Note that the corresponding
1001 \macro{declaremodule} must be in the same document. If the
1002 \macro{declaremodule} defines a module key different from the
1003 module name, it must also be provided as \var{key} to the
1004 \macro{refmodule} macro.
1005 \end{macrodesc}
1006
1007 \begin{macrodesc}{regexp}{\p{string}}
1008 Mark a regular expression.
1009 \end{macrodesc}
1010
1011 \begin{macrodesc}{rfc}{\p{number}}
Fred Drakee7f343d2003-07-11 03:36:15 +00001012 A reference to an Internet Request for Comments. This generates
Fred Drake2f4bebd1999-04-28 16:43:11 +00001013 appropriate index entries. The text \samp{RFC \var{number}} is
1014 generated; in the HTML output, this text is a hyperlink to an
1015 online copy of the specified RFC.
1016 \end{macrodesc}
1017
1018 \begin{macrodesc}{samp}{\p{text}}
1019 A short code sample, but possibly longer than would be given
Fred Drakee7f343d2003-07-11 03:36:15 +00001020 using \macro{code}. Since quotation marks are added, spaces are
Fred Drake2f4bebd1999-04-28 16:43:11 +00001021 acceptable.
1022 \end{macrodesc}
1023
Fred Drakeaf2b7142000-09-14 20:11:05 +00001024 \begin{macrodesc}{shortversion}{}
1025 The ``short'' version number of the documented software, as
1026 specified using the \macro{setshortversion} macro in the
1027 preamble. For Python, the short version number for a release is
1028 the first three characters of the \code{sys.version} value. For
1029 example, versions 2.0b1 and 2.0.1 both have a short version of
1030 2.0. This may not apply for all packages; if
1031 \macro{setshortversion} is not used, this produces an empty
1032 expansion. See also the \macro{version} macro.
1033 \end{macrodesc}
1034
Fred Drake2f4bebd1999-04-28 16:43:11 +00001035 \begin{macrodesc}{strong}{\p{text}}
1036 Strongly emphasized text; this will be presented using a bold
1037 font.
1038 \end{macrodesc}
1039
Fred Drake432cef02001-07-06 22:34:33 +00001040 \begin{macrodesc}{ulink}{\p{text}\p{url}}
1041 A hypertext link with a target specified by a URL, but for which
1042 the link text should not be the title of the resource. For
1043 resources being referenced by name, use the \macro{citetitle}
1044 macro. Not all formatted versions support arbitrary hypertext
1045 links. Note that many characters are special to \LaTeX{} and
1046 this macro does not always do the right thing. In particular,
1047 the tilde character (\character{\~}) is mis-handled; encoding it
1048 as a hex-sequence does work, use \samp{\%7e} in place of the
1049 tilde character.
1050 \end{macrodesc}
1051
Fred Draked1fb7791999-05-17 16:33:54 +00001052 \begin{macrodesc}{url}{\p{url}}
Fred Drakee7f343d2003-07-11 03:36:15 +00001053 A URL (or URN). The URL will be presented as text. In the HTML
Fred Draked1fb7791999-05-17 16:33:54 +00001054 and PDF formatted versions, the URL will also be a hyperlink.
Fred Drake432cef02001-07-06 22:34:33 +00001055 This can be used when referring to external resources without
1056 specific titles; references to resources which have titles
1057 should be marked using the \macro{citetitle} macro. See the
1058 comments about special characters in the description of the
1059 \macro{ulink} macro for special considerations.
Fred Draked1fb7791999-05-17 16:33:54 +00001060 \end{macrodesc}
1061
Fred Drake2f4bebd1999-04-28 16:43:11 +00001062 \begin{macrodesc}{var}{\p{name}}
1063 The name of a variable or formal parameter in running text.
1064 \end{macrodesc}
1065
1066 \begin{macrodesc}{version}{}
Fred Drakeaf2b7142000-09-14 20:11:05 +00001067 The version number of the described software, as specified using
1068 \macro{release} in the preamble. See also the
1069 \macro{shortversion} macro.
Fred Drake2f4bebd1999-04-28 16:43:11 +00001070 \end{macrodesc}
Fred Drakeacffaee1999-03-16 16:09:13 +00001071
Fred Drake92350b32001-10-09 18:01:23 +00001072 \begin{macrodesc}{warning}{\p{text}}
1073 An important bit of information about an API that a user should
1074 be very aware of when using whatever bit of API the warning
1075 pertains to. This should be the last thing in the paragraph as
Fred Drake64a5aaf2001-10-20 04:18:14 +00001076 the end of the warning is not visually marked in any way. The
1077 content of \var{text} should be written in complete sentences
1078 and include all appropriate punctuation. This differs from
1079 \macro{note} in that it is recommended over \macro{note} for
1080 information regarding security.
Fred Drake92350b32001-10-09 18:01:23 +00001081 \end{macrodesc}
1082
Fred Drakec0ed9c42004-07-13 21:04:26 +00001083 The following two macros are used to describe information that's
1084 associated with changes from one release to another. For features
1085 which are described by a single paragraph, these are typically
1086 added as separate source lines at the end of the paragraph. When
1087 adding these to features described by multiple paragraphs, they
1088 are usually collected in a single separate paragraph after the
1089 description. When both \macro{versionadded} and
1090 \macro{versionchanged} are used, \macro{versionadded} should come
1091 first; the versions should be listed in chronological order. Both
1092 of these should come before availability statements. The location
1093 should be selected so the explanation makes sense and may vary as
1094 needed.
1095
1096 \begin{macrodesc}{versionadded}{\op{explanation}\p{version}}
1097 The version of Python which added the described feature to the
1098 library or C API. \var{explanation} should be a \emph{brief}
1099 explanation of the change consisting of a capitalized sentence
1100 fragment; a period will be appended by the formatting process.
1101 When this applies to an entire module, it should be placed at
1102 the top of the module section before any prose.
1103 \end{macrodesc}
1104
1105 \begin{macrodesc}{versionchanged}{\op{explanation}\p{version}}
1106 The version of Python in which the named feature was changed in
1107 some way (new parameters, changed side effects, etc.).
1108 \var{explanation} should be a \emph{brief} explanation of the
1109 change consisting of a capitalized sentence fragment; a
1110 period will be appended by the formatting process. This should
1111 not generally be applied to modules.
1112 \end{macrodesc}
1113
Fred Drakeacffaee1999-03-16 16:09:13 +00001114
Fred Drake6ca33772001-12-14 22:50:06 +00001115 \subsection{Miscellaneous Text Markup \label{misc-text-markup}}
1116
1117 In addition to the inline markup, some additional ``block'' markup
1118 is defined to make it easier to bring attention to various bits of
1119 text. The markup described here serves this purpose, and is
1120 intended to be used when marking one or more paragraphs or other
1121 block constructs (such as \env{verbatim} environments).
1122
1123 \begin{envdesc}{notice}{\op{type}}
1124 Label some paragraphs as being worthy of additional attention from
Raymond Hettinger68804312005-01-01 00:28:46 +00001125 the reader. What sort of attention is warranted can be indicated
Fred Drake6ca33772001-12-14 22:50:06 +00001126 by specifying the \var{type} of the notice. The only values
1127 defined for \var{type} are \code{note} and \code{warning}; these
1128 are equivalent in intent to the inline markup of the same name.
1129 If \var{type} is omitted, \code{note} is used. Additional values
1130 may be defined in the future.
1131 \end{envdesc}
1132
1133
Fred Drakef1b3de82001-07-24 14:38:34 +00001134 \subsection{Module-specific Markup \label{module-markup}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001135
1136 The markup described in this section is used to provide information
Georg Brandl29822522005-07-18 08:04:17 +00001137 about a module being documented. Each module should be documented
1138 in its own \macro{section}. A typical use of this markup
1139 appears at the top of that section and might look like this:
Fred Drakeacffaee1999-03-16 16:09:13 +00001140
1141\begin{verbatim}
1142\section{\module{spam} ---
1143 Access to the SPAM facility}
1144
1145\declaremodule{extension}{spam}
Fred Drake2c4e0091999-03-29 14:55:55 +00001146 \platform{Unix}
Fred Drake9120df32001-07-14 02:34:12 +00001147\modulesynopsis{Access to the SPAM facility of \UNIX.}
Fred Drake2c4e0091999-03-29 14:55:55 +00001148\moduleauthor{Jane Doe}{jane.doe@frobnitz.org}
Fred Drakeacffaee1999-03-16 16:09:13 +00001149\end{verbatim}
1150
Fred Drake7932ed02000-08-11 17:37:33 +00001151 Python packages\index{packages} --- collections of modules that can
1152 be described as a unit --- are documented using the same markup as
1153 modules. The name for a module in a package should be typed in
Fred Drake432cef02001-07-06 22:34:33 +00001154 ``fully qualified'' form (it should include the package name).
Fred Drake7932ed02000-08-11 17:37:33 +00001155 For example, a module ``foo'' in package ``bar'' should be marked as
Fred Drake203d91a2001-09-26 18:43:20 +00001156 \code{\e module\{bar.foo\}}, and the beginning of the reference
Fred Drake7932ed02000-08-11 17:37:33 +00001157 section would appear as:
1158
1159\begin{verbatim}
1160\section{\module{bar.foo} ---
1161 Module from the \module{bar} package}
1162
1163\declaremodule{extension}{bar.foo}
1164\modulesynopsis{Nifty module from the \module{bar} package.}
1165\moduleauthor{Jane Doe}{jane.doe@frobnitz.org}
1166\end{verbatim}
1167
1168 Note that the name of a package is also marked using
1169 \macro{module}.
1170
Fred Drakeadade921999-04-22 13:05:27 +00001171 \begin{macrodesc}{declaremodule}{\op{key}\p{type}\p{name}}
Fred Drake87f768e1999-05-17 15:22:45 +00001172 Requires two parameters: module type (\samp{standard},
1173 \samp{builtin}, \samp{extension}, or \samp{}), and the module
1174 name. An optional parameter should be given as the basis for the
1175 module's ``key'' used for linking to or referencing the section.
1176 The ``key'' should only be given if the module's name contains any
1177 underscores, and should be the name with the underscores stripped.
1178 Note that the \var{type} parameter must be one of the values
1179 listed above or an error will be printed. For modules which are
1180 contained in packages, the fully-qualified name should be given as
1181 \var{name} parameter. This should be the first thing after the
1182 \macro{section} used to introduce the module.
Fred Drakeacffaee1999-03-16 16:09:13 +00001183 \end{macrodesc}
1184
Fred Drakeadade921999-04-22 13:05:27 +00001185 \begin{macrodesc}{platform}{\p{specifier}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001186 Specifies the portability of the module. \var{specifier} is a
1187 comma-separated list of keys that specify what platforms the
1188 module is available on. The keys are short identifiers;
1189 examples that are in use include \samp{IRIX}, \samp{Mac},
1190 \samp{Windows}, and \samp{Unix}. It is important to use a key
Fred Drake7a737df1999-04-23 14:41:44 +00001191 which has already been used when applicable. This is used to
1192 provide annotations in the Module Index and the HTML and GNU info
1193 output.
Fred Drakeacffaee1999-03-16 16:09:13 +00001194 \end{macrodesc}
1195
Fred Drakeadade921999-04-22 13:05:27 +00001196 \begin{macrodesc}{modulesynopsis}{\p{text}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001197 The \var{text} is a short, ``one line'' description of the
1198 module that can be used as part of the chapter introduction.
Fred Drakeadade921999-04-22 13:05:27 +00001199 This is must be placed after \macro{declaremodule}.
Fred Drakeacffaee1999-03-16 16:09:13 +00001200 The synopsis is used in building the contents of the table
1201 inserted as the \macro{localmoduletable}. No text is
1202 produced at the point of the markup.
1203 \end{macrodesc}
1204
Fred Drakeadade921999-04-22 13:05:27 +00001205 \begin{macrodesc}{moduleauthor}{\p{name}\p{email}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001206 This macro is used to encode information about who authored a
1207 module. This is currently not used to generate output, but can be
1208 used to help determine the origin of the module.
1209 \end{macrodesc}
1210
1211
Fred Drakef1b3de82001-07-24 14:38:34 +00001212 \subsection{Library-level Markup \label{library-markup}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001213
1214 This markup is used when describing a selection of modules. For
Fred Drake698d5201999-11-10 15:54:57 +00001215 example, the \citetitle[../mac/mac.html]{Macintosh Library
1216 Modules} document uses this to help provide an overview of the
1217 modules in the collection, and many chapters in the
1218 \citetitle[../lib/lib.html]{Python Library Reference} use it for
Fred Drakeacffaee1999-03-16 16:09:13 +00001219 the same purpose.
1220
1221 \begin{macrodesc}{localmoduletable}{}
Fred Drake2c4e0091999-03-29 14:55:55 +00001222 If a \file{.syn} file exists for the current
Fred Drakeacffaee1999-03-16 16:09:13 +00001223 chapter (or for the entire document in \code{howto} documents), a
1224 \env{synopsistable} is created with the contents loaded from the
1225 \file{.syn} file.
1226 \end{macrodesc}
1227
1228
Fred Drakef1b3de82001-07-24 14:38:34 +00001229 \subsection{Table Markup \label{table-markup}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001230
1231 There are three general-purpose table environments defined which
1232 should be used whenever possible. These environments are defined
1233 to provide tables of specific widths and some convenience for
1234 formatting. These environments are not meant to be general
1235 replacements for the standard \LaTeX{} table environments, but can
1236 be used for an advantage when the documents are processed using
1237 the tools for Python documentation processing. In particular, the
1238 generated HTML looks good! There is also an advantage for the
Fred Drake67f193f2001-07-09 16:04:03 +00001239 eventual conversion of the documentation to XML (see section
Fred Drake2c4e0091999-03-29 14:55:55 +00001240 \ref{futures}, ``Future Directions'').
Fred Drakeacffaee1999-03-16 16:09:13 +00001241
1242 Each environment is named \env{table\var{cols}}, where \var{cols}
1243 is the number of columns in the table specified in lower-case
1244 Roman numerals. Within each of these environments, an additional
1245 macro, \macro{line\var{cols}}, is defined, where \var{cols}
1246 matches the \var{cols} value of the corresponding table
Fred Drake2c4e0091999-03-29 14:55:55 +00001247 environment. These are supported for \var{cols} values of
1248 \code{ii}, \code{iii}, and \code{iv}. These environments are all
Fred Drakeda72b932000-09-21 15:58:02 +00001249 built on top of the \env{tabular} environment. Variants based on
1250 the \env{longtable} environment are also provided.
Fred Drakeacffaee1999-03-16 16:09:13 +00001251
Fred Drake2b853412000-04-11 19:08:30 +00001252 Note that all tables in the standard Python documentation use
1253 vertical lines between columns, and this must be specified in the
1254 markup for each table. A general border around the outside of the
1255 table is not used, but would be the responsibility of the
Fred Drakeda72b932000-09-21 15:58:02 +00001256 processor; the document markup should not include an exterior
1257 border.
1258
1259 The \env{longtable}-based variants of the table environments are
1260 formatted with extra space before and after, so should only be
1261 used on tables which are long enough that splitting over multiple
1262 pages is reasonable; tables with fewer than twenty rows should
1263 never by marked using the long flavors of the table environments.
1264 The header row is repeated across the top of each part of the
1265 table.
Fred Drake2b853412000-04-11 19:08:30 +00001266
Fred Drakeadade921999-04-22 13:05:27 +00001267 \begin{envdesc}{tableii}{\p{colspec}\p{col1font}\p{heading1}\p{heading2}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001268 Create a two-column table using the \LaTeX{} column specifier
1269 \var{colspec}. The column specifier should indicate vertical
1270 bars between columns as appropriate for the specific table, but
1271 should not specify vertical bars on the outside of the table
1272 (that is considered a stylesheet issue). The \var{col1font}
1273 parameter is used as a stylistic treatment of the first column
1274 of the table: the first column is presented as
1275 \code{\e\var{col1font}\{column1\}}. To avoid treating the first
Fred Drakeadade921999-04-22 13:05:27 +00001276 column specially, \var{col1font} may be \samp{textrm}. The
Fred Drakeacffaee1999-03-16 16:09:13 +00001277 column headings are taken from the values \var{heading1} and
1278 \var{heading2}.
1279 \end{envdesc}
1280
Fred Drakeda72b932000-09-21 15:58:02 +00001281 \begin{envdesc}{longtableii}{\unspecified}
1282 Like \env{tableii}, but produces a table which may be broken
1283 across page boundaries. The parameters are the same as for
1284 \env{tableii}.
1285 \end{envdesc}
1286
Fred Drakeadade921999-04-22 13:05:27 +00001287 \begin{macrodesc}{lineii}{\p{column1}\p{column2}}
Fred Drakeda72b932000-09-21 15:58:02 +00001288 Create a single table row within a \env{tableii} or
1289 \env{longtableii} environment.
Fred Drakeacffaee1999-03-16 16:09:13 +00001290 The text for the first column will be generated by applying the
1291 macro named by the \var{col1font} value when the \env{tableii}
1292 was opened.
1293 \end{macrodesc}
1294
Fred Drakeadade921999-04-22 13:05:27 +00001295 \begin{envdesc}{tableiii}{\p{colspec}\p{col1font}\p{heading1}\p{heading2}\p{heading3}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001296 Like the \env{tableii} environment, but with a third column.
1297 The heading for the third column is given by \var{heading3}.
1298 \end{envdesc}
1299
Fred Drakeda72b932000-09-21 15:58:02 +00001300 \begin{envdesc}{longtableiii}{\unspecified}
1301 Like \env{tableiii}, but produces a table which may be broken
1302 across page boundaries. The parameters are the same as for
1303 \env{tableiii}.
1304 \end{envdesc}
1305
Fred Drakeadade921999-04-22 13:05:27 +00001306 \begin{macrodesc}{lineiii}{\p{column1}\p{column2}\p{column3}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001307 Like the \macro{lineii} macro, but with a third column. The
1308 text for the third column is given by \var{column3}.
1309 \end{macrodesc}
1310
Fred Drakeadade921999-04-22 13:05:27 +00001311 \begin{envdesc}{tableiv}{\p{colspec}\p{col1font}\p{heading1}\p{heading2}\p{heading3}\p{heading4}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001312 Like the \env{tableiii} environment, but with a fourth column.
1313 The heading for the fourth column is given by \var{heading4}.
1314 \end{envdesc}
1315
Fred Drakeda72b932000-09-21 15:58:02 +00001316 \begin{envdesc}{longtableiv}{\unspecified}
1317 Like \env{tableiv}, but produces a table which may be broken
1318 across page boundaries. The parameters are the same as for
1319 \env{tableiv}.
1320 \end{envdesc}
1321
Fred Drakeadade921999-04-22 13:05:27 +00001322 \begin{macrodesc}{lineiv}{\p{column1}\p{column2}\p{column3}\p{column4}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001323 Like the \macro{lineiii} macro, but with a fourth column. The
1324 text for the fourth column is given by \var{column4}.
1325 \end{macrodesc}
1326
Fred Drakef269e592001-07-17 23:05:57 +00001327 \begin{envdesc}{tablev}{\p{colspec}\p{col1font}\p{heading1}\p{heading2}\p{heading3}\p{heading4}\p{heading5}}
1328 Like the \env{tableiv} environment, but with a fifth column.
1329 The heading for the fifth column is given by \var{heading5}.
1330 \end{envdesc}
1331
1332 \begin{envdesc}{longtablev}{\unspecified}
1333 Like \env{tablev}, but produces a table which may be broken
1334 across page boundaries. The parameters are the same as for
1335 \env{tablev}.
1336 \end{envdesc}
1337
1338 \begin{macrodesc}{linev}{\p{column1}\p{column2}\p{column3}\p{column4}\p{column5}}
1339 Like the \macro{lineiv} macro, but with a fifth column. The
1340 text for the fifth column is given by \var{column5}.
1341 \end{macrodesc}
1342
Fred Drakeacffaee1999-03-16 16:09:13 +00001343
1344 An additional table-like environment is \env{synopsistable}. The
1345 table generated by this environment contains two columns, and each
1346 row is defined by an alternate definition of
Fred Drakee15956b2000-04-03 04:51:13 +00001347 \macro{modulesynopsis}. This environment is not normally used by
1348 authors, but is created by the \macro{localmoduletable} macro.
Fred Drakeacffaee1999-03-16 16:09:13 +00001349
Fred Drake0cac5f62001-08-14 21:36:19 +00001350 Here is a small example of a table given in the documentation for
1351 the \module{warnings} module; markup inside the table cells is
1352 minimal so the markup for the table itself is readily discernable.
1353 Here is the markup for the table:
1354
1355\begin{verbatim}
1356\begin{tableii}{l|l}{exception}{Class}{Description}
1357 \lineii{Warning}
1358 {This is the base class of all warning category classes. It
1359 is a subclass of \exception{Exception}.}
1360 \lineii{UserWarning}
1361 {The default category for \function{warn()}.}
1362 \lineii{DeprecationWarning}
1363 {Base category for warnings about deprecated features.}
1364 \lineii{SyntaxWarning}
1365 {Base category for warnings about dubious syntactic
1366 features.}
1367 \lineii{RuntimeWarning}
1368 {Base category for warnings about dubious runtime features.}
Barry Warsawb8c20a72002-08-14 16:40:54 +00001369 \lineii{FutureWarning}
Fred Drakee7f343d2003-07-11 03:36:15 +00001370 {Base category for warnings about constructs that will change
1371 semantically in the future.}
Fred Drake0cac5f62001-08-14 21:36:19 +00001372\end{tableii}
1373\end{verbatim}
1374
1375 Here is the resulting table:
1376
1377\begin{tableii}{l|l}{exception}{Class}{Description}
1378 \lineii{Warning}
1379 {This is the base class of all warning category classes. It
1380 is a subclass of \exception{Exception}.}
1381 \lineii{UserWarning}
1382 {The default category for \function{warn()}.}
1383 \lineii{DeprecationWarning}
1384 {Base category for warnings about deprecated features.}
1385 \lineii{SyntaxWarning}
1386 {Base category for warnings about dubious syntactic
1387 features.}
1388 \lineii{RuntimeWarning}
1389 {Base category for warnings about dubious runtime features.}
1390\end{tableii}
1391
1392 Note that the class names are implicitly marked using the
1393 \macro{exception} macro, since that is given as the \var{col1font}
1394 value for the \env{tableii} environment. To create a table using
1395 different markup for the first column, use \code{textrm} for the
1396 \var{col1font} value and mark each entry individually.
1397
1398 To add a horizontal line between vertical sections of a table, use
1399 the standard \macro{hline} macro between the rows which should be
1400 separated:
1401
1402\begin{verbatim}
1403\begin{tableii}{l|l}{constant}{Language}{Audience}
1404 \lineii{APL}{Masochists.}
1405 \lineii{BASIC}{First-time programmers on PC hardware.}
1406 \lineii{C}{\UNIX{} \&\ Linux kernel developers.}
1407 \hline
1408 \lineii{Python}{Everyone!}
1409\end{tableii}
1410\end{verbatim}
1411
1412 Note that not all presentation formats are capable of displaying a
1413 horizontal rule in this position. This is how the table looks in
1414 the format you're reading now:
1415
1416\begin{tableii}{l|l}{constant}{Language}{Audience}
1417 \lineii{APL}{Masochists.}
1418 \lineii{C}{\UNIX{} \&\ Linux kernel developers.}
1419 \lineii{JavaScript}{Web developers.}
1420 \hline
1421 \lineii{Python}{Everyone!}
1422\end{tableii}
1423
Fred Drakeacffaee1999-03-16 16:09:13 +00001424
1425 \subsection{Reference List Markup \label{references}}
1426
1427 Many sections include a list of references to module documentation
1428 or external documents. These lists are created using the
Fred Drake5ed35fd2001-11-30 18:09:54 +00001429 \env{seealso} or \env{seealso*} environments. These environments
1430 define some additional macros to support creating reference
1431 entries in a reasonable manner.
Fred Drakeacffaee1999-03-16 16:09:13 +00001432
Fred Drake5802e482000-07-06 05:24:41 +00001433 The \env{seealso} environment is typically placed in a section
1434 just before any sub-sections. This is done to ensure that
1435 reference links related to the section are not hidden in a
Fred Drake5ed35fd2001-11-30 18:09:54 +00001436 subsection in the hypertext renditions of the documentation. For
1437 the HTML output, it is shown as a ``side bar,'' boxed off from the
1438 main flow of the text. The \env{seealso*} environment is
1439 different in that it should be used when a list of references is
1440 being presented as part of the primary content; it is not
1441 specially set off from the text.
Fred Drake5802e482000-07-06 05:24:41 +00001442
Fred Drakeacffaee1999-03-16 16:09:13 +00001443 \begin{envdesc}{seealso}{}
1444 This environment creates a ``See also:'' heading and defines the
1445 markup used to describe individual references.
1446 \end{envdesc}
1447
Fred Drake5ed35fd2001-11-30 18:09:54 +00001448 \begin{envdesc}{seealso*}{}
1449 This environment is used to create a list of references which
1450 form part of the main content. It is not given a special
1451 header and is not set off from the main flow of the text. It
1452 provides the same additional markup used to describe individual
1453 references.
1454 \end{envdesc}
1455
Fred Drake48449982000-09-12 17:52:33 +00001456 For each of the following macros, \var{why} should be one or more
1457 complete sentences, starting with a capital letter (unless it
1458 starts with an identifier, which should not be modified), and
Fred Drake4f687b32004-01-08 14:57:27 +00001459 ending with the appropriate punctuation.
Fred Drake5802e482000-07-06 05:24:41 +00001460
Fred Drakeb7cf3782000-09-12 19:58:10 +00001461 These macros are only defined within the content of the
Fred Drake5ed35fd2001-11-30 18:09:54 +00001462 \env{seealso} and \env{seealso*} environments.
Fred Drakeb7cf3782000-09-12 19:58:10 +00001463
Fred Drake4f687b32004-01-08 14:57:27 +00001464 \begin{macrodesc}{seelink}{\p{url}\p{linktext}\p{why}}
1465 References to specific on-line resources should be given using
1466 the \macro{seelink} macro if they don't have a meaningful title
1467 but there is some short description of what's at the end of the
1468 link. Online documents which have identifiable titles should be
1469 referenced using the \macro{seetitle} macro, using the optional
1470 parameter to that macro to provide the URL.
1471 \end{macrodesc}
1472
Fred Drakeadade921999-04-22 13:05:27 +00001473 \begin{macrodesc}{seemodule}{\op{key}\p{name}\p{why}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001474 Refer to another module. \var{why} should be a brief
1475 explanation of why the reference may be interesting. The module
1476 name is given in \var{name}, with the link key given in
1477 \var{key} if necessary. In the HTML and PDF conversions, the
1478 module name will be a hyperlink to the referred-to module.
Fred Drake64a5aaf2001-10-20 04:18:14 +00001479 \note{The module must be documented in the same
1480 document (the corresponding \macro{declaremodule} is required).}
Fred Drakeacffaee1999-03-16 16:09:13 +00001481 \end{macrodesc}
1482
Fred Drake08c5d0c2000-09-11 05:22:30 +00001483 \begin{macrodesc}{seepep}{\p{number}\p{title}\p{why}}
1484 Refer to an Python Enhancement Proposal (PEP). \var{number}
1485 should be the official number assigned by the PEP Editor,
1486 \var{title} should be the human-readable title of the PEP as
Fred Drake5802e482000-07-06 05:24:41 +00001487 found in the official copy of the document, and \var{why} should
Fred Drake08c5d0c2000-09-11 05:22:30 +00001488 explain what's interesting about the PEP. This should be used
1489 to refer the reader to PEPs which specify interfaces or language
1490 features relevant to the material in the annotated section of the
1491 documentation.
1492 \end{macrodesc}
1493
1494 \begin{macrodesc}{seerfc}{\p{number}\p{title}\p{why}}
1495 Refer to an IETF Request for Comments (RFC). Otherwise very
1496 similar to \macro{seepep}. This should be used
1497 to refer the reader to PEPs which specify protocols or data
Fred Drake5802e482000-07-06 05:24:41 +00001498 formats relevant to the material in the annotated section of the
1499 documentation.
1500 \end{macrodesc}
1501
Fred Drakeadade921999-04-22 13:05:27 +00001502 \begin{macrodesc}{seetext}{\p{text}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001503 Add arbitrary text \var{text} to the ``See also:'' list. This
1504 can be used to refer to off-line materials or on-line materials
Fred Drake5802e482000-07-06 05:24:41 +00001505 using the \macro{url} macro. This should consist of one or more
1506 complete sentences.
1507 \end{macrodesc}
1508
Fred Drake48449982000-09-12 17:52:33 +00001509 \begin{macrodesc}{seetitle}{\op{url}\p{title}\p{why}}
1510 Add a reference to an external document named \var{title}. If
1511 \var{url} is given, the title is made a hyperlink in the HTML
1512 version of the documentation, and displayed below the title in
1513 the typeset versions of the documentation.
1514 \end{macrodesc}
1515
Fred Drake5802e482000-07-06 05:24:41 +00001516 \begin{macrodesc}{seeurl}{\p{url}\p{why}}
1517 References to specific on-line resources should be given using
Fred Drake5ed35fd2001-11-30 18:09:54 +00001518 the \macro{seeurl} macro if they don't have a meaningful title.
1519 Online documents which have identifiable titles should be
1520 referenced using the \macro{seetitle} macro, using the optional
1521 parameter to that macro to provide the URL.
Fred Drakeacffaee1999-03-16 16:09:13 +00001522 \end{macrodesc}
1523
1524
1525 \subsection{Index-generating Markup \label{indexing}}
1526
1527 Effective index generation for technical documents can be very
Fred Drakee15956b2000-04-03 04:51:13 +00001528 difficult, especially for someone familiar with the topic but not
Fred Drakeacffaee1999-03-16 16:09:13 +00001529 the creation of indexes. Much of the difficulty arises in the
1530 area of terminology: including the terms an expert would use for a
1531 concept is not sufficient. Coming up with the terms that a novice
Fred Drake2c4e0091999-03-29 14:55:55 +00001532 would look up is fairly difficult for an author who, typically, is
Fred Drakeacffaee1999-03-16 16:09:13 +00001533 an expert in the area she is writing on.
1534
Fred Drake2c4e0091999-03-29 14:55:55 +00001535 The truly difficult aspects of index generation are not areas with
1536 which the documentation tools can help. However, ease
Fred Drakee15956b2000-04-03 04:51:13 +00001537 of producing the index once content decisions are made is within
Fred Drakeacffaee1999-03-16 16:09:13 +00001538 the scope of the tools. Markup is provided which the processing
1539 software is able to use to generate a variety of kinds of index
1540 entry with minimal effort. Additionally, many of the environments
Fred Drake7a737df1999-04-23 14:41:44 +00001541 described in section \ref{info-units}, ``Information Units,'' will
Fred Drakeacffaee1999-03-16 16:09:13 +00001542 generate appropriate entries into the general and module indexes.
1543
1544 The following macro can be used to control the generation of index
Fred Drakeadade921999-04-22 13:05:27 +00001545 data, and should be used in the document preamble:
Fred Drakeacffaee1999-03-16 16:09:13 +00001546
1547 \begin{macrodesc}{makemodindex}{}
Fred Drakeadade921999-04-22 13:05:27 +00001548 This should be used in the document preamble if a ``Module
Fred Drakeacffaee1999-03-16 16:09:13 +00001549 Index'' is desired for a document containing reference material
1550 on many modules. This causes a data file
Fred Draked1fb7791999-05-17 16:33:54 +00001551 \code{lib\var{jobname}.idx} to be created from the
Fred Drakeacffaee1999-03-16 16:09:13 +00001552 \macro{declaremodule} macros. This file can be processed by the
1553 \program{makeindex} program to generate a file which can be
1554 \macro{input} into the document at the desired location of the
1555 module index.
1556 \end{macrodesc}
1557
1558 There are a number of macros that are useful for adding index
1559 entries for particular concepts, many of which are specific to
1560 programming languages or even Python.
1561
Fred Drakeadade921999-04-22 13:05:27 +00001562 \begin{macrodesc}{bifuncindex}{\p{name}}
Fred Drakeec8b9051999-04-23 20:01:17 +00001563 Add an index entry referring to a built-in function named
1564 \var{name}; parentheses should not be included after
Fred Drake2c4e0091999-03-29 14:55:55 +00001565 \var{name}.
Fred Drakeacffaee1999-03-16 16:09:13 +00001566 \end{macrodesc}
1567
Fred Drakeadade921999-04-22 13:05:27 +00001568 \begin{macrodesc}{exindex}{\p{exception}}
Fred Drake2c4e0091999-03-29 14:55:55 +00001569 Add a reference to an exception named \var{exception}. The
Neal Norwitz847207a2003-05-29 02:17:23 +00001570 exception should be class-based.
Fred Drakeacffaee1999-03-16 16:09:13 +00001571 \end{macrodesc}
1572
Fred Drakeadade921999-04-22 13:05:27 +00001573 \begin{macrodesc}{kwindex}{\p{keyword}}
Fred Drake2c4e0091999-03-29 14:55:55 +00001574 Add a reference to a language keyword (not a keyword parameter
1575 in a function or method call).
Fred Drakeacffaee1999-03-16 16:09:13 +00001576 \end{macrodesc}
1577
Fred Drakeadade921999-04-22 13:05:27 +00001578 \begin{macrodesc}{obindex}{\p{object type}}
Fred Drake2c4e0091999-03-29 14:55:55 +00001579 Add an index entry for a built-in object type.
Fred Drakeacffaee1999-03-16 16:09:13 +00001580 \end{macrodesc}
1581
Fred Drakeadade921999-04-22 13:05:27 +00001582 \begin{macrodesc}{opindex}{\p{operator}}
Fred Drake2c4e0091999-03-29 14:55:55 +00001583 Add a reference to an operator, such as \samp{+}.
Fred Drakeacffaee1999-03-16 16:09:13 +00001584 \end{macrodesc}
1585
Fred Drakeadade921999-04-22 13:05:27 +00001586 \begin{macrodesc}{refmodindex}{\op{key}\p{module}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001587 Add an index entry for module \var{module}; if \var{module}
1588 contains an underscore, the optional parameter \var{key} should
1589 be provided as the same string with underscores removed. An
1590 index entry ``\var{module} (module)'' will be generated. This
1591 is intended for use with non-standard modules implemented in
1592 Python.
1593 \end{macrodesc}
1594
Fred Drakeadade921999-04-22 13:05:27 +00001595 \begin{macrodesc}{refexmodindex}{\op{key}\p{module}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001596 As for \macro{refmodindex}, but the index entry will be
1597 ``\var{module} (extension module).'' This is intended for use
1598 with non-standard modules not implemented in Python.
1599 \end{macrodesc}
1600
Fred Drakeadade921999-04-22 13:05:27 +00001601 \begin{macrodesc}{refbimodindex}{\op{key}\p{module}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001602 As for \macro{refmodindex}, but the index entry will be
1603 ``\var{module} (built-in module).'' This is intended for use
1604 with standard modules not implemented in Python.
1605 \end{macrodesc}
1606
Fred Drakeadade921999-04-22 13:05:27 +00001607 \begin{macrodesc}{refstmodindex}{\op{key}\p{module}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001608 As for \macro{refmodindex}, but the index entry will be
1609 ``\var{module} (standard module).'' This is intended for use
1610 with standard modules implemented in Python.
1611 \end{macrodesc}
1612
Fred Drakeadade921999-04-22 13:05:27 +00001613 \begin{macrodesc}{stindex}{\p{statement}}
Fred Drake2c4e0091999-03-29 14:55:55 +00001614 Add an index entry for a statement type, such as \keyword{print}
Fred Drakeadade921999-04-22 13:05:27 +00001615 or \keyword{try}/\keyword{finally}.
1616
1617 XXX Need better examples of difference from \macro{kwindex}.
Fred Drakeacffaee1999-03-16 16:09:13 +00001618 \end{macrodesc}
1619
1620
1621 Additional macros are provided which are useful for conveniently
1622 creating general index entries which should appear at many places
1623 in the index by rotating a list of words. These are simple macros
1624 that simply use \macro{index} to build some number of index
1625 entries. Index entries build using these macros contain both
1626 primary and secondary text.
1627
Fred Drakeadade921999-04-22 13:05:27 +00001628 \begin{macrodesc}{indexii}{\p{word1}\p{word2}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001629 Build two index entries. This is exactly equivalent to using
Fred Drakee7f343d2003-07-11 03:36:15 +00001630 \code{\e index\{\var{word1}!\var{word2}\}} and
Fred Drakeacffaee1999-03-16 16:09:13 +00001631 \code{\e index\{\var{word2}!\var{word1}\}}.
1632 \end{macrodesc}
1633
Fred Drakeadade921999-04-22 13:05:27 +00001634 \begin{macrodesc}{indexiii}{\p{word1}\p{word2}\p{word3}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001635 Build three index entries. This is exactly equivalent to using
1636 \code{\e index\{\var{word1}!\var{word2} \var{word3}\}},
1637 \code{\e index\{\var{word2}!\var{word3}, \var{word1}\}}, and
1638 \code{\e index\{\var{word3}!\var{word1} \var{word2}\}}.
1639 \end{macrodesc}
1640
Fred Drakeadade921999-04-22 13:05:27 +00001641 \begin{macrodesc}{indexiv}{\p{word1}\p{word2}\p{word3}\p{word4}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001642 Build four index entries. This is exactly equivalent to using
1643 \code{\e index\{\var{word1}!\var{word2} \var{word3} \var{word4}\}},
1644 \code{\e index\{\var{word2}!\var{word3} \var{word4}, \var{word1}\}},
1645 \code{\e index\{\var{word3}!\var{word4}, \var{word1} \var{word2}\}},
1646 and
1647 \code{\e index\{\var{word4}!\var{word1} \var{word2} \var{word3}\}}.
1648 \end{macrodesc}
1649
Fred Drake432cef02001-07-06 22:34:33 +00001650 \subsection{Grammar Production Displays \label{grammar-displays}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001651
Fred Drake432cef02001-07-06 22:34:33 +00001652 Special markup is available for displaying the productions of a
1653 formal grammar. The markup is simple and does not attempt to
1654 model all aspects of BNF (or any derived forms), but provides
1655 enough to allow context-free grammars to be displayed in a way
1656 that causes uses of a symbol to be rendered as hyperlinks to the
1657 definition of the symbol. There is one environment and a pair of
1658 macros:
Fred Drakeacffaee1999-03-16 16:09:13 +00001659
Fred Drake432cef02001-07-06 22:34:33 +00001660 \begin{envdesc}{productionlist}{\op{language}}
1661 This environment is used to enclose a group of productions. The
1662 two macros are only defined within this environment. If a
Raymond Hettinger68804312005-01-01 00:28:46 +00001663 document describes more than one language, the optional parameter
Fred Drake432cef02001-07-06 22:34:33 +00001664 \var{language} should be used to distinguish productions between
1665 languages. The value of the parameter should be a short name
1666 that can be used as part of a filename; colons or other
1667 characters that can't be used in filename across platforms
1668 should be included.
1669 \end{envdesc}
Fred Drakeacffaee1999-03-16 16:09:13 +00001670
Fred Drake432cef02001-07-06 22:34:33 +00001671 \begin{macrodesc}{production}{\p{name}\p{definition}}
1672 A production rule in the grammar. The rule defines the symbol
1673 \var{name} to be \var{definition}. \var{name} should not
1674 contain any markup, and the use of hyphens in a document which
1675 supports more than one grammar is undefined. \var{definition}
1676 may contain \macro{token} macros and any additional content
1677 needed to describe the grammatical model of \var{symbol}. Only
1678 one \macro{production} may be used to define a symbol ---
1679 multiple definitions are not allowed.
1680 \end{macrodesc}
Fred Drakeacffaee1999-03-16 16:09:13 +00001681
Fred Drake432cef02001-07-06 22:34:33 +00001682 \begin{macrodesc}{token}{\p{name}}
1683 The name of a symbol defined by a \macro{production} macro, used
1684 in the \var{definition} of a symbol. Where possible, this will
1685 be rendered as a hyperlink to the definition of the symbol
1686 \var{name}.
1687 \end{macrodesc}
Fred Drake42934682000-04-03 15:00:28 +00001688
Fred Drake432cef02001-07-06 22:34:33 +00001689 Note that the entire grammar does not need to be defined in a
1690 single \env{productionlist} environment; any number of
1691 groupings may be used to describe the grammar. Every use of the
1692 \macro{token} must correspond to a \macro{production}.
1693
1694 The following is an example taken from the
1695 \citetitle[../ref/identifiers.html]{Python Reference Manual}:
1696
1697\begin{verbatim}
1698\begin{productionlist}
1699 \production{identifier}
1700 {(\token{letter}|"_") (\token{letter} | \token{digit} | "_")*}
1701 \production{letter}
1702 {\token{lowercase} | \token{uppercase}}
1703 \production{lowercase}
1704 {"a"..."z"}
1705 \production{uppercase}
1706 {"A"..."Z"}
1707 \production{digit}
1708 {"0"..."9"}
1709\end{productionlist}
1710\end{verbatim}
1711
1712
Fred Drakee1341582002-09-25 18:44:21 +00001713\subsection{Graphical Interface Components \label{gui-markup}}
Fred Drake432cef02001-07-06 22:34:33 +00001714
1715 The components of graphical interfaces will be assigned markup, but
Fred Drakee1341582002-09-25 18:44:21 +00001716 most of the specifics have not been determined.
1717
Fred Drakef0f6d122004-01-23 08:52:28 +00001718 \begin{macrodesc}{guilabel}{\p{label}}
1719 Labels presented as part of an interactive user interface should
1720 be marked using \macro{guilabel}. This includes labels from
1721 text-based interfaces such as those created using \code{curses} or
1722 other text-based libraries. Any label used in the interface
1723 should be marked with this macro, including button labels, window
1724 titles, field names, menu and menu selection names, and even
1725 values in selection lists.
1726 \end{macrodesc}
1727
Fred Drakee1341582002-09-25 18:44:21 +00001728 \begin{macrodesc}{menuselection}{\p{menupath}}
1729 Menu selections should be marked using a combination of
1730 \macro{menuselection} and \macro{sub}. This macro is used to mark
1731 a complete sequence of menu selections, including selecting
1732 submenus and choosing a specific operation, or any subsequence of
1733 such a sequence. The names of individual selections should be
Raymond Hettinger68804312005-01-01 00:28:46 +00001734 separated by occurrences of \macro{sub}.
Fred Drakee1341582002-09-25 18:44:21 +00001735
1736 For example, to mark the selection ``\menuselection{Start \sub
1737 Programs}'', use this markup:
1738
1739\begin{verbatim}
1740\menuselection{Start \sub Programs}
1741\end{verbatim}
1742
1743 When including a selection that includes some trailing indicator,
1744 such as the ellipsis some operating systems use to indicate that
1745 the command opens a dialog, the indicator should be omitted from
1746 the selection name.
Fred Drakef0f6d122004-01-23 08:52:28 +00001747
1748 Individual selection names within the \macro{menuselection} should
1749 not be marked using \macro{guilabel} since that's implied by using
1750 \macro{menuselection}.
Fred Drakee1341582002-09-25 18:44:21 +00001751 \end{macrodesc}
1752
1753 \begin{macrodesc}{sub}{}
1754 Separator for menu selections that include multiple levels. This
1755 macro is only defined within the context of the
1756 \macro{menuselection} macro.
1757 \end{macrodesc}
Fred Drakeacffaee1999-03-16 16:09:13 +00001758
1759
Fred Drakef1b3de82001-07-24 14:38:34 +00001760\section{Processing Tools \label{tools}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001761
Fred Drakef1b3de82001-07-24 14:38:34 +00001762 \subsection{External Tools \label{tools-external}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001763
1764 Many tools are needed to be able to process the Python
1765 documentation if all supported formats are required. This
Fred Drakeadade921999-04-22 13:05:27 +00001766 section lists the tools used and when each is required. Consult
1767 the \file{Doc/README} file to see if there are specific version
1768 requirements for any of these.
Fred Drakeacffaee1999-03-16 16:09:13 +00001769
1770 \begin{description}
1771 \item[\program{dvips}]
1772 This program is a typical part of \TeX{} installations. It is
1773 used to generate PostScript from the ``device independent''
Fred Drake2c4e0091999-03-29 14:55:55 +00001774 \file{.dvi} files. It is needed for the conversion to
Fred Drakeacffaee1999-03-16 16:09:13 +00001775 PostScript.
1776
1777 \item[\program{emacs}]
1778 Emacs is the kitchen sink of programmers' editors, and a damn
1779 fine kitchen sink it is. It also comes with some of the
1780 processing needed to support the proper menu structures for
1781 Texinfo documents when an info conversion is desired. This is
Fred Drake2c4e0091999-03-29 14:55:55 +00001782 needed for the info conversion. Using \program{xemacs}
Fred Drakeacffaee1999-03-16 16:09:13 +00001783 instead of FSF \program{emacs} may lead to instability in the
1784 conversion, but that's because nobody seems to maintain the
1785 Emacs Texinfo code in a portable manner.
1786
1787 \item[\program{latex}]
Fred Drakeb5f17f22001-08-28 18:09:11 +00001788 \LaTeX{} is a large and extensible macro package by Leslie
1789 Lamport, based on \TeX, a world-class typesetter by Donald
1790 Knuth. It is used for the conversion to PostScript, and is
1791 needed for the HTML conversion as well (\LaTeX2HTML requires
1792 one of the intermediate files it creates).
Fred Drakeacffaee1999-03-16 16:09:13 +00001793
1794 \item[\program{latex2html}]
1795 Probably the longest Perl script anyone ever attempted to
1796 maintain. This converts \LaTeX{} documents to HTML documents,
1797 and does a pretty reasonable job. It is required for the
1798 conversions to HTML and GNU info.
1799
1800 \item[\program{lynx}]
1801 This is a text-mode Web browser which includes an
1802 HTML-to-plain text conversion. This is used to convert
1803 \code{howto} documents to text.
1804
1805 \item[\program{make}]
1806 Just about any version should work for the standard documents,
1807 but GNU \program{make} is required for the experimental
1808 processes in \file{Doc/tools/sgmlconv/}, at least while
Fred Drakeb5f17f22001-08-28 18:09:11 +00001809 they're experimental. This is not required for running the
Fred Drakef9dc0432001-08-29 02:34:10 +00001810 \program{mkhowto} script.
Fred Drakeacffaee1999-03-16 16:09:13 +00001811
1812 \item[\program{makeindex}]
1813 This is a standard program for converting \LaTeX{} index data
1814 to a formatted index; it should be included with all \LaTeX{}
1815 installations. It is needed for the PDF and PostScript
1816 conversions.
1817
1818 \item[\program{makeinfo}]
1819 GNU \program{makeinfo} is used to convert Texinfo documents to
1820 GNU info files. Since Texinfo is used as an intermediate
1821 format in the info conversion, this program is needed in that
1822 conversion.
1823
1824 \item[\program{pdflatex}]
1825 pdf\TeX{} is a relatively new variant of \TeX, and is used to
1826 generate the PDF version of the manuals. It is typically
1827 installed as part of most of the large \TeX{} distributions.
Fred Drake7a737df1999-04-23 14:41:44 +00001828 \program{pdflatex} is pdf\TeX{} using the \LaTeX{} format.
Fred Drakeacffaee1999-03-16 16:09:13 +00001829
1830 \item[\program{perl}]
1831 Perl is required for \LaTeX2HTML{} and one of the scripts used
1832 to post-process \LaTeX2HTML output, as well as the
Fred Drake2c4e0091999-03-29 14:55:55 +00001833 HTML-to-Texinfo conversion. This is required for
Fred Drakeacffaee1999-03-16 16:09:13 +00001834 the HTML and GNU info conversions.
1835
1836 \item[\program{python}]
1837 Python is used for many of the scripts in the
1838 \file{Doc/tools/} directory; it is required for all
1839 conversions. This shouldn't be a problem if you're interested
1840 in writing documentation for Python!
1841 \end{description}
1842
1843
Fred Drakef1b3de82001-07-24 14:38:34 +00001844 \subsection{Internal Tools \label{tools-internal}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001845
1846 This section describes the various scripts that are used to
1847 implement various stages of document processing or to orchestrate
Fred Drake2c4e0091999-03-29 14:55:55 +00001848 entire build sequences. Most of these tools are only useful
Fred Drakeacffaee1999-03-16 16:09:13 +00001849 in the context of building the standard documentation, but some
1850 are more general.
1851
1852 \begin{description}
1853 \item[\program{mkhowto}]
Fred Drake87f768e1999-05-17 15:22:45 +00001854 This is the primary script used to format third-party
Fred Drakee7f343d2003-07-11 03:36:15 +00001855 documents. It contains all the logic needed to ``get it
1856 right.'' The proper way to use this script is to make a
1857 symbolic link to it or run it in place; the actual script file
1858 must be stored as part of the documentation source tree,
Fred Drakeefb3a162003-10-01 04:15:09 +00001859 though it may be used to format documents outside the tree.
1860 Use \program{mkhowto} \longprogramopt{help} for a list of
Fred Draked2a727f1999-05-27 21:45:54 +00001861 command line options.
Fred Drake87f768e1999-05-17 15:22:45 +00001862
Fred Draked1fb7791999-05-17 16:33:54 +00001863 \program{mkhowto} can be used for both \code{howto} and
Fred Draked80032b2002-09-25 21:41:22 +00001864 \code{manual} class documents. It is usually a good idea to
1865 always use the latest version of this tool rather than a
Fred Drakeefb3a162003-10-01 04:15:09 +00001866 version from an older source release of Python. It can be
1867 used to generate DVI, HTML, PDF, PostScript, and plain text
1868 documents. The GNU info and iSilo formats will be supported
1869 by this script in some future version.
1870
1871 Use the \longprogramopt{help} option on this script's command
1872 line to get a summary of options for this script.
Fred Draked1fb7791999-05-17 16:33:54 +00001873
Fred Drakee7f343d2003-07-11 03:36:15 +00001874 XXX Need more here.
Fred Drakeacffaee1999-03-16 16:09:13 +00001875 \end{description}
1876
1877
Fred Drakeeb2b8332002-05-01 22:05:30 +00001878 \subsection{Working on Cygwin \label{cygwin}}
1879
Fred Drakeeb2b8332002-05-01 22:05:30 +00001880 Installing the required tools under Cygwin under Cygwin can be a
Martin v. Löwisc9f85252005-03-03 23:07:21 +00001881 little tedious. Most of the required packages can be installed
1882 using Cygwin's graphical installer, while netpbm and \LaTeX2HTML
1883 must be installed from source.
1884
1885 Start with a reasonably modern version of Cygwin. If you haven't
1886 upgraded for a few years, now would be a good time.
Fred Drakeeb2b8332002-05-01 22:05:30 +00001887
1888 Using the Cygwin installer, make sure your Cygwin installation
1889 includes Perl, Python, and the \TeX{} packages. Perl and Python
Martin v. Löwisc9f85252005-03-03 23:07:21 +00001890 are located under the \menuselection{Interpreters} heading. The
1891 \TeX{} packages are located under the \menuselection{Text}
1892 heading, and are named \code{tetex-*}. To ensure that all
1893 required packages are available, install every \code{tetex}
1894 package, except \code{tetex-x11}. (There may be a more minimal
1895 set, but I've not spent time trying to minimize the installation.)
Fred Drakeeb2b8332002-05-01 22:05:30 +00001896
1897 The netpbm package is used by \LaTeX2HTML, and \emph{must} be
1898 installed before \LaTeX2HTML can be successfully installed, even
Martin v. Löwisc9f85252005-03-03 23:07:21 +00001899 though its features will not be used for most Python
1900 documentation. References to download locations are located in
1901 the \ulink{netpbm README}{http://netpbm.sourceforge.net/README}.
1902 Install from the latest stable source distribution according to
1903 the instructions. (Note that binary packages of netpbm are
1904 sometimes available, but these may not work correctly with
1905 \LaTeX2HTML.)
Fred Drakeeb2b8332002-05-01 22:05:30 +00001906
1907 \LaTeX2HTML can be installed from the source archive, but only
Martin v. Löwisc9f85252005-03-03 23:07:21 +00001908 after munging one of the files in the distribution. Download the
1909 source archive from the \LaTeX2HTML website
1910 \url{http://www.latex2html.org/} (or one of the many alternate
1911 sites) and unpack it to a build directory. In the top level of
1912 this build directory there will be a file named \file{L2hos.pm}.
1913 Open \file{L2hos.pm} in an editor, and near the bottom of the file
1914 replace the text \code{\$\textasciicircum{}O} with the text
1915 \code{'unix'}. Proceed using this command to build and install
1916 the software:
Fred Drakeeb2b8332002-05-01 22:05:30 +00001917
1918\begin{verbatim}
Fred Drakec7c9a3a2004-05-10 18:39:32 +00001919% ./configure && make install
Fred Drakeeb2b8332002-05-01 22:05:30 +00001920\end{verbatim}
1921
Fred Drakeefb3a162003-10-01 04:15:09 +00001922 You should now be able to build at least the DVI, HTML, PDF, and
Fred Drake77c18952002-05-02 21:10:48 +00001923 PostScript versions of the formatted documentation.
1924
Fred Drakeeb2b8332002-05-01 22:05:30 +00001925
Fred Drake40b9df22003-10-11 05:25:24 +00001926\section{Including Graphics \label{graphics}}
1927
1928 The standard documentation included with Python makes no use of
1929 diagrams or images; this is intentional. The outside tools used to
1930 format the documentation have not always been suited to working with
1931 graphics. As the tools have evolved and been improved by their
1932 maintainers, support for graphics has improved.
1933
1934 The internal tools, starting with the \program{mkhowto} script, do
1935 not provide any direct support for graphics. However,
1936 \program{mkhowto} will not interfere with graphics support in the
1937 external tools.
1938
1939 Experience using graphics together with these tools and the
1940 \code{howto} and \code{manual} document classes is not extensive,
1941 but has been known to work. The basic approach is this:
1942
1943 \begin{enumerate}
1944 \item Create the image or graphic using your favorite
1945 application.
1946
1947 \item Convert the image to a format supported by the conversion to
1948 your desired output format. If you want to generate HTML or
1949 PostScript, you can convert the image or graphic to
1950 encapsulated PostScript (a \file{.eps} file); \LaTeX2HTML
1951 can convert that to a \file{.gif} file; it may be possible
1952 to provide a \file{.gif} file directly. If you want to
1953 generate PDF, you need to provide an ``encapsulated'' PDF
1954 file. This can be generated from encapsulated PostScript
1955 using the \program{epstopdf} tool provided with the te\TeX{}
1956 distribution on Linux and \UNIX.
1957
1958 \item In your document, add this line to ``import'' the general
1959 graphics support package \code{graphicx}:
1960
1961\begin{verbatim}
1962\usepackage{graphicx}
1963\end{verbatim}
1964
1965 \item Where you want to include your graphic or image, include
1966 markup similar to this:
1967
1968\begin{verbatim}
1969\begin{figure}
1970 \centering
1971 \includegraphics[width=5in]{myimage}
1972 \caption{Description of my image}
1973\end{figure}
1974\end{verbatim}
1975
1976 In particular, note for the \macro{includegraphics} macro
1977 that no file extension is provided. If you're only
1978 interested in one target format, you can include the
1979 extension of the appropriate input file, but to allow
1980 support for multiple formats, omitting the extension makes
1981 life easier.
1982
1983 \item Run \program{mkhowto} normally.
1984 \end{enumerate}
1985
1986 If you're working on systems which support some sort of
1987 \program{make} facility, you can use that to ensure the intermediate
1988 graphic formats are kept up to date. This example shows a
1989 \file{Makefile} used to format a document containing a diagram
1990 created using the \program{dia} application:
1991
1992\begin{verbatim}
1993default: pdf
1994all: html pdf ps
1995
1996html: mydoc/mydoc.html
1997pdf: mydoc.pdf
1998ps: mydoc.ps
1999
2000mydoc/mydoc.html: mydoc.tex mygraphic.eps
2001 mkhowto --html $<
2002
2003mydoc.pdf: mydoc.tex mygraphic.pdf
2004 mkhowto --pdf $<
2005
2006mydoc.ps: mydoc.tex mygraphic.eps
2007 mkhowto --postscript $<
2008
2009.SUFFIXES: .dia .eps .pdf
2010
2011.dia.eps:
2012 dia --nosplash --export $@ $<
2013
2014.eps.pdf:
2015 epstopdf $<
2016\end{verbatim} % $ <-- bow to font-lock
2017
2018
Fred Drakeacffaee1999-03-16 16:09:13 +00002019\section{Future Directions \label{futures}}
2020
2021 The history of the Python documentation is full of changes, most of
2022 which have been fairly small and evolutionary. There has been a
2023 great deal of discussion about making large changes in the markup
2024 languages and tools used to process the documentation. This section
2025 deals with the nature of the changes and what appears to be the most
2026 likely path of future development.
2027
2028 \subsection{Structured Documentation \label{structured}}
2029
2030 Most of the small changes to the \LaTeX{} markup have been made
2031 with an eye to divorcing the markup from the presentation, making
2032 both a bit more maintainable. Over the course of 1998, a large
2033 number of changes were made with exactly this in mind; previously,
2034 changes had been made but in a less systematic manner and with
2035 more concern for not needing to update the existing content. The
2036 result has been a highly structured and semantically loaded markup
2037 language implemented in \LaTeX. With almost no basic \TeX{} or
2038 \LaTeX{} markup in use, however, the markup syntax is about the
2039 only evidence of \LaTeX{} in the actual document sources.
2040
2041 One side effect of this is that while we've been able to use
2042 standard ``engines'' for manipulating the documents, such as
2043 \LaTeX{} and \LaTeX2HTML, most of the actual transformations have
Fred Drake7a737df1999-04-23 14:41:44 +00002044 been created specifically for Python. The \LaTeX{} document
2045 classes and \LaTeX2HTML support are both complete implementations
2046 of the specific markup designed for these documents.
Fred Drakeacffaee1999-03-16 16:09:13 +00002047
2048 Combining highly customized markup with the somewhat esoteric
2049 systems used to process the documents leads us to ask some
2050 questions: Can we do this more easily? and, Can we do this
2051 better? After a great deal of discussion with the community, we
2052 have determined that actively pursuing modern structured
Fred Drake2c4e0091999-03-29 14:55:55 +00002053 documentation systems is worth some investment of time.
Fred Drakeacffaee1999-03-16 16:09:13 +00002054
2055 There appear to be two real contenders in this arena: the Standard
2056 General Markup Language (SGML), and the Extensible Markup Language
2057 (XML). Both of these standards have advantages and disadvantages,
2058 and many advantages are shared.
2059
2060 SGML offers advantages which may appeal most to authors,
2061 especially those using ordinary text editors. There are also
2062 additional abilities to define content models. A number of
Fred Drake67f193f2001-07-09 16:04:03 +00002063 high-quality tools with demonstrated maturity are available, but
Fred Drakeacffaee1999-03-16 16:09:13 +00002064 most are not free; for those which are, portability issues remain
2065 a problem.
2066
2067 The advantages of XML include the availability of a large number
2068 of evolving tools. Unfortunately, many of the associated
2069 standards are still evolving, and the tools will have to follow
2070 along. This means that developing a robust tool set that uses
2071 more than the basic XML 1.0 recommendation is not possible in the
2072 short term. The promised availability of a wide variety of
2073 high-quality tools which support some of the most important
2074 related standards is not immediate. Many tools are likely to be
Fred Drake67f193f2001-07-09 16:04:03 +00002075 free, and the portability issues of those which are, are not
2076 expected to be significant.
Fred Drakeacffaee1999-03-16 16:09:13 +00002077
Fred Drake67f193f2001-07-09 16:04:03 +00002078 It turns out that converting to an XML or SGML system holds
2079 promise for translators as well; how much can be done to ease the
2080 burden on translators remains to be seen, and may have some impact
2081 on the schema and specific technologies used.
2082
2083 XXX Eventual migration to XML.
2084
2085 The documentation will be moved to XML in the future, and tools
2086 are being written which will convert the documentation from the
2087 current format to something close to a finished version, to the
2088 extent that the desired information is already present in the
2089 documentation. Some XSLT stylesheets have been started for
2090 presenting a preliminary XML version as HTML, but the results are
Fred Drakee7f343d2003-07-11 03:36:15 +00002091 fairly rough.
Fred Drake67f193f2001-07-09 16:04:03 +00002092
2093 The timeframe for the conversion is not clear since there doesn't
Raymond Hettinger68804312005-01-01 00:28:46 +00002094 seem to be much time available to work on this, but the apparent
Fred Drake67f193f2001-07-09 16:04:03 +00002095 benefits are growing more substantial at a moderately rapid pace.
2096
Fred Drakeacffaee1999-03-16 16:09:13 +00002097
2098 \subsection{Discussion Forums \label{discussion}}
2099
2100 Discussion of the future of the Python documentation and related
Fred Drake7a737df1999-04-23 14:41:44 +00002101 topics takes place in the Documentation Special Interest Group, or
2102 ``Doc-SIG.'' Information on the group, including mailing list
2103 archives and subscription information, is available at
Fred Drakeacffaee1999-03-16 16:09:13 +00002104 \url{http://www.python.org/sigs/doc-sig/}. The SIG is open to all
2105 interested parties.
2106
2107 Comments and bug reports on the standard documents should be sent
Fred Drake9d843082003-07-30 02:55:28 +00002108 to \email{docs@python.org}. This may include comments
Fred Drakeadade921999-04-22 13:05:27 +00002109 about formatting, content, grammatical and spelling errors, or
Fred Draked1fb7791999-05-17 16:33:54 +00002110 this document. You can also send comments on this document
2111 directly to the author at \email{fdrake@acm.org}.
Fred Drakeacffaee1999-03-16 16:09:13 +00002112
Skip Montanaro176bda4cd2002-04-19 04:50:44 +00002113\input{doc.ind}
2114
Fred Drakeacffaee1999-03-16 16:09:13 +00002115\end{document}