blob: 1d0f279f36b05c86524e955a8ade35c28184d193 [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
Thomas Wouters0e3f5912006-08-11 14:57:12 +0000190 Footnotes are generally discouraged due to the pain of using
191 footnotes in the HTML conversion of documents. Footnotes may be
192 used when they are the best way to present specific information.
193 When a footnote reference is added at the end of the sentence, it
194 should follow the sentence-ending punctuation. The \LaTeX{} markup
195 should appear something like this:
196
197\begin{verbatim}
198This sentence has a footnote reference.%
199 \footnote{This is the footnote text.}
200\end{verbatim}
201
202 Footnotes may appear in the middle of sentences where appropriate.
203
Fred Drake432cef02001-07-06 22:34:33 +0000204 Many special names are used in the Python documentation, including
205 the names of operating systems, programming languages, standards
206 bodies, and the like. Many of these were assigned \LaTeX{} macros
207 at some point in the distant past, and these macros lived on long
Fred Drake9120df32001-07-14 02:34:12 +0000208 past their usefulness. In the current markup, most of these entities
209 are not assigned any special markup, but the preferred spellings are
Fred Drake432cef02001-07-06 22:34:33 +0000210 given here to aid authors in maintaining the consistency of
211 presentation in the Python documentation.
212
Fred Drake9120df32001-07-14 02:34:12 +0000213 Other terms and words deserve special mention as well; these conventions
214 should be used to ensure consistency throughout the documentation:
215
Fred Drake432cef02001-07-06 22:34:33 +0000216 \begin{description}
Fred Drake9120df32001-07-14 02:34:12 +0000217 \item[CPU]
218 For ``central processing unit.'' Many style guides say this
219 should be spelled out on the first use (and if you must use it,
220 do so!). For the Python documentation, this abbreviation should
Raymond Hettinger68804312005-01-01 00:28:46 +0000221 be avoided since there's no reasonable way to predict which occurrence
Fred Drake9120df32001-07-14 02:34:12 +0000222 will be the first seen by the reader. It is better to use the
223 word ``processor'' instead.
224
225 \item[\POSIX]
Fred Drakee7f343d2003-07-11 03:36:15 +0000226 The name assigned to a particular group of standards. This is
227 always uppercase. Use the macro \macro{POSIX} to represent this
228 name.
Fred Drake432cef02001-07-06 22:34:33 +0000229
230 \item[Python]
Fred Drakee7f343d2003-07-11 03:36:15 +0000231 The name of our favorite programming language is always
232 capitalized.
Fred Drake432cef02001-07-06 22:34:33 +0000233
234 \item[Unicode]
Fred Drakee7f343d2003-07-11 03:36:15 +0000235 The name of a character set and matching encoding. This is
236 always written capitalized.
Fred Drake9120df32001-07-14 02:34:12 +0000237
238 \item[\UNIX]
Fred Drakee7f343d2003-07-11 03:36:15 +0000239 The name of the operating system developed at AT\&T Bell Labs
240 in the early 1970s. Use the macro \macro{UNIX} to use this
241 name.
Fred Drake432cef02001-07-06 22:34:33 +0000242 \end{description}
243
244
Fred Drakeadade921999-04-22 13:05:27 +0000245\section{\LaTeX{} Primer \label{latex-primer}}
Fred Drake2c4e0091999-03-29 14:55:55 +0000246
Fred Drakeadade921999-04-22 13:05:27 +0000247 This section is a brief introduction to \LaTeX{} concepts and
248 syntax, to provide authors enough information to author documents
Fred Drake20a175a2004-10-18 21:30:40 +0000249 productively without having to become ``\TeX{}nicians.'' This does
250 not teach everything needed to know about writing \LaTeX{} for
251 Python documentation; many of the standard ``environments'' are not
252 described here (though you will learn how to mark something as an
253 environment).
Fred Drakeadade921999-04-22 13:05:27 +0000254
Fred Drake5eb992b1999-06-11 14:25:45 +0000255 Perhaps the most important concept to keep in mind while marking up
Fred Drake02997492000-09-21 05:26:43 +0000256 Python documentation is that while \TeX{} is unstructured, \LaTeX{} was
Fred Drakee7f343d2003-07-11 03:36:15 +0000257 designed as a layer on top of \TeX{} which specifically supports
Fred Drake5eb992b1999-06-11 14:25:45 +0000258 structured markup. The Python-specific markup is intended to extend
259 the structure provided by standard \LaTeX{} document classes to
260 support additional information specific to Python.
261
Fred Drakeadade921999-04-22 13:05:27 +0000262 \LaTeX{} documents contain two parts: the preamble and the body.
263 The preamble is used to specify certain metadata about the document
264 itself, such as the title, the list of authors, the date, and the
265 \emph{class} the document belongs to. Additional information used
266 to control index generation and the use of bibliographic databases
Fred Drake7a737df1999-04-23 14:41:44 +0000267 can also be placed in the preamble. For most authors, the preamble
Fred Drakeadade921999-04-22 13:05:27 +0000268 can be most easily created by copying it from an existing document
269 and modifying a few key pieces of information.
270
271 The \dfn{class} of a document is used to place a document within a
272 broad category of documents and set some fundamental formatting
273 properties. For Python documentation, two classes are used: the
274 \code{manual} class and the \code{howto} class. These classes also
275 define the additional markup used to document Python concepts and
276 structures. Specific information about these classes is provided in
Fred Drake7a737df1999-04-23 14:41:44 +0000277 section \ref{classes}, ``Document Classes,'' below. The first thing
Fred Drakeadade921999-04-22 13:05:27 +0000278 in the preamble is the declaration of the document's class.
279
280 After the class declaration, a number of \emph{macros} are used to
281 provide further information about the document and setup any
Fred Drake7a737df1999-04-23 14:41:44 +0000282 additional markup that is needed. No output is generated from the
283 preamble; it is an error to include free text in the preamble
284 because it would cause output.
Fred Drakeadade921999-04-22 13:05:27 +0000285
286 The document body follows the preamble. This contains all the
Fred Drake63568aa2000-10-19 05:36:10 +0000287 printed components of the document marked up structurally. Generic
Fred Drake4c6f17a2001-04-18 05:12:47 +0000288 \LaTeX{} structures include hierarchical sections, numbered and
289 bulleted lists, and special structures for the document abstract and
290 indexes.
Fred Drakeadade921999-04-22 13:05:27 +0000291
Fred Drakef1b3de82001-07-24 14:38:34 +0000292 \subsection{Syntax \label{latex-syntax}}
Fred Drake63568aa2000-10-19 05:36:10 +0000293
Fred Drake4c6f17a2001-04-18 05:12:47 +0000294 There are some things that an author of Python documentation needs
295 to know about \LaTeX{} syntax.
Fred Drake63568aa2000-10-19 05:36:10 +0000296
297 A \dfn{comment} is started by the ``percent'' character
Thomas Wouters0e3f5912006-08-11 14:57:12 +0000298 (\character{\%}) and continues through the end of the line
299 \emph{and all leading whitespace on the following line}. This is
300 a little different from any programming language I know of, so an
301 example is in order:
Fred Drake63568aa2000-10-19 05:36:10 +0000302
303\begin{verbatim}
304This is text.% comment
305 This is more text. % another comment
306Still more text.
307\end{verbatim}
308
309 The first non-comment character following the first comment is the
310 letter \character{T} on the second line; the leading whitespace on
311 that line is consumed as part of the first comment. This means
312 that there is no space between the first and second sentences, so
313 the period and letter \character{T} will be directly adjacent in
314 the typeset document.
315
316 Note also that though the first non-comment character after the
317 second comment is the letter \character{S}, there is whitespace
318 preceding the comment, so the two sentences are separated as
319 expected.
320
321 A \dfn{group} is an enclosure for a collection of text and
322 commands which encloses the formatting context and constrains the
323 scope of any changes to that context made by commands within the
324 group. Groups can be nested hierarchically. The formatting
325 context includes the font and the definition of additional macros
326 (or overrides of macros defined in outer groups). Syntactically,
327 groups are enclosed in braces:
328
329\begin{verbatim}
330{text in a group}
331\end{verbatim}
332
Fred Drake4c6f17a2001-04-18 05:12:47 +0000333 An alternate syntax for a group using brackets, \code{[...]}, is
Fred Drake63568aa2000-10-19 05:36:10 +0000334 used by macros and environment constructors which take optional
335 parameters; brackets do not normally hold syntactic significance.
336 A degenerate group, containing only one atomic bit of content,
337 does not need to have an explicit group, unless it is required to
338 avoid ambiguity. Since Python tends toward the explicit, groups
339 are also made explicit in the documentation markup.
340
341 Groups are used only sparingly in the Python documentation, except
342 for their use in marking parameters to macros and environments.
343
Fred Drake4c6f17a2001-04-18 05:12:47 +0000344 A \dfn{macro} is usually a simple construct which is identified by
Fred Drake63568aa2000-10-19 05:36:10 +0000345 name and can take some number of parameters. In normal \LaTeX{}
346 usage, one of these can be optional. The markup is introduced
347 using the backslash character (\character{\e}), and the name is
348 given by alphabetic characters (no digits, hyphens, or
349 underscores). Required parameters should be marked as a group,
350 and optional parameters should be marked using the alternate
351 syntax for a group.
352
Neal Norwitz750f0602004-08-01 22:36:40 +0000353 For example, a macro which takes a single parameter
Fred Drake63568aa2000-10-19 05:36:10 +0000354 would appear like this:
355
356\begin{verbatim}
357\name{parameter}
358\end{verbatim}
359
360 A macro which takes an optional parameter would be typed like this
Raymond Hettinger5232f502004-03-25 08:51:36 +0000361 when the optional parameter is given:
Fred Drake63568aa2000-10-19 05:36:10 +0000362
363\begin{verbatim}
364\name[optional]
365\end{verbatim}
366
367 If both optional and required parameters are to be required, it
368 looks like this:
369
370\begin{verbatim}
371\name[optional]{required}
372\end{verbatim}
373
374 A macro name may be followed by a space or newline; a space
375 between the macro name and any parameters will be consumed, but
376 this usage is not practiced in the Python documentation. Such a
Fred Drake4c6f17a2001-04-18 05:12:47 +0000377 space is still consumed if there are no parameters to the macro,
Fred Drake63568aa2000-10-19 05:36:10 +0000378 in which case inserting an empty group (\code{\{\}}) or explicit
379 word space (\samp{\e\ }) immediately after the macro name helps to
380 avoid running the expansion of the macro into the following text.
381 Macros which take no parameters but which should not be followed
382 by a word space do not need special treatment if the following
383 character in the document source if not a name character (such as
Fred Drake4c6f17a2001-04-18 05:12:47 +0000384 punctuation).
Fred Drake63568aa2000-10-19 05:36:10 +0000385
386 Each line of this example shows an appropriate way to write text
387 which includes a macro which takes no parameters:
388
389\begin{verbatim}
390This \UNIX{} is followed by a space.
391This \UNIX\ is also followed by a space.
392\UNIX, followed by a comma, needs no additional markup.
393\end{verbatim}
394
Fred Draked097d482000-10-20 20:51:31 +0000395 An \dfn{environment} is a larger construct than a macro, and can
Fred Drake4c6f17a2001-04-18 05:12:47 +0000396 be used for things with more content than would conveniently fit
Fred Draked097d482000-10-20 20:51:31 +0000397 in a macro parameter. They are primarily used when formatting
398 parameters need to be changed before and after a large chunk of
399 content, but the content itself needs to be highly flexible. Code
400 samples are presented using an environment, and descriptions of
Fred Drake4c6f17a2001-04-18 05:12:47 +0000401 functions, methods, and classes are also marked using environments.
Fred Draked097d482000-10-20 20:51:31 +0000402
403 Since the content of an environment is free-form and can consist
404 of several paragraphs, they are actually marked using a pair of
405 macros: \macro{begin} and \macro{end}. These macros both take the
406 name of the environment as a parameter. An example is the
407 environment used to mark the abstract of a document:
408
409\begin{verbatim}
410\begin{abstract}
411 This is the text of the abstract. It concisely explains what
412 information is found in the document.
413
414 It can consist of multiple paragraphs.
415\end{abstract}
416\end{verbatim}
417
418 An environment can also have required and optional parameters of
419 its own. These follow the parameter of the \macro{begin} macro.
420 This example shows an environment which takes a single required
421 parameter:
422
423\begin{verbatim}
Fred Drake2bbc6972001-03-28 16:51:20 +0000424\begin{datadesc}{controlnames}
Fred Draked097d482000-10-20 20:51:31 +0000425 A 33-element string array that contains the \ASCII{} mnemonics for
426 the thirty-two \ASCII{} control characters from 0 (NUL) to 0x1f
427 (US), in order, plus the mnemonic \samp{SP} for the space character.
428\end{datadesc}
429\end{verbatim}
Fred Drake63568aa2000-10-19 05:36:10 +0000430
Fred Drake4c6f17a2001-04-18 05:12:47 +0000431 There are a number of less-used marks in \LaTeX{} which are used
Fred Drakee789ea12002-03-13 02:48:24 +0000432 to enter characters which are not found in \ASCII{} or which a
433 considered special, or \emph{active} in \TeX{} or \LaTeX. Given
434 that these are often used adjacent to other characters, the markup
435 required to produce the proper character may need to be followed
436 by a space or an empty group, or the markup can be enclosed in a
437 group. Some which are found in Python documentation are:
Fred Drake63568aa2000-10-19 05:36:10 +0000438
Fred Draked097d482000-10-20 20:51:31 +0000439\begin{tableii}{c|l}{textrm}{Character}{Markup}
Fred Drakee789ea12002-03-13 02:48:24 +0000440 \lineii{\textasciicircum}{\code{\e textasciicircum}}
441 \lineii{\textasciitilde}{\code{\e textasciitilde}}
442 \lineii{\textgreater}{\code{\e textgreater}}
443 \lineii{\textless}{\code{\e textless}}
Fred Draked097d482000-10-20 20:51:31 +0000444 \lineii{\c c}{\code{\e c c}}
445 \lineii{\"o}{\code{\e"o}}
446 \lineii{\o}{\code{\e o}}
447\end{tableii}
Fred Drake63568aa2000-10-19 05:36:10 +0000448
449
Skip Montanaro176bda4cd2002-04-19 04:50:44 +0000450 \subsection{Hierarchical Structure \label{latex-structure}}
Fred Drake63568aa2000-10-19 05:36:10 +0000451
Fred Draked097d482000-10-20 20:51:31 +0000452 \LaTeX{} expects documents to be arranged in a conventional,
453 hierarchical way, with chapters, sections, sub-sections,
454 appendixes, and the like. These are marked using macros rather
455 than environments, probably because the end of a section can be
456 safely inferred when a section of equal or higher level starts.
457
458 There are six ``levels'' of sectioning in the document classes
Fred Drake4c6f17a2001-04-18 05:12:47 +0000459 used for Python documentation, and the deepest two
460 levels\footnote{The deepest levels have the highest numbers in the
461 table.} are not used. The levels are:
Fred Draked097d482000-10-20 20:51:31 +0000462
463 \begin{tableiii}{c|l|c}{textrm}{Level}{Macro Name}{Notes}
464 \lineiii{1}{\macro{chapter}}{(1)}
465 \lineiii{2}{\macro{section}}{}
466 \lineiii{3}{\macro{subsection}}{}
Fred Drakeb7a52c92000-11-27 20:10:18 +0000467 \lineiii{4}{\macro{subsubsection}}{}
Fred Draked097d482000-10-20 20:51:31 +0000468 \lineiii{5}{\macro{paragraph}}{(2)}
469 \lineiii{6}{\macro{subparagraph}}{}
470 \end{tableiii}
471
472 \noindent
473 Notes:
474
475 \begin{description}
476 \item[(1)]
477 Only used for the \code{manual} documents, as described in
478 section \ref{classes}, ``Document Classes.''
479 \item[(2)]
480 Not the same as a paragraph of text; nobody seems to use this.
481 \end{description}
Fred Drake2c4e0091999-03-29 14:55:55 +0000482
483
Fred Drake20a175a2004-10-18 21:30:40 +0000484 \subsection{Common Environments \label{latex-environments}}
485
486 \LaTeX{} provides a variety of environments even without the
487 additional markup provided by the Python-specific document classes
Raymond Hettinger68804312005-01-01 00:28:46 +0000488 introduced in the next section. The following environments are
Fred Drake20a175a2004-10-18 21:30:40 +0000489 provided as part of standard \LaTeX{} and are being used in the
490 standard Python documentation; descriptions will be added here as
491 time allows.
492
493\begin{verbatim}
494abstract
495alltt
496description
497displaymath
498document
499enumerate
500figure
501flushleft
502itemize
503list
504math
505quotation
506quote
507sloppypar
508verbatim
509\end{verbatim}
510
511
Fred Drakeadade921999-04-22 13:05:27 +0000512\section{Document Classes \label{classes}}
Fred Drakeacffaee1999-03-16 16:09:13 +0000513
514 Two \LaTeX{} document classes are defined specifically for use with
515 the Python documentation. The \code{manual} class is for large
516 documents which are sectioned into chapters, and the \code{howto}
517 class is for smaller documents.
518
519 The \code{manual} documents are larger and are used for most of the
520 standard documents. This document class is based on the standard
521 \LaTeX{} \code{report} class and is formatted very much like a long
Fred Drake698d5201999-11-10 15:54:57 +0000522 technical report. The \citetitle[../ref/ref.html]{Python Reference
523 Manual} is a good example of a \code{manual} document, and the
524 \citetitle[../lib/lib.html]{Python Library Reference} is a large
525 example.
Fred Drakeacffaee1999-03-16 16:09:13 +0000526
527 The \code{howto} documents are shorter, and don't have the large
528 structure of the \code{manual} documents. This class is based on
529 the standard \LaTeX{} \code{article} class and is formatted somewhat
530 like the Linux Documentation Project's ``HOWTO'' series as done
531 originally using the LinuxDoc software. The original intent for the
532 document class was that it serve a similar role as the LDP's HOWTO
533 series, but the applicability of the class turns out to be somewhat
Fred Drake02997492000-09-21 05:26:43 +0000534 broader. This class is used for ``how-to'' documents (this
Fred Drakeacffaee1999-03-16 16:09:13 +0000535 document is an example) and for shorter reference manuals for small,
536 fairly cohesive module libraries. Examples of the later use include
Fred Drake6a547c72000-09-15 22:11:24 +0000537\citetitle[http://starship.python.net/crew/fdrake/manuals/krb5py/krb5py.html]{Using
Fred Drakeacffaee1999-03-16 16:09:13 +0000538 Kerberos from Python}, which contains reference material for an
539 extension package. These documents are roughly equivalent to a
540 single chapter from a larger work.
541
542
Fred Drakef1b3de82001-07-24 14:38:34 +0000543\section{Special Markup Constructs \label{special-constructs}}
Fred Drakeacffaee1999-03-16 16:09:13 +0000544
Fred Drake2c4e0091999-03-29 14:55:55 +0000545 The Python document classes define a lot of new environments and
546 macros. This section contains the reference material for these
Fred Drake20a175a2004-10-18 21:30:40 +0000547 facilities. Documentation for ``standard'' \LaTeX{} constructs is
548 not included here, though they are used in the Python documentation.
Fred Drake2c4e0091999-03-29 14:55:55 +0000549
Fred Drakeaf2b7142000-09-14 20:11:05 +0000550 \subsection{Markup for the Preamble \label{preamble-info}}
551
552 \begin{macrodesc}{release}{\p{ver}}
553 Set the version number for the software described in the
554 document.
555 \end{macrodesc}
556
557 \begin{macrodesc}{setshortversion}{\p{sver}}
558 Specify the ``short'' version number of the documented software
559 to be \var{sver}.
560 \end{macrodesc}
561
Fred Drakee15956b2000-04-03 04:51:13 +0000562 \subsection{Meta-information Markup \label{meta-info}}
563
564 \begin{macrodesc}{sectionauthor}{\p{author}\p{email}}
565 Identifies the author of the current section. \var{author}
566 should be the author's name such that it can be used for
567 presentation (though it isn't), and \var{email} should be the
568 author's email address. The domain name portion of
569 the address should be lower case.
570
Fred Drakee7f343d2003-07-11 03:36:15 +0000571 No presentation is generated from this markup, but it is used to
Fred Drakee15956b2000-04-03 04:51:13 +0000572 help keep track of contributions.
573 \end{macrodesc}
574
Fred Drakeacffaee1999-03-16 16:09:13 +0000575 \subsection{Information Units \label{info-units}}
576
Fred Drake2f4bebd1999-04-28 16:43:11 +0000577 XXX Explain terminology, or come up with something more ``lay.''
Fred Drakeacffaee1999-03-16 16:09:13 +0000578
Fred Drakeadade921999-04-22 13:05:27 +0000579 There are a number of environments used to describe specific
580 features provided by modules. Each environment requires
581 parameters needed to provide basic information about what is being
582 described, and the environment content should be the description.
583 Most of these environments make entries in the general index (if
584 one is being produced for the document); if no index entry is
585 desired, non-indexing variants are available for many of these
586 environments. The environments have names of the form
587 \code{\var{feature}desc}, and the non-indexing variants are named
588 \code{\var{feature}descni}. The available variants are explicitly
589 included in the list below.
590
591 For each of these environments, the first parameter, \var{name},
592 provides the name by which the feature is accessed.
593
594 Environments which describe features of objects within a module,
595 such as object methods or data attributes, allow an optional
596 \var{type name} parameter. When the feature is an attribute of
597 class instances, \var{type name} only needs to be given if the
598 class was not the most recently described class in the module; the
599 \var{name} value from the most recent \env{classdesc} is implied.
600 For features of built-in or extension types, the \var{type name}
Fred Drake7a737df1999-04-23 14:41:44 +0000601 value should always be provided. Another special case includes
602 methods and members of general ``protocols,'' such as the
603 formatter and writer protocols described for the
604 \module{formatter} module: these may be documented without any
605 specific implementation classes, and will always require the
606 \var{type name} parameter to be provided.
Fred Drakeadade921999-04-22 13:05:27 +0000607
Fred Drake7be440d2000-09-16 21:23:25 +0000608 \begin{envdesc}{cfuncdesc}{\p{type}\p{name}\p{args}}
609 Environment used to described a C function. The \var{type}
610 should be specified as a \keyword{typedef} name, \code{struct
611 \var{tag}}, or the name of a primitive type. If it is a pointer
Fred Drake02997492000-09-21 05:26:43 +0000612 type, the trailing asterisk should not be preceded by a space.
Fred Drake7be440d2000-09-16 21:23:25 +0000613 \var{name} should be the name of the function (or function-like
614 pre-processor macro), and \var{args} should give the types and
615 names of the parameters. The names need to be given so they may
616 be used in the description.
617 \end{envdesc}
618
Fred Drake1251b0e2002-04-15 20:10:23 +0000619 \begin{envdesc}{cmemberdesc}{\p{container}\p{type}\p{name}}
620 Description for a structure member. \var{container} should be
621 the \keyword{typedef} name, if there is one, otherwise if should
622 be \samp{struct \var{tag}}. The type of the member should given
623 as \var{type}, and the name should be given as \var{name}. The
624 text of the description should include the range of values
625 allowed, how the value should be interpreted, and whether the
626 value can be changed. References to structure members in text
627 should use the \macro{member} macro.
628 \end{envdesc}
629
Fred Drake79bf99c2002-04-09 20:17:42 +0000630 \begin{envdesc}{csimplemacrodesc}{\p{name}}
631 Documentation for a ``simple'' macro. Simple macros are macros
632 which are used for code expansion, but which do not take
633 arguments so cannot be described as functions. This is not to
Neil Schemenauerc4932292005-06-18 17:54:13 +0000634 be used for simple constant definitions. Examples of its use
Fred Drake79bf99c2002-04-09 20:17:42 +0000635 in the Python documentation include
636 \csimplemacro{PyObject_HEAD} and
637 \csimplemacro{Py_BEGIN_ALLOW_THREADS}.
638 \end{envdesc}
639
Fred Drake7be440d2000-09-16 21:23:25 +0000640 \begin{envdesc}{ctypedesc}{\op{tag}\p{name}}
641 Environment used to described a C type. The \var{name}
642 parameter should be the \keyword{typedef} name. If the type is
643 defined as a \keyword{struct} without a \keyword{typedef},
644 \var{name} should have the form \code{struct \var{tag}}.
645 \var{name} will be added to the index unless \var{tag} is
646 provided, in which case \var{tag} will be used instead.
647 \var{tag} should not be used for a \keyword{typedef} name.
648 \end{envdesc}
649
650 \begin{envdesc}{cvardesc}{\p{type}\p{name}}
651 Description of a global C variable. \var{type} should be the
652 \keyword{typedef} name, \code{struct \var{tag}}, or the name of
653 a primitive type. If variable has a pointer type, the trailing
Fred Drake02997492000-09-21 05:26:43 +0000654 asterisk should \emph{not} be preceded by a space.
Fred Drake7be440d2000-09-16 21:23:25 +0000655 \end{envdesc}
656
Fred Drakeadade921999-04-22 13:05:27 +0000657 \begin{envdesc}{datadesc}{\p{name}}
658 This environment is used to document global data in a module,
659 including both variables and values used as ``defined
660 constants.'' Class and object attributes are not documented
661 using this environment.
Fred Drakeacffaee1999-03-16 16:09:13 +0000662 \end{envdesc}
Fred Drake7a737df1999-04-23 14:41:44 +0000663 \begin{envdesc}{datadescni}{\p{name}}
Fred Drakeacffaee1999-03-16 16:09:13 +0000664 Like \env{datadesc}, but without creating any index entries.
665 \end{envdesc}
666
Fred Drake9f2376d2001-05-11 01:01:12 +0000667 \begin{envdesc}{excclassdesc}{\p{name}\p{constructor parameters}}
Raymond Hettinger68804312005-01-01 00:28:46 +0000668 Describe an exception defined by a class. \var{constructor
Fred Drake9f2376d2001-05-11 01:01:12 +0000669 parameters} should not include the \var{self} parameter or
670 the parentheses used in the call syntax. To describe an
671 exception class without describing the parameters to its
672 constructor, use the \env{excdesc} environment.
673 \end{envdesc}
674
Fred Drakeadade921999-04-22 13:05:27 +0000675 \begin{envdesc}{excdesc}{\p{name}}
Neal Norwitz847207a2003-05-29 02:17:23 +0000676 Describe an exception. In the case of class exceptions, the
Fred Drake9f2376d2001-05-11 01:01:12 +0000677 constructor parameters are not described; use \env{excclassdesc}
678 to describe an exception class and its constructor.
Fred Drakeacffaee1999-03-16 16:09:13 +0000679 \end{envdesc}
680
Fred Drakeadade921999-04-22 13:05:27 +0000681 \begin{envdesc}{funcdesc}{\p{name}\p{parameters}}
682 Describe a module-level function. \var{parameters} should
683 not include the parentheses used in the call syntax. Object
684 methods are not documented using this environment. Bound object
685 methods placed in the module namespace as part of the public
686 interface of the module are documented using this, as they are
687 equivalent to normal functions for most purposes.
688
689 The description should include information about the parameters
690 required and how they are used (especially whether mutable
691 objects passed as parameters are modified), side effects, and
692 possible exceptions. A small example may be provided.
Fred Drakeacffaee1999-03-16 16:09:13 +0000693 \end{envdesc}
Fred Drakeadade921999-04-22 13:05:27 +0000694 \begin{envdesc}{funcdescni}{\p{name}\p{parameters}}
Fred Drakeacffaee1999-03-16 16:09:13 +0000695 Like \env{funcdesc}, but without creating any index entries.
696 \end{envdesc}
697
Fred Drakeadade921999-04-22 13:05:27 +0000698 \begin{envdesc}{classdesc}{\p{name}\p{constructor parameters}}
699 Describe a class and its constructor. \var{constructor
700 parameters} should not include the \var{self} parameter or
701 the parentheses used in the call syntax.
Fred Drakeacffaee1999-03-16 16:09:13 +0000702 \end{envdesc}
703
Fred Drake9f2376d2001-05-11 01:01:12 +0000704 \begin{envdesc}{classdesc*}{\p{name}}
705 Describe a class without describing the constructor. This can
706 be used to describe classes that are merely containers for
707 attributes or which should never be instantiated or subclassed
708 by user code.
709 \end{envdesc}
710
Fred Drakeadade921999-04-22 13:05:27 +0000711 \begin{envdesc}{memberdesc}{\op{type name}\p{name}}
712 Describe an object data attribute. The description should
713 include information about the type of the data to be expected
714 and whether it may be changed directly.
Fred Drakeacffaee1999-03-16 16:09:13 +0000715 \end{envdesc}
Fred Drakeadade921999-04-22 13:05:27 +0000716 \begin{envdesc}{memberdescni}{\op{type name}\p{name}}
Fred Drakeacffaee1999-03-16 16:09:13 +0000717 Like \env{memberdesc}, but without creating any index entries.
718 \end{envdesc}
719
Fred Drakeadade921999-04-22 13:05:27 +0000720 \begin{envdesc}{methoddesc}{\op{type name}\p{name}\p{parameters}}
721 Describe an object method. \var{parameters} should not include
722 the \var{self} parameter or the parentheses used in the call
723 syntax. The description should include similar information to
724 that described for \env{funcdesc}.
Fred Drakeacffaee1999-03-16 16:09:13 +0000725 \end{envdesc}
Fred Drakeadade921999-04-22 13:05:27 +0000726 \begin{envdesc}{methoddescni}{\op{type name}\p{name}\p{parameters}}
Fred Drakeacffaee1999-03-16 16:09:13 +0000727 Like \env{methoddesc}, but without creating any index entries.
728 \end{envdesc}
729
730
Fred Drakef1b3de82001-07-24 14:38:34 +0000731 \subsection{Showing Code Examples \label{showing-examples}}
Fred Drake5eb992b1999-06-11 14:25:45 +0000732
733 Examples of Python source code or interactive sessions are
734 represented as \env{verbatim} environments. This environment
735 is a standard part of \LaTeX{}. It is important to only use
736 spaces for indentation in code examples since \TeX{} drops tabs
737 instead of converting them to spaces.
738
739 Representing an interactive session requires including the prompts
740 and output along with the Python code. No special markup is
Fred Drake63568aa2000-10-19 05:36:10 +0000741 required for interactive sessions. After the last line of input
742 or output presented, there should not be an ``unused'' primary
743 prompt; this is an example of what \emph{not} to do:
744
745\begin{verbatim}
746>>> 1 + 1
7472
Fred Drakee7f343d2003-07-11 03:36:15 +0000748>>>
Fred Drake63568aa2000-10-19 05:36:10 +0000749\end{verbatim}
Fred Drake5eb992b1999-06-11 14:25:45 +0000750
751 Within the \env{verbatim} environment, characters special to
752 \LaTeX{} do not need to be specially marked in any way. The entire
753 example will be presented in a monospaced font; no attempt at
754 ``pretty-printing'' is made, as the environment must work for
Fred Drake63568aa2000-10-19 05:36:10 +0000755 non-Python code and non-code displays. There should be no blank
756 lines at the top or bottom of any \env{verbatim} display.
Fred Drake5eb992b1999-06-11 14:25:45 +0000757
Fred Drake66eed242001-06-18 14:59:58 +0000758 Longer displays of verbatim text may be included by storing the
759 example text in an external file containing only plain text. The
760 file may be included using the standard \macro{verbatiminput}
761 macro; this macro takes a single argument naming the file
762 containing the text. For example, to include the Python source
763 file \file{example.py}, use:
764
765\begin{verbatim}
766\verbatiminput{example.py}
767\end{verbatim}
768
769 Use of \macro{verbatiminput} allows easier use of special editing
770 modes for the included file. The file should be placed in the
771 same directory as the \LaTeX{} files for the document.
772
Fred Drake5eb992b1999-06-11 14:25:45 +0000773 The Python Documentation Special Interest Group has discussed a
774 number of approaches to creating pretty-printed code displays and
775 interactive sessions; see the Doc-SIG area on the Python Web site
776 for more information on this topic.
777
778
Fred Drakef1b3de82001-07-24 14:38:34 +0000779 \subsection{Inline Markup \label{inline-markup}}
Fred Drakeacffaee1999-03-16 16:09:13 +0000780
Fred Drake87f768e1999-05-17 15:22:45 +0000781 The macros described in this section are used to mark just about
782 anything interesting in the document text. They may be used in
783 headings (though anything involving hyperlinks should be avoided
784 there) as well as in the body text.
Fred Drake2f4bebd1999-04-28 16:43:11 +0000785
786 \begin{macrodesc}{bfcode}{\p{text}}
787 Like \macro{code}, but also makes the font bold-face.
788 \end{macrodesc}
789
790 \begin{macrodesc}{cdata}{\p{name}}
791 The name of a C-language variable.
792 \end{macrodesc}
793
794 \begin{macrodesc}{cfunction}{\p{name}}
795 The name of a C-language function. \var{name} should include the
796 function name and the trailing parentheses.
797 \end{macrodesc}
798
799 \begin{macrodesc}{character}{\p{char}}
800 A character when discussing the character rather than a one-byte
801 string value. The character will be typeset as with \macro{samp}.
802 \end{macrodesc}
803
Fred Drake29a710f1999-11-10 22:51:18 +0000804 \begin{macrodesc}{citetitle}{\op{url}\p{title}}
805 A title for a referenced publication. If \var{url} is specified,
806 the title will be made into a hyperlink when formatted as HTML.
807 \end{macrodesc}
808
Fred Drake2f4bebd1999-04-28 16:43:11 +0000809 \begin{macrodesc}{class}{\p{name}}
810 A class name; a dotted name may be used.
811 \end{macrodesc}
812
813 \begin{macrodesc}{code}{\p{text}}
814 A short code fragment or literal constant value. Typically, it
815 should not include any spaces since no quotation marks are
816 added.
817 \end{macrodesc}
818
819 \begin{macrodesc}{constant}{\p{name}}
820 The name of a ``defined'' constant. This may be a C-language
821 \code{\#define} or a Python variable that is not intended to be
822 changed.
823 \end{macrodesc}
824
Fred Drake79bf99c2002-04-09 20:17:42 +0000825 \begin{macrodesc}{csimplemacro}{\p{name}}
826 The name of a ``simple'' macro. Simple macros are macros
827 which are used for code expansion, but which do not take
828 arguments so cannot be described as functions. This is not to
Neil Schemenauerc4932292005-06-18 17:54:13 +0000829 be used for simple constant definitions. Examples of its use
Fred Drake79bf99c2002-04-09 20:17:42 +0000830 in the Python documentation include
831 \csimplemacro{PyObject_HEAD} and
832 \csimplemacro{Py_BEGIN_ALLOW_THREADS}.
833 \end{macrodesc}
834
Fred Drake2f4bebd1999-04-28 16:43:11 +0000835 \begin{macrodesc}{ctype}{\p{name}}
836 The name of a C \keyword{typedef} or structure. For structures
837 defined without a \keyword{typedef}, use \code{\e ctype\{struct
838 struct_tag\}} to make it clear that the \keyword{struct} is
839 required.
840 \end{macrodesc}
841
842 \begin{macrodesc}{deprecated}{\p{version}\p{what to do}}
Fred Drakee7f343d2003-07-11 03:36:15 +0000843 Declare whatever is being described as being deprecated starting
Fred Drake2f4bebd1999-04-28 16:43:11 +0000844 with release \var{version}. The text given as \var{what to do}
Fred Drakef79f2f92002-05-21 16:27:20 +0000845 should recommend something to use instead. It should be
846 complete sentences. The entire deprecation notice will be
Raymond Hettinger68804312005-01-01 00:28:46 +0000847 presented as a separate paragraph; it should either precede or
Fred Drakef79f2f92002-05-21 16:27:20 +0000848 succeed the description of the deprecated feature.
Fred Drake2f4bebd1999-04-28 16:43:11 +0000849 \end{macrodesc}
850
851 \begin{macrodesc}{dfn}{\p{term}}
Fred Drakee7f343d2003-07-11 03:36:15 +0000852 Mark the defining instance of \var{term} in the text. (No index
Fred Drake2f4bebd1999-04-28 16:43:11 +0000853 entries are generated.)
854 \end{macrodesc}
855
Fred Draked1fb7791999-05-17 16:33:54 +0000856 \begin{macrodesc}{e}{}
Fred Drake27da2912004-02-09 21:00:29 +0000857 Produces a backslash. This is convenient in \macro{code},
Fred Drake29f59332004-02-10 18:30:22 +0000858 \macro{file}, and similar macros, and the \env{alltt}
859 environment, and is only defined there. To
Fred Drake27da2912004-02-09 21:00:29 +0000860 create a backslash in ordinary text (such as the contents of the
861 \macro{citetitle} macro), use the standard \macro{textbackslash}
862 macro.
Fred Draked1fb7791999-05-17 16:33:54 +0000863 \end{macrodesc}
864
Fred Drake2f4bebd1999-04-28 16:43:11 +0000865 \begin{macrodesc}{email}{\p{address}}
866 An email address. Note that this is \emph{not} hyperlinked in
Fred Drakee15956b2000-04-03 04:51:13 +0000867 any of the possible output formats. The domain name portion of
868 the address should be lower case.
Fred Drake2f4bebd1999-04-28 16:43:11 +0000869 \end{macrodesc}
870
871 \begin{macrodesc}{emph}{\p{text}}
872 Emphasized text; this will be presented in an italic font.
873 \end{macrodesc}
874
875 \begin{macrodesc}{envvar}{\p{name}}
876 An environment variable. Index entries are generated.
877 \end{macrodesc}
878
879 \begin{macrodesc}{exception}{\p{name}}
880 The name of an exception. A dotted name may be used.
881 \end{macrodesc}
882
883 \begin{macrodesc}{file}{\p{file or dir}}
884 The name of a file or directory. In the PDF and PostScript
885 outputs, single quotes and a font change are used to indicate
886 the file name, but no quotes are used in the HTML output.
Fred Drake64a5aaf2001-10-20 04:18:14 +0000887 \warning{The \macro{file} macro cannot be used in the
888 content of a section title due to processing limitations.}
Fred Drake2f4bebd1999-04-28 16:43:11 +0000889 \end{macrodesc}
890
891 \begin{macrodesc}{filenq}{\p{file or dir}}
892 Like \macro{file}, but single quotes are never used. This can
Fred Drakee7f343d2003-07-11 03:36:15 +0000893 be used in conjunction with tables if a column will only contain
Fred Drake2f4bebd1999-04-28 16:43:11 +0000894 file or directory names.
Fred Drake64a5aaf2001-10-20 04:18:14 +0000895 \warning{The \macro{filenq} macro cannot be used in the
896 content of a section title due to processing limitations.}
Fred Drake2f4bebd1999-04-28 16:43:11 +0000897 \end{macrodesc}
898
899 \begin{macrodesc}{function}{\p{name}}
900 The name of a Python function; dotted names may be used.
901 \end{macrodesc}
902
Fred Drake432cef02001-07-06 22:34:33 +0000903 \begin{macrodesc}{infinity}{}
904 The symbol for mathematical infinity: \infinity. Some Web
905 browsers are not able to render the HTML representation of this
906 symbol properly, but support is growing.
907 \end{macrodesc}
908
Fred Drake2f4bebd1999-04-28 16:43:11 +0000909 \begin{macrodesc}{kbd}{\p{key sequence}}
910 Mark a sequence of keystrokes. What form \var{key sequence}
911 takes may depend on platform- or application-specific
Fred Drake07178d22001-07-12 02:08:29 +0000912 conventions. When there are no relevant conventions, the names
913 of modifier keys should be spelled out, to improve accessibility
914 for new users and non-native speakers. For example, an
915 \program{xemacs} key sequence may be marked like
916 \code{\e kbd\{C-x C-f\}}, but without reference to a specific
917 application or platform, the same sequence should be marked as
918 \code{\e kbd\{Control-x Control-f\}}.
Fred Drake2f4bebd1999-04-28 16:43:11 +0000919 \end{macrodesc}
920
921 \begin{macrodesc}{keyword}{\p{name}}
922 The name of a keyword in a programming language.
923 \end{macrodesc}
924
Fred Drake8b3a7b52001-09-26 17:01:58 +0000925 \begin{macrodesc}{mailheader}{\p{name}}
926 The name of an \rfc{822}-style mail header. This markup does
927 not imply that the header is being used in an email message, but
928 can be used to refer to any header of the same ``style.'' This
929 is also used for headers defined by the various MIME
930 specifications. The header name should be entered in the same
931 way it would normally be found in practice, with the
932 camel-casing conventions being preferred where there is more
Fred Drake203d91a2001-09-26 18:43:20 +0000933 than one common usage. The colon which follows the name of the
934 header should not be included.
935 For example: \code{\e mailheader\{Content-Type\}}.
Fred Drake8b3a7b52001-09-26 17:01:58 +0000936 \end{macrodesc}
937
Fred Drake2f4bebd1999-04-28 16:43:11 +0000938 \begin{macrodesc}{makevar}{\p{name}}
939 The name of a \program{make} variable.
940 \end{macrodesc}
941
942 \begin{macrodesc}{manpage}{\p{name}\p{section}}
943 A reference to a \UNIX{} manual page.
944 \end{macrodesc}
945
946 \begin{macrodesc}{member}{\p{name}}
947 The name of a data attribute of an object.
948 \end{macrodesc}
949
950 \begin{macrodesc}{method}{\p{name}}
951 The name of a method of an object. \var{name} should include the
952 method name and the trailing parentheses. A dotted name may be
953 used.
954 \end{macrodesc}
955
956 \begin{macrodesc}{mimetype}{\p{name}}
Fred Drake8b3a7b52001-09-26 17:01:58 +0000957 The name of a MIME type, or a component of a MIME type (the
958 major or minor portion, taken alone).
Fred Drake2f4bebd1999-04-28 16:43:11 +0000959 \end{macrodesc}
960
961 \begin{macrodesc}{module}{\p{name}}
Fred Drake2b853412000-04-11 19:08:30 +0000962 The name of a module; a dotted name may be used. This should
963 also be used for package names.
Fred Drake2f4bebd1999-04-28 16:43:11 +0000964 \end{macrodesc}
965
966 \begin{macrodesc}{newsgroup}{\p{name}}
Fred Drake9120df32001-07-14 02:34:12 +0000967 The name of a Usenet newsgroup.
Fred Drake2f4bebd1999-04-28 16:43:11 +0000968 \end{macrodesc}
969
Fred Drake92350b32001-10-09 18:01:23 +0000970 \begin{macrodesc}{note}{\p{text}}
971 An especially important bit of information about an API that a
972 user should be aware of when using whatever bit of API the
973 note pertains to. This should be the last thing in the
974 paragraph as the end of the note is not visually marked in
Fred Drake64a5aaf2001-10-20 04:18:14 +0000975 any way. The content of \var{text} should be written in
976 complete sentences and include all appropriate punctuation.
Fred Drake92350b32001-10-09 18:01:23 +0000977 \end{macrodesc}
978
Fred Drake432cef02001-07-06 22:34:33 +0000979 \begin{macrodesc}{pep}{\p{number}}
980 A reference to a Python Enhancement Proposal. This generates
981 appropriate index entries. The text \samp{PEP \var{number}} is
982 generated; in the HTML output, this text is a hyperlink to an
983 online copy of the specified PEP.
984 \end{macrodesc}
985
986 \begin{macrodesc}{plusminus}{}
987 The symbol for indicating a value that may take a positive or
988 negative value of a specified magnitude, typically represented
989 by a plus sign placed over a minus sign. For example:
Fred Drake203d91a2001-09-26 18:43:20 +0000990 \code{\e plusminus 3\%{}}.
Fred Drake432cef02001-07-06 22:34:33 +0000991 \end{macrodesc}
992
Fred Drake2f4bebd1999-04-28 16:43:11 +0000993 \begin{macrodesc}{program}{\p{name}}
994 The name of an executable program. This may differ from the
Fred Drakee7f343d2003-07-11 03:36:15 +0000995 file name for the executable for some platforms. In particular,
996 the \file{.exe} (or other) extension should be omitted for
Martin v. Löwis36a4d8c2002-10-10 18:24:54 +0000997 Windows programs.
Fred Drake2f4bebd1999-04-28 16:43:11 +0000998 \end{macrodesc}
999
Fred Drake29a710f1999-11-10 22:51:18 +00001000 \begin{macrodesc}{programopt}{\p{option}}
Fred Drakece444982000-04-11 18:52:52 +00001001 A command-line option to an executable program. Use this only
Greg Ward8b46c712002-06-29 01:23:45 +00001002 for ``short'' options, and include the leading hyphen.
Fred Drakece444982000-04-11 18:52:52 +00001003 \end{macrodesc}
1004
1005 \begin{macrodesc}{longprogramopt}{\p{option}}
1006 A long command-line option to an executable program. This
1007 should only be used for long option names which will be prefixed
1008 by two hyphens; the hyphens should not be provided as part of
1009 \var{option}.
Fred Drake29a710f1999-11-10 22:51:18 +00001010 \end{macrodesc}
1011
Fred Drake2f4bebd1999-04-28 16:43:11 +00001012 \begin{macrodesc}{refmodule}{\op{key}\p{name}}
Fred Drakee7f343d2003-07-11 03:36:15 +00001013 Like \macro{module}, but create a hyperlink to the documentation
Fred Drake2f4bebd1999-04-28 16:43:11 +00001014 for the named module. Note that the corresponding
1015 \macro{declaremodule} must be in the same document. If the
1016 \macro{declaremodule} defines a module key different from the
1017 module name, it must also be provided as \var{key} to the
1018 \macro{refmodule} macro.
1019 \end{macrodesc}
1020
1021 \begin{macrodesc}{regexp}{\p{string}}
1022 Mark a regular expression.
1023 \end{macrodesc}
1024
1025 \begin{macrodesc}{rfc}{\p{number}}
Fred Drakee7f343d2003-07-11 03:36:15 +00001026 A reference to an Internet Request for Comments. This generates
Fred Drake2f4bebd1999-04-28 16:43:11 +00001027 appropriate index entries. The text \samp{RFC \var{number}} is
1028 generated; in the HTML output, this text is a hyperlink to an
1029 online copy of the specified RFC.
1030 \end{macrodesc}
1031
1032 \begin{macrodesc}{samp}{\p{text}}
1033 A short code sample, but possibly longer than would be given
Fred Drakee7f343d2003-07-11 03:36:15 +00001034 using \macro{code}. Since quotation marks are added, spaces are
Fred Drake2f4bebd1999-04-28 16:43:11 +00001035 acceptable.
1036 \end{macrodesc}
1037
Fred Drakeaf2b7142000-09-14 20:11:05 +00001038 \begin{macrodesc}{shortversion}{}
1039 The ``short'' version number of the documented software, as
1040 specified using the \macro{setshortversion} macro in the
1041 preamble. For Python, the short version number for a release is
1042 the first three characters of the \code{sys.version} value. For
1043 example, versions 2.0b1 and 2.0.1 both have a short version of
1044 2.0. This may not apply for all packages; if
1045 \macro{setshortversion} is not used, this produces an empty
1046 expansion. See also the \macro{version} macro.
1047 \end{macrodesc}
1048
Fred Drake2f4bebd1999-04-28 16:43:11 +00001049 \begin{macrodesc}{strong}{\p{text}}
1050 Strongly emphasized text; this will be presented using a bold
1051 font.
1052 \end{macrodesc}
1053
Fred Drake432cef02001-07-06 22:34:33 +00001054 \begin{macrodesc}{ulink}{\p{text}\p{url}}
1055 A hypertext link with a target specified by a URL, but for which
1056 the link text should not be the title of the resource. For
1057 resources being referenced by name, use the \macro{citetitle}
1058 macro. Not all formatted versions support arbitrary hypertext
1059 links. Note that many characters are special to \LaTeX{} and
1060 this macro does not always do the right thing. In particular,
1061 the tilde character (\character{\~}) is mis-handled; encoding it
1062 as a hex-sequence does work, use \samp{\%7e} in place of the
1063 tilde character.
1064 \end{macrodesc}
1065
Fred Draked1fb7791999-05-17 16:33:54 +00001066 \begin{macrodesc}{url}{\p{url}}
Fred Drakee7f343d2003-07-11 03:36:15 +00001067 A URL (or URN). The URL will be presented as text. In the HTML
Fred Draked1fb7791999-05-17 16:33:54 +00001068 and PDF formatted versions, the URL will also be a hyperlink.
Fred Drake432cef02001-07-06 22:34:33 +00001069 This can be used when referring to external resources without
1070 specific titles; references to resources which have titles
1071 should be marked using the \macro{citetitle} macro. See the
1072 comments about special characters in the description of the
1073 \macro{ulink} macro for special considerations.
Fred Draked1fb7791999-05-17 16:33:54 +00001074 \end{macrodesc}
1075
Fred Drake2f4bebd1999-04-28 16:43:11 +00001076 \begin{macrodesc}{var}{\p{name}}
1077 The name of a variable or formal parameter in running text.
1078 \end{macrodesc}
1079
1080 \begin{macrodesc}{version}{}
Fred Drakeaf2b7142000-09-14 20:11:05 +00001081 The version number of the described software, as specified using
1082 \macro{release} in the preamble. See also the
1083 \macro{shortversion} macro.
Fred Drake2f4bebd1999-04-28 16:43:11 +00001084 \end{macrodesc}
Fred Drakeacffaee1999-03-16 16:09:13 +00001085
Fred Drake92350b32001-10-09 18:01:23 +00001086 \begin{macrodesc}{warning}{\p{text}}
1087 An important bit of information about an API that a user should
1088 be very aware of when using whatever bit of API the warning
1089 pertains to. This should be the last thing in the paragraph as
Fred Drake64a5aaf2001-10-20 04:18:14 +00001090 the end of the warning is not visually marked in any way. The
1091 content of \var{text} should be written in complete sentences
1092 and include all appropriate punctuation. This differs from
1093 \macro{note} in that it is recommended over \macro{note} for
1094 information regarding security.
Fred Drake92350b32001-10-09 18:01:23 +00001095 \end{macrodesc}
1096
Fred Drakec0ed9c42004-07-13 21:04:26 +00001097 The following two macros are used to describe information that's
1098 associated with changes from one release to another. For features
1099 which are described by a single paragraph, these are typically
1100 added as separate source lines at the end of the paragraph. When
1101 adding these to features described by multiple paragraphs, they
1102 are usually collected in a single separate paragraph after the
1103 description. When both \macro{versionadded} and
1104 \macro{versionchanged} are used, \macro{versionadded} should come
1105 first; the versions should be listed in chronological order. Both
1106 of these should come before availability statements. The location
1107 should be selected so the explanation makes sense and may vary as
1108 needed.
1109
1110 \begin{macrodesc}{versionadded}{\op{explanation}\p{version}}
1111 The version of Python which added the described feature to the
1112 library or C API. \var{explanation} should be a \emph{brief}
1113 explanation of the change consisting of a capitalized sentence
1114 fragment; a period will be appended by the formatting process.
1115 When this applies to an entire module, it should be placed at
1116 the top of the module section before any prose.
1117 \end{macrodesc}
1118
1119 \begin{macrodesc}{versionchanged}{\op{explanation}\p{version}}
1120 The version of Python in which the named feature was changed in
1121 some way (new parameters, changed side effects, etc.).
1122 \var{explanation} should be a \emph{brief} explanation of the
1123 change consisting of a capitalized sentence fragment; a
1124 period will be appended by the formatting process. This should
1125 not generally be applied to modules.
1126 \end{macrodesc}
1127
Fred Drakeacffaee1999-03-16 16:09:13 +00001128
Fred Drake6ca33772001-12-14 22:50:06 +00001129 \subsection{Miscellaneous Text Markup \label{misc-text-markup}}
1130
1131 In addition to the inline markup, some additional ``block'' markup
1132 is defined to make it easier to bring attention to various bits of
1133 text. The markup described here serves this purpose, and is
1134 intended to be used when marking one or more paragraphs or other
1135 block constructs (such as \env{verbatim} environments).
1136
1137 \begin{envdesc}{notice}{\op{type}}
1138 Label some paragraphs as being worthy of additional attention from
Raymond Hettinger68804312005-01-01 00:28:46 +00001139 the reader. What sort of attention is warranted can be indicated
Fred Drake6ca33772001-12-14 22:50:06 +00001140 by specifying the \var{type} of the notice. The only values
1141 defined for \var{type} are \code{note} and \code{warning}; these
1142 are equivalent in intent to the inline markup of the same name.
1143 If \var{type} is omitted, \code{note} is used. Additional values
1144 may be defined in the future.
1145 \end{envdesc}
1146
1147
Fred Drakef1b3de82001-07-24 14:38:34 +00001148 \subsection{Module-specific Markup \label{module-markup}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001149
1150 The markup described in this section is used to provide information
Georg Brandl29822522005-07-18 08:04:17 +00001151 about a module being documented. Each module should be documented
1152 in its own \macro{section}. A typical use of this markup
1153 appears at the top of that section and might look like this:
Fred Drakeacffaee1999-03-16 16:09:13 +00001154
1155\begin{verbatim}
1156\section{\module{spam} ---
1157 Access to the SPAM facility}
1158
1159\declaremodule{extension}{spam}
Fred Drake2c4e0091999-03-29 14:55:55 +00001160 \platform{Unix}
Fred Drake9120df32001-07-14 02:34:12 +00001161\modulesynopsis{Access to the SPAM facility of \UNIX.}
Fred Drake2c4e0091999-03-29 14:55:55 +00001162\moduleauthor{Jane Doe}{jane.doe@frobnitz.org}
Fred Drakeacffaee1999-03-16 16:09:13 +00001163\end{verbatim}
1164
Fred Drake7932ed02000-08-11 17:37:33 +00001165 Python packages\index{packages} --- collections of modules that can
1166 be described as a unit --- are documented using the same markup as
1167 modules. The name for a module in a package should be typed in
Fred Drake432cef02001-07-06 22:34:33 +00001168 ``fully qualified'' form (it should include the package name).
Fred Drake7932ed02000-08-11 17:37:33 +00001169 For example, a module ``foo'' in package ``bar'' should be marked as
Fred Drake203d91a2001-09-26 18:43:20 +00001170 \code{\e module\{bar.foo\}}, and the beginning of the reference
Fred Drake7932ed02000-08-11 17:37:33 +00001171 section would appear as:
1172
1173\begin{verbatim}
1174\section{\module{bar.foo} ---
1175 Module from the \module{bar} package}
1176
1177\declaremodule{extension}{bar.foo}
1178\modulesynopsis{Nifty module from the \module{bar} package.}
1179\moduleauthor{Jane Doe}{jane.doe@frobnitz.org}
1180\end{verbatim}
1181
1182 Note that the name of a package is also marked using
1183 \macro{module}.
1184
Fred Drakeadade921999-04-22 13:05:27 +00001185 \begin{macrodesc}{declaremodule}{\op{key}\p{type}\p{name}}
Fred Drake87f768e1999-05-17 15:22:45 +00001186 Requires two parameters: module type (\samp{standard},
1187 \samp{builtin}, \samp{extension}, or \samp{}), and the module
1188 name. An optional parameter should be given as the basis for the
1189 module's ``key'' used for linking to or referencing the section.
1190 The ``key'' should only be given if the module's name contains any
1191 underscores, and should be the name with the underscores stripped.
1192 Note that the \var{type} parameter must be one of the values
1193 listed above or an error will be printed. For modules which are
1194 contained in packages, the fully-qualified name should be given as
1195 \var{name} parameter. This should be the first thing after the
1196 \macro{section} used to introduce the module.
Fred Drakeacffaee1999-03-16 16:09:13 +00001197 \end{macrodesc}
1198
Fred Drakeadade921999-04-22 13:05:27 +00001199 \begin{macrodesc}{platform}{\p{specifier}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001200 Specifies the portability of the module. \var{specifier} is a
1201 comma-separated list of keys that specify what platforms the
1202 module is available on. The keys are short identifiers;
1203 examples that are in use include \samp{IRIX}, \samp{Mac},
1204 \samp{Windows}, and \samp{Unix}. It is important to use a key
Fred Drake7a737df1999-04-23 14:41:44 +00001205 which has already been used when applicable. This is used to
1206 provide annotations in the Module Index and the HTML and GNU info
1207 output.
Fred Drakeacffaee1999-03-16 16:09:13 +00001208 \end{macrodesc}
1209
Fred Drakeadade921999-04-22 13:05:27 +00001210 \begin{macrodesc}{modulesynopsis}{\p{text}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001211 The \var{text} is a short, ``one line'' description of the
1212 module that can be used as part of the chapter introduction.
Fred Drakeadade921999-04-22 13:05:27 +00001213 This is must be placed after \macro{declaremodule}.
Fred Drakeacffaee1999-03-16 16:09:13 +00001214 The synopsis is used in building the contents of the table
1215 inserted as the \macro{localmoduletable}. No text is
1216 produced at the point of the markup.
1217 \end{macrodesc}
1218
Fred Drakeadade921999-04-22 13:05:27 +00001219 \begin{macrodesc}{moduleauthor}{\p{name}\p{email}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001220 This macro is used to encode information about who authored a
1221 module. This is currently not used to generate output, but can be
1222 used to help determine the origin of the module.
1223 \end{macrodesc}
1224
1225
Fred Drakef1b3de82001-07-24 14:38:34 +00001226 \subsection{Library-level Markup \label{library-markup}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001227
1228 This markup is used when describing a selection of modules. For
Fred Drake698d5201999-11-10 15:54:57 +00001229 example, the \citetitle[../mac/mac.html]{Macintosh Library
1230 Modules} document uses this to help provide an overview of the
1231 modules in the collection, and many chapters in the
1232 \citetitle[../lib/lib.html]{Python Library Reference} use it for
Fred Drakeacffaee1999-03-16 16:09:13 +00001233 the same purpose.
1234
1235 \begin{macrodesc}{localmoduletable}{}
Fred Drake2c4e0091999-03-29 14:55:55 +00001236 If a \file{.syn} file exists for the current
Fred Drakeacffaee1999-03-16 16:09:13 +00001237 chapter (or for the entire document in \code{howto} documents), a
1238 \env{synopsistable} is created with the contents loaded from the
1239 \file{.syn} file.
1240 \end{macrodesc}
1241
1242
Fred Drakef1b3de82001-07-24 14:38:34 +00001243 \subsection{Table Markup \label{table-markup}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001244
1245 There are three general-purpose table environments defined which
1246 should be used whenever possible. These environments are defined
1247 to provide tables of specific widths and some convenience for
1248 formatting. These environments are not meant to be general
1249 replacements for the standard \LaTeX{} table environments, but can
1250 be used for an advantage when the documents are processed using
1251 the tools for Python documentation processing. In particular, the
1252 generated HTML looks good! There is also an advantage for the
Fred Drake67f193f2001-07-09 16:04:03 +00001253 eventual conversion of the documentation to XML (see section
Fred Drake2c4e0091999-03-29 14:55:55 +00001254 \ref{futures}, ``Future Directions'').
Fred Drakeacffaee1999-03-16 16:09:13 +00001255
1256 Each environment is named \env{table\var{cols}}, where \var{cols}
1257 is the number of columns in the table specified in lower-case
1258 Roman numerals. Within each of these environments, an additional
1259 macro, \macro{line\var{cols}}, is defined, where \var{cols}
1260 matches the \var{cols} value of the corresponding table
Fred Drake2c4e0091999-03-29 14:55:55 +00001261 environment. These are supported for \var{cols} values of
1262 \code{ii}, \code{iii}, and \code{iv}. These environments are all
Fred Drakeda72b932000-09-21 15:58:02 +00001263 built on top of the \env{tabular} environment. Variants based on
1264 the \env{longtable} environment are also provided.
Fred Drakeacffaee1999-03-16 16:09:13 +00001265
Fred Drake2b853412000-04-11 19:08:30 +00001266 Note that all tables in the standard Python documentation use
1267 vertical lines between columns, and this must be specified in the
1268 markup for each table. A general border around the outside of the
1269 table is not used, but would be the responsibility of the
Fred Drakeda72b932000-09-21 15:58:02 +00001270 processor; the document markup should not include an exterior
1271 border.
1272
1273 The \env{longtable}-based variants of the table environments are
1274 formatted with extra space before and after, so should only be
1275 used on tables which are long enough that splitting over multiple
1276 pages is reasonable; tables with fewer than twenty rows should
1277 never by marked using the long flavors of the table environments.
1278 The header row is repeated across the top of each part of the
1279 table.
Fred Drake2b853412000-04-11 19:08:30 +00001280
Fred Drakeadade921999-04-22 13:05:27 +00001281 \begin{envdesc}{tableii}{\p{colspec}\p{col1font}\p{heading1}\p{heading2}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001282 Create a two-column table using the \LaTeX{} column specifier
1283 \var{colspec}. The column specifier should indicate vertical
1284 bars between columns as appropriate for the specific table, but
1285 should not specify vertical bars on the outside of the table
1286 (that is considered a stylesheet issue). The \var{col1font}
1287 parameter is used as a stylistic treatment of the first column
1288 of the table: the first column is presented as
1289 \code{\e\var{col1font}\{column1\}}. To avoid treating the first
Fred Drakeadade921999-04-22 13:05:27 +00001290 column specially, \var{col1font} may be \samp{textrm}. The
Fred Drakeacffaee1999-03-16 16:09:13 +00001291 column headings are taken from the values \var{heading1} and
1292 \var{heading2}.
1293 \end{envdesc}
1294
Fred Drakeda72b932000-09-21 15:58:02 +00001295 \begin{envdesc}{longtableii}{\unspecified}
1296 Like \env{tableii}, but produces a table which may be broken
1297 across page boundaries. The parameters are the same as for
1298 \env{tableii}.
1299 \end{envdesc}
1300
Fred Drakeadade921999-04-22 13:05:27 +00001301 \begin{macrodesc}{lineii}{\p{column1}\p{column2}}
Fred Drakeda72b932000-09-21 15:58:02 +00001302 Create a single table row within a \env{tableii} or
1303 \env{longtableii} environment.
Fred Drakeacffaee1999-03-16 16:09:13 +00001304 The text for the first column will be generated by applying the
1305 macro named by the \var{col1font} value when the \env{tableii}
1306 was opened.
1307 \end{macrodesc}
1308
Fred Drakeadade921999-04-22 13:05:27 +00001309 \begin{envdesc}{tableiii}{\p{colspec}\p{col1font}\p{heading1}\p{heading2}\p{heading3}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001310 Like the \env{tableii} environment, but with a third column.
1311 The heading for the third column is given by \var{heading3}.
1312 \end{envdesc}
1313
Fred Drakeda72b932000-09-21 15:58:02 +00001314 \begin{envdesc}{longtableiii}{\unspecified}
1315 Like \env{tableiii}, but produces a table which may be broken
1316 across page boundaries. The parameters are the same as for
1317 \env{tableiii}.
1318 \end{envdesc}
1319
Fred Drakeadade921999-04-22 13:05:27 +00001320 \begin{macrodesc}{lineiii}{\p{column1}\p{column2}\p{column3}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001321 Like the \macro{lineii} macro, but with a third column. The
1322 text for the third column is given by \var{column3}.
1323 \end{macrodesc}
1324
Fred Drakeadade921999-04-22 13:05:27 +00001325 \begin{envdesc}{tableiv}{\p{colspec}\p{col1font}\p{heading1}\p{heading2}\p{heading3}\p{heading4}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001326 Like the \env{tableiii} environment, but with a fourth column.
1327 The heading for the fourth column is given by \var{heading4}.
1328 \end{envdesc}
1329
Fred Drakeda72b932000-09-21 15:58:02 +00001330 \begin{envdesc}{longtableiv}{\unspecified}
1331 Like \env{tableiv}, but produces a table which may be broken
1332 across page boundaries. The parameters are the same as for
1333 \env{tableiv}.
1334 \end{envdesc}
1335
Fred Drakeadade921999-04-22 13:05:27 +00001336 \begin{macrodesc}{lineiv}{\p{column1}\p{column2}\p{column3}\p{column4}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001337 Like the \macro{lineiii} macro, but with a fourth column. The
1338 text for the fourth column is given by \var{column4}.
1339 \end{macrodesc}
1340
Fred Drakef269e592001-07-17 23:05:57 +00001341 \begin{envdesc}{tablev}{\p{colspec}\p{col1font}\p{heading1}\p{heading2}\p{heading3}\p{heading4}\p{heading5}}
1342 Like the \env{tableiv} environment, but with a fifth column.
1343 The heading for the fifth column is given by \var{heading5}.
1344 \end{envdesc}
1345
1346 \begin{envdesc}{longtablev}{\unspecified}
1347 Like \env{tablev}, but produces a table which may be broken
1348 across page boundaries. The parameters are the same as for
1349 \env{tablev}.
1350 \end{envdesc}
1351
1352 \begin{macrodesc}{linev}{\p{column1}\p{column2}\p{column3}\p{column4}\p{column5}}
1353 Like the \macro{lineiv} macro, but with a fifth column. The
1354 text for the fifth column is given by \var{column5}.
1355 \end{macrodesc}
1356
Fred Drakeacffaee1999-03-16 16:09:13 +00001357
1358 An additional table-like environment is \env{synopsistable}. The
1359 table generated by this environment contains two columns, and each
1360 row is defined by an alternate definition of
Fred Drakee15956b2000-04-03 04:51:13 +00001361 \macro{modulesynopsis}. This environment is not normally used by
1362 authors, but is created by the \macro{localmoduletable} macro.
Fred Drakeacffaee1999-03-16 16:09:13 +00001363
Fred Drake0cac5f62001-08-14 21:36:19 +00001364 Here is a small example of a table given in the documentation for
1365 the \module{warnings} module; markup inside the table cells is
1366 minimal so the markup for the table itself is readily discernable.
1367 Here is the markup for the table:
1368
1369\begin{verbatim}
1370\begin{tableii}{l|l}{exception}{Class}{Description}
1371 \lineii{Warning}
1372 {This is the base class of all warning category classes. It
1373 is a subclass of \exception{Exception}.}
1374 \lineii{UserWarning}
1375 {The default category for \function{warn()}.}
1376 \lineii{DeprecationWarning}
1377 {Base category for warnings about deprecated features.}
1378 \lineii{SyntaxWarning}
1379 {Base category for warnings about dubious syntactic
1380 features.}
1381 \lineii{RuntimeWarning}
1382 {Base category for warnings about dubious runtime features.}
Barry Warsawb8c20a72002-08-14 16:40:54 +00001383 \lineii{FutureWarning}
Fred Drakee7f343d2003-07-11 03:36:15 +00001384 {Base category for warnings about constructs that will change
1385 semantically in the future.}
Fred Drake0cac5f62001-08-14 21:36:19 +00001386\end{tableii}
1387\end{verbatim}
1388
1389 Here is the resulting table:
1390
1391\begin{tableii}{l|l}{exception}{Class}{Description}
1392 \lineii{Warning}
1393 {This is the base class of all warning category classes. It
1394 is a subclass of \exception{Exception}.}
1395 \lineii{UserWarning}
1396 {The default category for \function{warn()}.}
1397 \lineii{DeprecationWarning}
1398 {Base category for warnings about deprecated features.}
1399 \lineii{SyntaxWarning}
1400 {Base category for warnings about dubious syntactic
1401 features.}
1402 \lineii{RuntimeWarning}
1403 {Base category for warnings about dubious runtime features.}
1404\end{tableii}
1405
1406 Note that the class names are implicitly marked using the
1407 \macro{exception} macro, since that is given as the \var{col1font}
1408 value for the \env{tableii} environment. To create a table using
1409 different markup for the first column, use \code{textrm} for the
1410 \var{col1font} value and mark each entry individually.
1411
1412 To add a horizontal line between vertical sections of a table, use
1413 the standard \macro{hline} macro between the rows which should be
1414 separated:
1415
1416\begin{verbatim}
1417\begin{tableii}{l|l}{constant}{Language}{Audience}
1418 \lineii{APL}{Masochists.}
1419 \lineii{BASIC}{First-time programmers on PC hardware.}
1420 \lineii{C}{\UNIX{} \&\ Linux kernel developers.}
1421 \hline
1422 \lineii{Python}{Everyone!}
1423\end{tableii}
1424\end{verbatim}
1425
1426 Note that not all presentation formats are capable of displaying a
1427 horizontal rule in this position. This is how the table looks in
1428 the format you're reading now:
1429
1430\begin{tableii}{l|l}{constant}{Language}{Audience}
1431 \lineii{APL}{Masochists.}
1432 \lineii{C}{\UNIX{} \&\ Linux kernel developers.}
1433 \lineii{JavaScript}{Web developers.}
1434 \hline
1435 \lineii{Python}{Everyone!}
1436\end{tableii}
1437
Fred Drakeacffaee1999-03-16 16:09:13 +00001438
1439 \subsection{Reference List Markup \label{references}}
1440
1441 Many sections include a list of references to module documentation
1442 or external documents. These lists are created using the
Fred Drake5ed35fd2001-11-30 18:09:54 +00001443 \env{seealso} or \env{seealso*} environments. These environments
1444 define some additional macros to support creating reference
1445 entries in a reasonable manner.
Fred Drakeacffaee1999-03-16 16:09:13 +00001446
Fred Drake5802e482000-07-06 05:24:41 +00001447 The \env{seealso} environment is typically placed in a section
1448 just before any sub-sections. This is done to ensure that
1449 reference links related to the section are not hidden in a
Fred Drake5ed35fd2001-11-30 18:09:54 +00001450 subsection in the hypertext renditions of the documentation. For
1451 the HTML output, it is shown as a ``side bar,'' boxed off from the
1452 main flow of the text. The \env{seealso*} environment is
1453 different in that it should be used when a list of references is
1454 being presented as part of the primary content; it is not
1455 specially set off from the text.
Fred Drake5802e482000-07-06 05:24:41 +00001456
Fred Drakeacffaee1999-03-16 16:09:13 +00001457 \begin{envdesc}{seealso}{}
1458 This environment creates a ``See also:'' heading and defines the
1459 markup used to describe individual references.
1460 \end{envdesc}
1461
Fred Drake5ed35fd2001-11-30 18:09:54 +00001462 \begin{envdesc}{seealso*}{}
1463 This environment is used to create a list of references which
1464 form part of the main content. It is not given a special
1465 header and is not set off from the main flow of the text. It
1466 provides the same additional markup used to describe individual
1467 references.
1468 \end{envdesc}
1469
Fred Drake48449982000-09-12 17:52:33 +00001470 For each of the following macros, \var{why} should be one or more
1471 complete sentences, starting with a capital letter (unless it
1472 starts with an identifier, which should not be modified), and
Fred Drake4f687b32004-01-08 14:57:27 +00001473 ending with the appropriate punctuation.
Fred Drake5802e482000-07-06 05:24:41 +00001474
Fred Drakeb7cf3782000-09-12 19:58:10 +00001475 These macros are only defined within the content of the
Fred Drake5ed35fd2001-11-30 18:09:54 +00001476 \env{seealso} and \env{seealso*} environments.
Fred Drakeb7cf3782000-09-12 19:58:10 +00001477
Fred Drake4f687b32004-01-08 14:57:27 +00001478 \begin{macrodesc}{seelink}{\p{url}\p{linktext}\p{why}}
1479 References to specific on-line resources should be given using
1480 the \macro{seelink} macro if they don't have a meaningful title
1481 but there is some short description of what's at the end of the
1482 link. Online documents which have identifiable titles should be
1483 referenced using the \macro{seetitle} macro, using the optional
1484 parameter to that macro to provide the URL.
1485 \end{macrodesc}
1486
Fred Drakeadade921999-04-22 13:05:27 +00001487 \begin{macrodesc}{seemodule}{\op{key}\p{name}\p{why}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001488 Refer to another module. \var{why} should be a brief
1489 explanation of why the reference may be interesting. The module
1490 name is given in \var{name}, with the link key given in
1491 \var{key} if necessary. In the HTML and PDF conversions, the
1492 module name will be a hyperlink to the referred-to module.
Fred Drake64a5aaf2001-10-20 04:18:14 +00001493 \note{The module must be documented in the same
1494 document (the corresponding \macro{declaremodule} is required).}
Fred Drakeacffaee1999-03-16 16:09:13 +00001495 \end{macrodesc}
1496
Fred Drake08c5d0c2000-09-11 05:22:30 +00001497 \begin{macrodesc}{seepep}{\p{number}\p{title}\p{why}}
1498 Refer to an Python Enhancement Proposal (PEP). \var{number}
1499 should be the official number assigned by the PEP Editor,
1500 \var{title} should be the human-readable title of the PEP as
Fred Drake5802e482000-07-06 05:24:41 +00001501 found in the official copy of the document, and \var{why} should
Fred Drake08c5d0c2000-09-11 05:22:30 +00001502 explain what's interesting about the PEP. This should be used
1503 to refer the reader to PEPs which specify interfaces or language
1504 features relevant to the material in the annotated section of the
1505 documentation.
1506 \end{macrodesc}
1507
1508 \begin{macrodesc}{seerfc}{\p{number}\p{title}\p{why}}
1509 Refer to an IETF Request for Comments (RFC). Otherwise very
1510 similar to \macro{seepep}. This should be used
1511 to refer the reader to PEPs which specify protocols or data
Fred Drake5802e482000-07-06 05:24:41 +00001512 formats relevant to the material in the annotated section of the
1513 documentation.
1514 \end{macrodesc}
1515
Fred Drakeadade921999-04-22 13:05:27 +00001516 \begin{macrodesc}{seetext}{\p{text}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001517 Add arbitrary text \var{text} to the ``See also:'' list. This
1518 can be used to refer to off-line materials or on-line materials
Fred Drake5802e482000-07-06 05:24:41 +00001519 using the \macro{url} macro. This should consist of one or more
1520 complete sentences.
1521 \end{macrodesc}
1522
Fred Drake48449982000-09-12 17:52:33 +00001523 \begin{macrodesc}{seetitle}{\op{url}\p{title}\p{why}}
1524 Add a reference to an external document named \var{title}. If
1525 \var{url} is given, the title is made a hyperlink in the HTML
1526 version of the documentation, and displayed below the title in
1527 the typeset versions of the documentation.
1528 \end{macrodesc}
1529
Fred Drake5802e482000-07-06 05:24:41 +00001530 \begin{macrodesc}{seeurl}{\p{url}\p{why}}
1531 References to specific on-line resources should be given using
Fred Drake5ed35fd2001-11-30 18:09:54 +00001532 the \macro{seeurl} macro if they don't have a meaningful title.
1533 Online documents which have identifiable titles should be
1534 referenced using the \macro{seetitle} macro, using the optional
1535 parameter to that macro to provide the URL.
Fred Drakeacffaee1999-03-16 16:09:13 +00001536 \end{macrodesc}
1537
1538
1539 \subsection{Index-generating Markup \label{indexing}}
1540
1541 Effective index generation for technical documents can be very
Fred Drakee15956b2000-04-03 04:51:13 +00001542 difficult, especially for someone familiar with the topic but not
Fred Drakeacffaee1999-03-16 16:09:13 +00001543 the creation of indexes. Much of the difficulty arises in the
1544 area of terminology: including the terms an expert would use for a
1545 concept is not sufficient. Coming up with the terms that a novice
Fred Drake2c4e0091999-03-29 14:55:55 +00001546 would look up is fairly difficult for an author who, typically, is
Fred Drakeacffaee1999-03-16 16:09:13 +00001547 an expert in the area she is writing on.
1548
Fred Drake2c4e0091999-03-29 14:55:55 +00001549 The truly difficult aspects of index generation are not areas with
1550 which the documentation tools can help. However, ease
Fred Drakee15956b2000-04-03 04:51:13 +00001551 of producing the index once content decisions are made is within
Fred Drakeacffaee1999-03-16 16:09:13 +00001552 the scope of the tools. Markup is provided which the processing
1553 software is able to use to generate a variety of kinds of index
1554 entry with minimal effort. Additionally, many of the environments
Fred Drake7a737df1999-04-23 14:41:44 +00001555 described in section \ref{info-units}, ``Information Units,'' will
Fred Drakeacffaee1999-03-16 16:09:13 +00001556 generate appropriate entries into the general and module indexes.
1557
1558 The following macro can be used to control the generation of index
Fred Drakeadade921999-04-22 13:05:27 +00001559 data, and should be used in the document preamble:
Fred Drakeacffaee1999-03-16 16:09:13 +00001560
1561 \begin{macrodesc}{makemodindex}{}
Fred Drakeadade921999-04-22 13:05:27 +00001562 This should be used in the document preamble if a ``Module
Fred Drakeacffaee1999-03-16 16:09:13 +00001563 Index'' is desired for a document containing reference material
1564 on many modules. This causes a data file
Fred Draked1fb7791999-05-17 16:33:54 +00001565 \code{lib\var{jobname}.idx} to be created from the
Fred Drakeacffaee1999-03-16 16:09:13 +00001566 \macro{declaremodule} macros. This file can be processed by the
1567 \program{makeindex} program to generate a file which can be
1568 \macro{input} into the document at the desired location of the
1569 module index.
1570 \end{macrodesc}
1571
1572 There are a number of macros that are useful for adding index
1573 entries for particular concepts, many of which are specific to
1574 programming languages or even Python.
1575
Fred Drakeadade921999-04-22 13:05:27 +00001576 \begin{macrodesc}{bifuncindex}{\p{name}}
Fred Drakeec8b9051999-04-23 20:01:17 +00001577 Add an index entry referring to a built-in function named
1578 \var{name}; parentheses should not be included after
Fred Drake2c4e0091999-03-29 14:55:55 +00001579 \var{name}.
Fred Drakeacffaee1999-03-16 16:09:13 +00001580 \end{macrodesc}
1581
Fred Drakeadade921999-04-22 13:05:27 +00001582 \begin{macrodesc}{exindex}{\p{exception}}
Fred Drake2c4e0091999-03-29 14:55:55 +00001583 Add a reference to an exception named \var{exception}. The
Neal Norwitz847207a2003-05-29 02:17:23 +00001584 exception should be class-based.
Fred Drakeacffaee1999-03-16 16:09:13 +00001585 \end{macrodesc}
1586
Fred Drakeadade921999-04-22 13:05:27 +00001587 \begin{macrodesc}{kwindex}{\p{keyword}}
Fred Drake2c4e0091999-03-29 14:55:55 +00001588 Add a reference to a language keyword (not a keyword parameter
1589 in a function or method call).
Fred Drakeacffaee1999-03-16 16:09:13 +00001590 \end{macrodesc}
1591
Fred Drakeadade921999-04-22 13:05:27 +00001592 \begin{macrodesc}{obindex}{\p{object type}}
Fred Drake2c4e0091999-03-29 14:55:55 +00001593 Add an index entry for a built-in object type.
Fred Drakeacffaee1999-03-16 16:09:13 +00001594 \end{macrodesc}
1595
Fred Drakeadade921999-04-22 13:05:27 +00001596 \begin{macrodesc}{opindex}{\p{operator}}
Fred Drake2c4e0091999-03-29 14:55:55 +00001597 Add a reference to an operator, such as \samp{+}.
Fred Drakeacffaee1999-03-16 16:09:13 +00001598 \end{macrodesc}
1599
Fred Drakeadade921999-04-22 13:05:27 +00001600 \begin{macrodesc}{refmodindex}{\op{key}\p{module}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001601 Add an index entry for module \var{module}; if \var{module}
1602 contains an underscore, the optional parameter \var{key} should
1603 be provided as the same string with underscores removed. An
1604 index entry ``\var{module} (module)'' will be generated. This
1605 is intended for use with non-standard modules implemented in
1606 Python.
1607 \end{macrodesc}
1608
Fred Drakeadade921999-04-22 13:05:27 +00001609 \begin{macrodesc}{refexmodindex}{\op{key}\p{module}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001610 As for \macro{refmodindex}, but the index entry will be
1611 ``\var{module} (extension module).'' This is intended for use
1612 with non-standard modules not implemented in Python.
1613 \end{macrodesc}
1614
Fred Drakeadade921999-04-22 13:05:27 +00001615 \begin{macrodesc}{refbimodindex}{\op{key}\p{module}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001616 As for \macro{refmodindex}, but the index entry will be
1617 ``\var{module} (built-in module).'' This is intended for use
1618 with standard modules not implemented in Python.
1619 \end{macrodesc}
1620
Fred Drakeadade921999-04-22 13:05:27 +00001621 \begin{macrodesc}{refstmodindex}{\op{key}\p{module}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001622 As for \macro{refmodindex}, but the index entry will be
1623 ``\var{module} (standard module).'' This is intended for use
1624 with standard modules implemented in Python.
1625 \end{macrodesc}
1626
Fred Drakeadade921999-04-22 13:05:27 +00001627 \begin{macrodesc}{stindex}{\p{statement}}
Fred Drake2c4e0091999-03-29 14:55:55 +00001628 Add an index entry for a statement type, such as \keyword{print}
Fred Drakeadade921999-04-22 13:05:27 +00001629 or \keyword{try}/\keyword{finally}.
1630
1631 XXX Need better examples of difference from \macro{kwindex}.
Fred Drakeacffaee1999-03-16 16:09:13 +00001632 \end{macrodesc}
1633
1634
1635 Additional macros are provided which are useful for conveniently
1636 creating general index entries which should appear at many places
1637 in the index by rotating a list of words. These are simple macros
1638 that simply use \macro{index} to build some number of index
1639 entries. Index entries build using these macros contain both
1640 primary and secondary text.
1641
Fred Drakeadade921999-04-22 13:05:27 +00001642 \begin{macrodesc}{indexii}{\p{word1}\p{word2}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001643 Build two index entries. This is exactly equivalent to using
Fred Drakee7f343d2003-07-11 03:36:15 +00001644 \code{\e index\{\var{word1}!\var{word2}\}} and
Fred Drakeacffaee1999-03-16 16:09:13 +00001645 \code{\e index\{\var{word2}!\var{word1}\}}.
1646 \end{macrodesc}
1647
Fred Drakeadade921999-04-22 13:05:27 +00001648 \begin{macrodesc}{indexiii}{\p{word1}\p{word2}\p{word3}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001649 Build three index entries. This is exactly equivalent to using
1650 \code{\e index\{\var{word1}!\var{word2} \var{word3}\}},
1651 \code{\e index\{\var{word2}!\var{word3}, \var{word1}\}}, and
1652 \code{\e index\{\var{word3}!\var{word1} \var{word2}\}}.
1653 \end{macrodesc}
1654
Fred Drakeadade921999-04-22 13:05:27 +00001655 \begin{macrodesc}{indexiv}{\p{word1}\p{word2}\p{word3}\p{word4}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001656 Build four index entries. This is exactly equivalent to using
1657 \code{\e index\{\var{word1}!\var{word2} \var{word3} \var{word4}\}},
1658 \code{\e index\{\var{word2}!\var{word3} \var{word4}, \var{word1}\}},
1659 \code{\e index\{\var{word3}!\var{word4}, \var{word1} \var{word2}\}},
1660 and
1661 \code{\e index\{\var{word4}!\var{word1} \var{word2} \var{word3}\}}.
1662 \end{macrodesc}
1663
Fred Drake432cef02001-07-06 22:34:33 +00001664 \subsection{Grammar Production Displays \label{grammar-displays}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001665
Fred Drake432cef02001-07-06 22:34:33 +00001666 Special markup is available for displaying the productions of a
1667 formal grammar. The markup is simple and does not attempt to
1668 model all aspects of BNF (or any derived forms), but provides
1669 enough to allow context-free grammars to be displayed in a way
1670 that causes uses of a symbol to be rendered as hyperlinks to the
1671 definition of the symbol. There is one environment and a pair of
1672 macros:
Fred Drakeacffaee1999-03-16 16:09:13 +00001673
Fred Drake432cef02001-07-06 22:34:33 +00001674 \begin{envdesc}{productionlist}{\op{language}}
1675 This environment is used to enclose a group of productions. The
1676 two macros are only defined within this environment. If a
Raymond Hettinger68804312005-01-01 00:28:46 +00001677 document describes more than one language, the optional parameter
Fred Drake432cef02001-07-06 22:34:33 +00001678 \var{language} should be used to distinguish productions between
1679 languages. The value of the parameter should be a short name
1680 that can be used as part of a filename; colons or other
1681 characters that can't be used in filename across platforms
1682 should be included.
1683 \end{envdesc}
Fred Drakeacffaee1999-03-16 16:09:13 +00001684
Fred Drake432cef02001-07-06 22:34:33 +00001685 \begin{macrodesc}{production}{\p{name}\p{definition}}
1686 A production rule in the grammar. The rule defines the symbol
1687 \var{name} to be \var{definition}. \var{name} should not
1688 contain any markup, and the use of hyphens in a document which
1689 supports more than one grammar is undefined. \var{definition}
1690 may contain \macro{token} macros and any additional content
1691 needed to describe the grammatical model of \var{symbol}. Only
1692 one \macro{production} may be used to define a symbol ---
1693 multiple definitions are not allowed.
1694 \end{macrodesc}
Fred Drakeacffaee1999-03-16 16:09:13 +00001695
Fred Drake432cef02001-07-06 22:34:33 +00001696 \begin{macrodesc}{token}{\p{name}}
1697 The name of a symbol defined by a \macro{production} macro, used
1698 in the \var{definition} of a symbol. Where possible, this will
1699 be rendered as a hyperlink to the definition of the symbol
1700 \var{name}.
1701 \end{macrodesc}
Fred Drake42934682000-04-03 15:00:28 +00001702
Fred Drake432cef02001-07-06 22:34:33 +00001703 Note that the entire grammar does not need to be defined in a
1704 single \env{productionlist} environment; any number of
1705 groupings may be used to describe the grammar. Every use of the
1706 \macro{token} must correspond to a \macro{production}.
1707
1708 The following is an example taken from the
1709 \citetitle[../ref/identifiers.html]{Python Reference Manual}:
1710
1711\begin{verbatim}
1712\begin{productionlist}
1713 \production{identifier}
1714 {(\token{letter}|"_") (\token{letter} | \token{digit} | "_")*}
1715 \production{letter}
1716 {\token{lowercase} | \token{uppercase}}
1717 \production{lowercase}
1718 {"a"..."z"}
1719 \production{uppercase}
1720 {"A"..."Z"}
1721 \production{digit}
1722 {"0"..."9"}
1723\end{productionlist}
1724\end{verbatim}
1725
1726
Fred Drakee1341582002-09-25 18:44:21 +00001727\subsection{Graphical Interface Components \label{gui-markup}}
Fred Drake432cef02001-07-06 22:34:33 +00001728
1729 The components of graphical interfaces will be assigned markup, but
Fred Drakee1341582002-09-25 18:44:21 +00001730 most of the specifics have not been determined.
1731
Fred Drakef0f6d122004-01-23 08:52:28 +00001732 \begin{macrodesc}{guilabel}{\p{label}}
1733 Labels presented as part of an interactive user interface should
1734 be marked using \macro{guilabel}. This includes labels from
1735 text-based interfaces such as those created using \code{curses} or
1736 other text-based libraries. Any label used in the interface
1737 should be marked with this macro, including button labels, window
1738 titles, field names, menu and menu selection names, and even
1739 values in selection lists.
1740 \end{macrodesc}
1741
Fred Drakee1341582002-09-25 18:44:21 +00001742 \begin{macrodesc}{menuselection}{\p{menupath}}
1743 Menu selections should be marked using a combination of
1744 \macro{menuselection} and \macro{sub}. This macro is used to mark
1745 a complete sequence of menu selections, including selecting
1746 submenus and choosing a specific operation, or any subsequence of
1747 such a sequence. The names of individual selections should be
Raymond Hettinger68804312005-01-01 00:28:46 +00001748 separated by occurrences of \macro{sub}.
Fred Drakee1341582002-09-25 18:44:21 +00001749
1750 For example, to mark the selection ``\menuselection{Start \sub
1751 Programs}'', use this markup:
1752
1753\begin{verbatim}
1754\menuselection{Start \sub Programs}
1755\end{verbatim}
1756
1757 When including a selection that includes some trailing indicator,
1758 such as the ellipsis some operating systems use to indicate that
1759 the command opens a dialog, the indicator should be omitted from
1760 the selection name.
Fred Drakef0f6d122004-01-23 08:52:28 +00001761
1762 Individual selection names within the \macro{menuselection} should
1763 not be marked using \macro{guilabel} since that's implied by using
1764 \macro{menuselection}.
Fred Drakee1341582002-09-25 18:44:21 +00001765 \end{macrodesc}
1766
1767 \begin{macrodesc}{sub}{}
1768 Separator for menu selections that include multiple levels. This
1769 macro is only defined within the context of the
1770 \macro{menuselection} macro.
1771 \end{macrodesc}
Fred Drakeacffaee1999-03-16 16:09:13 +00001772
1773
Fred Drakef1b3de82001-07-24 14:38:34 +00001774\section{Processing Tools \label{tools}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001775
Fred Drakef1b3de82001-07-24 14:38:34 +00001776 \subsection{External Tools \label{tools-external}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001777
1778 Many tools are needed to be able to process the Python
1779 documentation if all supported formats are required. This
Fred Drakeadade921999-04-22 13:05:27 +00001780 section lists the tools used and when each is required. Consult
1781 the \file{Doc/README} file to see if there are specific version
1782 requirements for any of these.
Fred Drakeacffaee1999-03-16 16:09:13 +00001783
1784 \begin{description}
1785 \item[\program{dvips}]
1786 This program is a typical part of \TeX{} installations. It is
1787 used to generate PostScript from the ``device independent''
Fred Drake2c4e0091999-03-29 14:55:55 +00001788 \file{.dvi} files. It is needed for the conversion to
Fred Drakeacffaee1999-03-16 16:09:13 +00001789 PostScript.
1790
1791 \item[\program{emacs}]
1792 Emacs is the kitchen sink of programmers' editors, and a damn
1793 fine kitchen sink it is. It also comes with some of the
1794 processing needed to support the proper menu structures for
1795 Texinfo documents when an info conversion is desired. This is
Fred Drake2c4e0091999-03-29 14:55:55 +00001796 needed for the info conversion. Using \program{xemacs}
Fred Drakeacffaee1999-03-16 16:09:13 +00001797 instead of FSF \program{emacs} may lead to instability in the
1798 conversion, but that's because nobody seems to maintain the
1799 Emacs Texinfo code in a portable manner.
1800
1801 \item[\program{latex}]
Fred Drakeb5f17f22001-08-28 18:09:11 +00001802 \LaTeX{} is a large and extensible macro package by Leslie
1803 Lamport, based on \TeX, a world-class typesetter by Donald
1804 Knuth. It is used for the conversion to PostScript, and is
1805 needed for the HTML conversion as well (\LaTeX2HTML requires
1806 one of the intermediate files it creates).
Fred Drakeacffaee1999-03-16 16:09:13 +00001807
1808 \item[\program{latex2html}]
1809 Probably the longest Perl script anyone ever attempted to
1810 maintain. This converts \LaTeX{} documents to HTML documents,
1811 and does a pretty reasonable job. It is required for the
1812 conversions to HTML and GNU info.
1813
1814 \item[\program{lynx}]
1815 This is a text-mode Web browser which includes an
1816 HTML-to-plain text conversion. This is used to convert
1817 \code{howto} documents to text.
1818
1819 \item[\program{make}]
1820 Just about any version should work for the standard documents,
1821 but GNU \program{make} is required for the experimental
1822 processes in \file{Doc/tools/sgmlconv/}, at least while
Fred Drakeb5f17f22001-08-28 18:09:11 +00001823 they're experimental. This is not required for running the
Fred Drakef9dc0432001-08-29 02:34:10 +00001824 \program{mkhowto} script.
Fred Drakeacffaee1999-03-16 16:09:13 +00001825
1826 \item[\program{makeindex}]
1827 This is a standard program for converting \LaTeX{} index data
1828 to a formatted index; it should be included with all \LaTeX{}
1829 installations. It is needed for the PDF and PostScript
1830 conversions.
1831
1832 \item[\program{makeinfo}]
1833 GNU \program{makeinfo} is used to convert Texinfo documents to
1834 GNU info files. Since Texinfo is used as an intermediate
1835 format in the info conversion, this program is needed in that
1836 conversion.
1837
1838 \item[\program{pdflatex}]
1839 pdf\TeX{} is a relatively new variant of \TeX, and is used to
1840 generate the PDF version of the manuals. It is typically
1841 installed as part of most of the large \TeX{} distributions.
Fred Drake7a737df1999-04-23 14:41:44 +00001842 \program{pdflatex} is pdf\TeX{} using the \LaTeX{} format.
Fred Drakeacffaee1999-03-16 16:09:13 +00001843
1844 \item[\program{perl}]
1845 Perl is required for \LaTeX2HTML{} and one of the scripts used
1846 to post-process \LaTeX2HTML output, as well as the
Fred Drake2c4e0091999-03-29 14:55:55 +00001847 HTML-to-Texinfo conversion. This is required for
Fred Drakeacffaee1999-03-16 16:09:13 +00001848 the HTML and GNU info conversions.
1849
1850 \item[\program{python}]
1851 Python is used for many of the scripts in the
1852 \file{Doc/tools/} directory; it is required for all
1853 conversions. This shouldn't be a problem if you're interested
1854 in writing documentation for Python!
1855 \end{description}
1856
1857
Fred Drakef1b3de82001-07-24 14:38:34 +00001858 \subsection{Internal Tools \label{tools-internal}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001859
1860 This section describes the various scripts that are used to
1861 implement various stages of document processing or to orchestrate
Fred Drake2c4e0091999-03-29 14:55:55 +00001862 entire build sequences. Most of these tools are only useful
Fred Drakeacffaee1999-03-16 16:09:13 +00001863 in the context of building the standard documentation, but some
1864 are more general.
1865
1866 \begin{description}
1867 \item[\program{mkhowto}]
Fred Drake87f768e1999-05-17 15:22:45 +00001868 This is the primary script used to format third-party
Fred Drakee7f343d2003-07-11 03:36:15 +00001869 documents. It contains all the logic needed to ``get it
1870 right.'' The proper way to use this script is to make a
1871 symbolic link to it or run it in place; the actual script file
1872 must be stored as part of the documentation source tree,
Fred Drakeefb3a162003-10-01 04:15:09 +00001873 though it may be used to format documents outside the tree.
1874 Use \program{mkhowto} \longprogramopt{help} for a list of
Fred Draked2a727f1999-05-27 21:45:54 +00001875 command line options.
Fred Drake87f768e1999-05-17 15:22:45 +00001876
Fred Draked1fb7791999-05-17 16:33:54 +00001877 \program{mkhowto} can be used for both \code{howto} and
Fred Draked80032b2002-09-25 21:41:22 +00001878 \code{manual} class documents. It is usually a good idea to
1879 always use the latest version of this tool rather than a
Fred Drakeefb3a162003-10-01 04:15:09 +00001880 version from an older source release of Python. It can be
1881 used to generate DVI, HTML, PDF, PostScript, and plain text
1882 documents. The GNU info and iSilo formats will be supported
1883 by this script in some future version.
1884
1885 Use the \longprogramopt{help} option on this script's command
1886 line to get a summary of options for this script.
Fred Draked1fb7791999-05-17 16:33:54 +00001887
Fred Drakee7f343d2003-07-11 03:36:15 +00001888 XXX Need more here.
Fred Drakeacffaee1999-03-16 16:09:13 +00001889 \end{description}
1890
1891
Fred Drakeeb2b8332002-05-01 22:05:30 +00001892 \subsection{Working on Cygwin \label{cygwin}}
1893
Fred Drakeeb2b8332002-05-01 22:05:30 +00001894 Installing the required tools under Cygwin under Cygwin can be a
Martin v. Löwisc9f85252005-03-03 23:07:21 +00001895 little tedious. Most of the required packages can be installed
1896 using Cygwin's graphical installer, while netpbm and \LaTeX2HTML
1897 must be installed from source.
1898
1899 Start with a reasonably modern version of Cygwin. If you haven't
1900 upgraded for a few years, now would be a good time.
Fred Drakeeb2b8332002-05-01 22:05:30 +00001901
1902 Using the Cygwin installer, make sure your Cygwin installation
1903 includes Perl, Python, and the \TeX{} packages. Perl and Python
Martin v. Löwisc9f85252005-03-03 23:07:21 +00001904 are located under the \menuselection{Interpreters} heading. The
1905 \TeX{} packages are located under the \menuselection{Text}
1906 heading, and are named \code{tetex-*}. To ensure that all
1907 required packages are available, install every \code{tetex}
1908 package, except \code{tetex-x11}. (There may be a more minimal
1909 set, but I've not spent time trying to minimize the installation.)
Fred Drakeeb2b8332002-05-01 22:05:30 +00001910
1911 The netpbm package is used by \LaTeX2HTML, and \emph{must} be
1912 installed before \LaTeX2HTML can be successfully installed, even
Martin v. Löwisc9f85252005-03-03 23:07:21 +00001913 though its features will not be used for most Python
1914 documentation. References to download locations are located in
1915 the \ulink{netpbm README}{http://netpbm.sourceforge.net/README}.
1916 Install from the latest stable source distribution according to
1917 the instructions. (Note that binary packages of netpbm are
1918 sometimes available, but these may not work correctly with
1919 \LaTeX2HTML.)
Fred Drakeeb2b8332002-05-01 22:05:30 +00001920
1921 \LaTeX2HTML can be installed from the source archive, but only
Martin v. Löwisc9f85252005-03-03 23:07:21 +00001922 after munging one of the files in the distribution. Download the
1923 source archive from the \LaTeX2HTML website
1924 \url{http://www.latex2html.org/} (or one of the many alternate
1925 sites) and unpack it to a build directory. In the top level of
1926 this build directory there will be a file named \file{L2hos.pm}.
1927 Open \file{L2hos.pm} in an editor, and near the bottom of the file
1928 replace the text \code{\$\textasciicircum{}O} with the text
1929 \code{'unix'}. Proceed using this command to build and install
1930 the software:
Fred Drakeeb2b8332002-05-01 22:05:30 +00001931
1932\begin{verbatim}
Fred Drakec7c9a3a2004-05-10 18:39:32 +00001933% ./configure && make install
Fred Drakeeb2b8332002-05-01 22:05:30 +00001934\end{verbatim}
1935
Fred Drakeefb3a162003-10-01 04:15:09 +00001936 You should now be able to build at least the DVI, HTML, PDF, and
Fred Drake77c18952002-05-02 21:10:48 +00001937 PostScript versions of the formatted documentation.
1938
Fred Drakeeb2b8332002-05-01 22:05:30 +00001939
Fred Drake40b9df22003-10-11 05:25:24 +00001940\section{Including Graphics \label{graphics}}
1941
1942 The standard documentation included with Python makes no use of
1943 diagrams or images; this is intentional. The outside tools used to
1944 format the documentation have not always been suited to working with
1945 graphics. As the tools have evolved and been improved by their
1946 maintainers, support for graphics has improved.
1947
1948 The internal tools, starting with the \program{mkhowto} script, do
1949 not provide any direct support for graphics. However,
1950 \program{mkhowto} will not interfere with graphics support in the
1951 external tools.
1952
1953 Experience using graphics together with these tools and the
1954 \code{howto} and \code{manual} document classes is not extensive,
1955 but has been known to work. The basic approach is this:
1956
1957 \begin{enumerate}
1958 \item Create the image or graphic using your favorite
1959 application.
1960
1961 \item Convert the image to a format supported by the conversion to
1962 your desired output format. If you want to generate HTML or
1963 PostScript, you can convert the image or graphic to
1964 encapsulated PostScript (a \file{.eps} file); \LaTeX2HTML
1965 can convert that to a \file{.gif} file; it may be possible
1966 to provide a \file{.gif} file directly. If you want to
1967 generate PDF, you need to provide an ``encapsulated'' PDF
1968 file. This can be generated from encapsulated PostScript
1969 using the \program{epstopdf} tool provided with the te\TeX{}
1970 distribution on Linux and \UNIX.
1971
1972 \item In your document, add this line to ``import'' the general
1973 graphics support package \code{graphicx}:
1974
1975\begin{verbatim}
1976\usepackage{graphicx}
1977\end{verbatim}
1978
1979 \item Where you want to include your graphic or image, include
1980 markup similar to this:
1981
1982\begin{verbatim}
1983\begin{figure}
1984 \centering
1985 \includegraphics[width=5in]{myimage}
1986 \caption{Description of my image}
1987\end{figure}
1988\end{verbatim}
1989
1990 In particular, note for the \macro{includegraphics} macro
1991 that no file extension is provided. If you're only
1992 interested in one target format, you can include the
1993 extension of the appropriate input file, but to allow
1994 support for multiple formats, omitting the extension makes
1995 life easier.
1996
1997 \item Run \program{mkhowto} normally.
1998 \end{enumerate}
1999
2000 If you're working on systems which support some sort of
2001 \program{make} facility, you can use that to ensure the intermediate
2002 graphic formats are kept up to date. This example shows a
2003 \file{Makefile} used to format a document containing a diagram
2004 created using the \program{dia} application:
2005
2006\begin{verbatim}
2007default: pdf
2008all: html pdf ps
2009
2010html: mydoc/mydoc.html
2011pdf: mydoc.pdf
2012ps: mydoc.ps
2013
2014mydoc/mydoc.html: mydoc.tex mygraphic.eps
2015 mkhowto --html $<
2016
2017mydoc.pdf: mydoc.tex mygraphic.pdf
2018 mkhowto --pdf $<
2019
2020mydoc.ps: mydoc.tex mygraphic.eps
2021 mkhowto --postscript $<
2022
2023.SUFFIXES: .dia .eps .pdf
2024
2025.dia.eps:
2026 dia --nosplash --export $@ $<
2027
2028.eps.pdf:
2029 epstopdf $<
2030\end{verbatim} % $ <-- bow to font-lock
2031
2032
Fred Drakeacffaee1999-03-16 16:09:13 +00002033\section{Future Directions \label{futures}}
2034
2035 The history of the Python documentation is full of changes, most of
2036 which have been fairly small and evolutionary. There has been a
2037 great deal of discussion about making large changes in the markup
2038 languages and tools used to process the documentation. This section
2039 deals with the nature of the changes and what appears to be the most
2040 likely path of future development.
2041
2042 \subsection{Structured Documentation \label{structured}}
2043
2044 Most of the small changes to the \LaTeX{} markup have been made
2045 with an eye to divorcing the markup from the presentation, making
2046 both a bit more maintainable. Over the course of 1998, a large
2047 number of changes were made with exactly this in mind; previously,
2048 changes had been made but in a less systematic manner and with
2049 more concern for not needing to update the existing content. The
2050 result has been a highly structured and semantically loaded markup
2051 language implemented in \LaTeX. With almost no basic \TeX{} or
2052 \LaTeX{} markup in use, however, the markup syntax is about the
2053 only evidence of \LaTeX{} in the actual document sources.
2054
2055 One side effect of this is that while we've been able to use
2056 standard ``engines'' for manipulating the documents, such as
2057 \LaTeX{} and \LaTeX2HTML, most of the actual transformations have
Fred Drake7a737df1999-04-23 14:41:44 +00002058 been created specifically for Python. The \LaTeX{} document
2059 classes and \LaTeX2HTML support are both complete implementations
2060 of the specific markup designed for these documents.
Fred Drakeacffaee1999-03-16 16:09:13 +00002061
2062 Combining highly customized markup with the somewhat esoteric
2063 systems used to process the documents leads us to ask some
2064 questions: Can we do this more easily? and, Can we do this
2065 better? After a great deal of discussion with the community, we
2066 have determined that actively pursuing modern structured
Fred Drake2c4e0091999-03-29 14:55:55 +00002067 documentation systems is worth some investment of time.
Fred Drakeacffaee1999-03-16 16:09:13 +00002068
2069 There appear to be two real contenders in this arena: the Standard
2070 General Markup Language (SGML), and the Extensible Markup Language
2071 (XML). Both of these standards have advantages and disadvantages,
2072 and many advantages are shared.
2073
2074 SGML offers advantages which may appeal most to authors,
2075 especially those using ordinary text editors. There are also
2076 additional abilities to define content models. A number of
Fred Drake67f193f2001-07-09 16:04:03 +00002077 high-quality tools with demonstrated maturity are available, but
Fred Drakeacffaee1999-03-16 16:09:13 +00002078 most are not free; for those which are, portability issues remain
2079 a problem.
2080
2081 The advantages of XML include the availability of a large number
2082 of evolving tools. Unfortunately, many of the associated
2083 standards are still evolving, and the tools will have to follow
2084 along. This means that developing a robust tool set that uses
2085 more than the basic XML 1.0 recommendation is not possible in the
2086 short term. The promised availability of a wide variety of
2087 high-quality tools which support some of the most important
2088 related standards is not immediate. Many tools are likely to be
Fred Drake67f193f2001-07-09 16:04:03 +00002089 free, and the portability issues of those which are, are not
2090 expected to be significant.
Fred Drakeacffaee1999-03-16 16:09:13 +00002091
Fred Drake67f193f2001-07-09 16:04:03 +00002092 It turns out that converting to an XML or SGML system holds
2093 promise for translators as well; how much can be done to ease the
2094 burden on translators remains to be seen, and may have some impact
2095 on the schema and specific technologies used.
2096
2097 XXX Eventual migration to XML.
2098
2099 The documentation will be moved to XML in the future, and tools
2100 are being written which will convert the documentation from the
2101 current format to something close to a finished version, to the
2102 extent that the desired information is already present in the
2103 documentation. Some XSLT stylesheets have been started for
2104 presenting a preliminary XML version as HTML, but the results are
Fred Drakee7f343d2003-07-11 03:36:15 +00002105 fairly rough.
Fred Drake67f193f2001-07-09 16:04:03 +00002106
2107 The timeframe for the conversion is not clear since there doesn't
Raymond Hettinger68804312005-01-01 00:28:46 +00002108 seem to be much time available to work on this, but the apparent
Fred Drake67f193f2001-07-09 16:04:03 +00002109 benefits are growing more substantial at a moderately rapid pace.
2110
Fred Drakeacffaee1999-03-16 16:09:13 +00002111
2112 \subsection{Discussion Forums \label{discussion}}
2113
2114 Discussion of the future of the Python documentation and related
Fred Drake7a737df1999-04-23 14:41:44 +00002115 topics takes place in the Documentation Special Interest Group, or
2116 ``Doc-SIG.'' Information on the group, including mailing list
2117 archives and subscription information, is available at
Fred Drakeacffaee1999-03-16 16:09:13 +00002118 \url{http://www.python.org/sigs/doc-sig/}. The SIG is open to all
2119 interested parties.
2120
2121 Comments and bug reports on the standard documents should be sent
Fred Drake9d843082003-07-30 02:55:28 +00002122 to \email{docs@python.org}. This may include comments
Fred Drakeadade921999-04-22 13:05:27 +00002123 about formatting, content, grammatical and spelling errors, or
Fred Draked1fb7791999-05-17 16:33:54 +00002124 this document. You can also send comments on this document
2125 directly to the author at \email{fdrake@acm.org}.
Fred Drakeacffaee1999-03-16 16:09:13 +00002126
Skip Montanaro176bda4cd2002-04-19 04:50:44 +00002127\input{doc.ind}
2128
Fred Drakeacffaee1999-03-16 16:09:13 +00002129\end{document}