blob: 1a7df0a0eec5b9d743cbeb8055a117f6b1762a4c [file] [log] [blame]
Fred Drakeacffaee1999-03-16 16:09:13 +00001\documentclass{howto}
2\usepackage{ltxmarkup}
3
4\title{Documenting Python}
5
6\input{boilerplate}
7
Fred Drakec7c9a641999-04-28 18:24:02 +00008% Now override the stuff that includes author information;
9% Guido did *not* write this one!
Fred Drakeacffaee1999-03-16 16:09:13 +000010
11\author{Fred L. Drake, Jr.}
12\authoraddress{
Fred Drake8fdb6382000-10-28 04:08:38 +000013 PythonLabs \\
Fred Drake9120df32001-07-14 02:34:12 +000014 Email: \email{fdrake@acm.org}
Fred Drakeacffaee1999-03-16 16:09:13 +000015}
Fred Drakeacffaee1999-03-16 16:09:13 +000016
17
18\begin{document}
19
20\maketitle
21
22\begin{abstract}
23\noindent
Fred Drake02997492000-09-21 05:26:43 +000024The Python language has a substantial body of
Fred Drakeacffaee1999-03-16 16:09:13 +000025documentation, much of it contributed by various authors. The markup
26used for the Python documentation is based on \LaTeX{} and requires a
27significant set of macros written specifically for documenting Python.
Fred Drake5eb992b1999-06-11 14:25:45 +000028This document describes the macros introduced to support Python
29documentation and how they should be used to support a wide range of
30output formats.
Fred Drakeacffaee1999-03-16 16:09:13 +000031
32This document describes the document classes and special markup used
33in the Python documentation. Authors may use this guide, in
34conjunction with the template files provided with the
35distribution, to create or maintain whole documents or sections.
36\end{abstract}
37
38\tableofcontents
39
40
Fred Drakef1b3de82001-07-24 14:38:34 +000041\section{Introduction \label{intro}}
Fred Drakeacffaee1999-03-16 16:09:13 +000042
43 Python's documentation has long been considered to be good for a
44 free programming language. There are a number of reasons for this,
45 the most important being the early commitment of Python's creator,
46 Guido van Rossum, to providing documentation on the language and its
47 libraries, and the continuing involvement of the user community in
48 providing assistance for creating and maintaining documentation.
49
50 The involvement of the community takes many forms, from authoring to
Fred Drake7a737df1999-04-23 14:41:44 +000051 bug reports to just plain complaining when the documentation could
52 be more complete or easier to use. All of these forms of input from
53 the community have proved useful during the time I've been involved
54 in maintaining the documentation.
Fred Drakeacffaee1999-03-16 16:09:13 +000055
Fred Drake2c4e0091999-03-29 14:55:55 +000056 This document is aimed at authors and potential authors of
Fred Drake7a737df1999-04-23 14:41:44 +000057 documentation for Python. More specifically, it is for people
58 contributing to the standard documentation and developing additional
59 documents using the same tools as the standard documents. This
60 guide will be less useful for authors using the Python documentation
61 tools for topics other than Python, and less useful still for
62 authors not using the tools at all.
Fred Drakeacffaee1999-03-16 16:09:13 +000063
Fred Drake2c4e0091999-03-29 14:55:55 +000064 The material in this guide is intended to assist authors using the
65 Python documentation tools. It includes information on the source
66 distribution of the standard documentation, a discussion of the
Fred Drake7a737df1999-04-23 14:41:44 +000067 document types, reference material on the markup defined in the
68 document classes, a list of the external tools needed for processing
Fred Drake2c4e0091999-03-29 14:55:55 +000069 documents, and reference material on the tools provided with the
70 documentation resources. At the end, there is also a section
Fred Drake7a737df1999-04-23 14:41:44 +000071 discussing future directions for the Python documentation and where
72 to turn for more information.
Fred Drakeacffaee1999-03-16 16:09:13 +000073
Fred Drakef1b3de82001-07-24 14:38:34 +000074\section{Directory Structure \label{directories}}
Fred Drakeacffaee1999-03-16 16:09:13 +000075
76 The source distribution for the standard Python documentation
77 contains a large number of directories. While third-party documents
78 do not need to be placed into this structure or need to be placed
79 within a similar structure, it can be helpful to know where to look
80 for examples and tools when developing new documents using the
81 Python documentation tools. This section describes this directory
82 structure.
83
84 The documentation sources are usually placed within the Python
Fred Drake7a737df1999-04-23 14:41:44 +000085 source distribution as the top-level directory \file{Doc/}, but
86 are not dependent on the Python source distribution in any way.
Fred Drakeacffaee1999-03-16 16:09:13 +000087
88 The \file{Doc/} directory contains a few files and several
89 subdirectories. The files are mostly self-explanatory, including a
90 \file{README} and a \file{Makefile}. The directories fall into
91 three categories:
92
93 \begin{definitions}
94 \term{Document Sources}
95 The \LaTeX{} sources for each document are placed in a
Fred Drake02997492000-09-21 05:26:43 +000096 separate directory. These directories are given short
97 names which vaguely indicate the document in each:
Fred Drake2f4bebd1999-04-28 16:43:11 +000098
99 \begin{tableii}{p{.75in}|p{3in}}{filenq}{Directory}{Document Title}
Fred Drake31edf4d2000-09-07 20:06:07 +0000100 \lineii{api/}
101 {\citetitle[../api/api.html]{The Python/C API}}
102 \lineii{dist/}
103 {\citetitle[../dist/dist.html]{Distributing Python Modules}}
104 \lineii{doc/}
105 {\citetitle[../doc/doc.html]{Documenting Python}}
106 \lineii{ext/}
107 {\citetitle[../ext/ext.html]{Extending and Embedding the Python Interpreter}}
108 \lineii{inst/}
109 {\citetitle[../inst/inst.html]{Installing Python Modules}}
110 \lineii{lib/}
111 {\citetitle[../lib/lib.html]{Python Library Reference}}
112 \lineii{mac/}
113 {\citetitle[../mac/mac.html]{Macintosh Module Reference}}
114 \lineii{ref/}
115 {\citetitle[../ref/ref.html]{Python Reference Manual}}
116 \lineii{tut/}
117 {\citetitle[../tut/tut.html]{Python Tutorial}}
Fred Drake2f4bebd1999-04-28 16:43:11 +0000118 \end{tableii}
Fred Drakeacffaee1999-03-16 16:09:13 +0000119
120 \term{Format-Specific Output}
Fred Drake2c4e0091999-03-29 14:55:55 +0000121 Most output formats have a directory which contains a
Fred Drakeacffaee1999-03-16 16:09:13 +0000122 \file{Makefile} which controls the generation of that format
123 and provides storage for the formatted documents. The only
Fred Drake2c4e0091999-03-29 14:55:55 +0000124 variations within this category are the Portable Document
125 Format (PDF) and PostScript versions are placed in the
Fred Drake7a737df1999-04-23 14:41:44 +0000126 directories \file{paper-a4/} and \file{paper-letter/} (this
127 causes all the temporary files created by \LaTeX{} to be kept
128 in the same place for each paper size, where they can be more
129 easily ignored).
Fred Drakeacffaee1999-03-16 16:09:13 +0000130
Fred Drake2f4bebd1999-04-28 16:43:11 +0000131 \begin{tableii}{p{.75in}|p{3in}}{filenq}{Directory}{Output Formats}
132 \lineii{html/}{HTML output}
133 \lineii{info/}{GNU info output}
134 \lineii{paper-a4/}{PDF and PostScript, A4 paper}
135 \lineii{paper-letter/}{PDF and PostScript, US-Letter paper}
136 \end{tableii}
137
Fred Drakeacffaee1999-03-16 16:09:13 +0000138 \term{Supplemental Files}
139 Some additional directories are used to store supplemental
140 files used for the various processes. Directories are
141 included for the shared \LaTeX{} document classes, the
142 \LaTeX2HTML support, template files for various document
143 components, and the scripts used to perform various steps in
144 the formatting processes.
Fred Drake2f4bebd1999-04-28 16:43:11 +0000145
146 \begin{tableii}{p{.75in}|p{3in}}{filenq}{Directory}{Contents}
147 \lineii{perl/}{Support for \LaTeX2HTML processing}
148 \lineii{templates/}{Example files for source documents}
149 \lineii{texinputs/}{Style implementation for \LaTeX}
150 \lineii{tools/}{Custom processing scripts}
151 \end{tableii}
152
Fred Drakeacffaee1999-03-16 16:09:13 +0000153 \end{definitions}
154
Fred Drake2c4e0091999-03-29 14:55:55 +0000155
Fred Drakef1b3de82001-07-24 14:38:34 +0000156\section{Style Guide \label{style-guide}}
Fred Drake432cef02001-07-06 22:34:33 +0000157
158 The Python documentation should follow the \citetitle
159 [http://developer.apple.com/techpubs/macos8/pdf/apple_styleguide00.pdf]
160 {Apple Publications Style Guide} wherever possible. This particular
161 style guide was selected mostly because it seems reasonable and is
162 easy to get online. (Printed copies are available; see the Apple's
163 \citetitle[http://developer.apple.com/techpubs/faq.html]{Developer
164 Documentation FAQ} for more information.)
165
166 Topics which are not covered in the Apple's style guide will be
167 discussed in this document if necessary.
168
169 Many special names are used in the Python documentation, including
170 the names of operating systems, programming languages, standards
171 bodies, and the like. Many of these were assigned \LaTeX{} macros
172 at some point in the distant past, and these macros lived on long
Fred Drake9120df32001-07-14 02:34:12 +0000173 past their usefulness. In the current markup, most of these entities
174 are not assigned any special markup, but the preferred spellings are
Fred Drake432cef02001-07-06 22:34:33 +0000175 given here to aid authors in maintaining the consistency of
176 presentation in the Python documentation.
177
Fred Drake9120df32001-07-14 02:34:12 +0000178 Other terms and words deserve special mention as well; these conventions
179 should be used to ensure consistency throughout the documentation:
180
Fred Drake432cef02001-07-06 22:34:33 +0000181 \begin{description}
Fred Drake9120df32001-07-14 02:34:12 +0000182 \item[CPU]
183 For ``central processing unit.'' Many style guides say this
184 should be spelled out on the first use (and if you must use it,
185 do so!). For the Python documentation, this abbreviation should
186 be avoided since there's no reasonable way to predict which occurance
187 will be the first seen by the reader. It is better to use the
188 word ``processor'' instead.
189
190 \item[\POSIX]
Fred Drake432cef02001-07-06 22:34:33 +0000191 The name assigned to a particular group of standards. This is
Fred Drake9120df32001-07-14 02:34:12 +0000192 always uppercase. Use the macro \macro{POSIX} to represent this
193 name.
Fred Drake432cef02001-07-06 22:34:33 +0000194
195 \item[Python]
196 The name of our favorite programming language is always
197 capitalized.
198
199 \item[Unicode]
200 The name of a character set and matching encoding. This is
Fred Drake9120df32001-07-14 02:34:12 +0000201 always written capitalized.
202
203 \item[\UNIX]
204 The name of the operating system developed at AT\&T Bell Labs
205 in the early 1970s. Use the macro \macro{UNIX} to use this name.
Fred Drake432cef02001-07-06 22:34:33 +0000206 \end{description}
207
208
Fred Drakeadade921999-04-22 13:05:27 +0000209\section{\LaTeX{} Primer \label{latex-primer}}
Fred Drake2c4e0091999-03-29 14:55:55 +0000210
Fred Drakeadade921999-04-22 13:05:27 +0000211 This section is a brief introduction to \LaTeX{} concepts and
212 syntax, to provide authors enough information to author documents
213 productively without having to become ``\TeX{}nicians.''
214
Fred Drake5eb992b1999-06-11 14:25:45 +0000215 Perhaps the most important concept to keep in mind while marking up
Fred Drake02997492000-09-21 05:26:43 +0000216 Python documentation is that while \TeX{} is unstructured, \LaTeX{} was
Fred Drake5eb992b1999-06-11 14:25:45 +0000217 designed as a layer on top of \TeX{} which specifically supports
218 structured markup. The Python-specific markup is intended to extend
219 the structure provided by standard \LaTeX{} document classes to
220 support additional information specific to Python.
221
Fred Drakeadade921999-04-22 13:05:27 +0000222 \LaTeX{} documents contain two parts: the preamble and the body.
223 The preamble is used to specify certain metadata about the document
224 itself, such as the title, the list of authors, the date, and the
225 \emph{class} the document belongs to. Additional information used
226 to control index generation and the use of bibliographic databases
Fred Drake7a737df1999-04-23 14:41:44 +0000227 can also be placed in the preamble. For most authors, the preamble
Fred Drakeadade921999-04-22 13:05:27 +0000228 can be most easily created by copying it from an existing document
229 and modifying a few key pieces of information.
230
231 The \dfn{class} of a document is used to place a document within a
232 broad category of documents and set some fundamental formatting
233 properties. For Python documentation, two classes are used: the
234 \code{manual} class and the \code{howto} class. These classes also
235 define the additional markup used to document Python concepts and
236 structures. Specific information about these classes is provided in
Fred Drake7a737df1999-04-23 14:41:44 +0000237 section \ref{classes}, ``Document Classes,'' below. The first thing
Fred Drakeadade921999-04-22 13:05:27 +0000238 in the preamble is the declaration of the document's class.
239
240 After the class declaration, a number of \emph{macros} are used to
241 provide further information about the document and setup any
Fred Drake7a737df1999-04-23 14:41:44 +0000242 additional markup that is needed. No output is generated from the
243 preamble; it is an error to include free text in the preamble
244 because it would cause output.
Fred Drakeadade921999-04-22 13:05:27 +0000245
246 The document body follows the preamble. This contains all the
Fred Drake63568aa2000-10-19 05:36:10 +0000247 printed components of the document marked up structurally. Generic
Fred Drake4c6f17a2001-04-18 05:12:47 +0000248 \LaTeX{} structures include hierarchical sections, numbered and
249 bulleted lists, and special structures for the document abstract and
250 indexes.
Fred Drakeadade921999-04-22 13:05:27 +0000251
Fred Drakef1b3de82001-07-24 14:38:34 +0000252 \subsection{Syntax \label{latex-syntax}}
Fred Drake63568aa2000-10-19 05:36:10 +0000253
Fred Drake4c6f17a2001-04-18 05:12:47 +0000254 There are some things that an author of Python documentation needs
255 to know about \LaTeX{} syntax.
Fred Drake63568aa2000-10-19 05:36:10 +0000256
257 A \dfn{comment} is started by the ``percent'' character
258 (\character{\%}) and continues through the end of the line and all
259 leading whitespace on the following line. This is a little
260 different from any programming language I know of, so an example
261 is in order:
262
263\begin{verbatim}
264This is text.% comment
265 This is more text. % another comment
266Still more text.
267\end{verbatim}
268
269 The first non-comment character following the first comment is the
270 letter \character{T} on the second line; the leading whitespace on
271 that line is consumed as part of the first comment. This means
272 that there is no space between the first and second sentences, so
273 the period and letter \character{T} will be directly adjacent in
274 the typeset document.
275
276 Note also that though the first non-comment character after the
277 second comment is the letter \character{S}, there is whitespace
278 preceding the comment, so the two sentences are separated as
279 expected.
280
281 A \dfn{group} is an enclosure for a collection of text and
282 commands which encloses the formatting context and constrains the
283 scope of any changes to that context made by commands within the
284 group. Groups can be nested hierarchically. The formatting
285 context includes the font and the definition of additional macros
286 (or overrides of macros defined in outer groups). Syntactically,
287 groups are enclosed in braces:
288
289\begin{verbatim}
290{text in a group}
291\end{verbatim}
292
Fred Drake4c6f17a2001-04-18 05:12:47 +0000293 An alternate syntax for a group using brackets, \code{[...]}, is
Fred Drake63568aa2000-10-19 05:36:10 +0000294 used by macros and environment constructors which take optional
295 parameters; brackets do not normally hold syntactic significance.
296 A degenerate group, containing only one atomic bit of content,
297 does not need to have an explicit group, unless it is required to
298 avoid ambiguity. Since Python tends toward the explicit, groups
299 are also made explicit in the documentation markup.
300
301 Groups are used only sparingly in the Python documentation, except
302 for their use in marking parameters to macros and environments.
303
Fred Drake4c6f17a2001-04-18 05:12:47 +0000304 A \dfn{macro} is usually a simple construct which is identified by
Fred Drake63568aa2000-10-19 05:36:10 +0000305 name and can take some number of parameters. In normal \LaTeX{}
306 usage, one of these can be optional. The markup is introduced
307 using the backslash character (\character{\e}), and the name is
308 given by alphabetic characters (no digits, hyphens, or
309 underscores). Required parameters should be marked as a group,
310 and optional parameters should be marked using the alternate
311 syntax for a group.
312
313 For example, a macro named ``foo'' which takes a single parameter
314 would appear like this:
315
316\begin{verbatim}
317\name{parameter}
318\end{verbatim}
319
320 A macro which takes an optional parameter would be typed like this
321 when the optional paramter is given:
322
323\begin{verbatim}
324\name[optional]
325\end{verbatim}
326
327 If both optional and required parameters are to be required, it
328 looks like this:
329
330\begin{verbatim}
331\name[optional]{required}
332\end{verbatim}
333
334 A macro name may be followed by a space or newline; a space
335 between the macro name and any parameters will be consumed, but
336 this usage is not practiced in the Python documentation. Such a
Fred Drake4c6f17a2001-04-18 05:12:47 +0000337 space is still consumed if there are no parameters to the macro,
Fred Drake63568aa2000-10-19 05:36:10 +0000338 in which case inserting an empty group (\code{\{\}}) or explicit
339 word space (\samp{\e\ }) immediately after the macro name helps to
340 avoid running the expansion of the macro into the following text.
341 Macros which take no parameters but which should not be followed
342 by a word space do not need special treatment if the following
343 character in the document source if not a name character (such as
Fred Drake4c6f17a2001-04-18 05:12:47 +0000344 punctuation).
Fred Drake63568aa2000-10-19 05:36:10 +0000345
346 Each line of this example shows an appropriate way to write text
347 which includes a macro which takes no parameters:
348
349\begin{verbatim}
350This \UNIX{} is followed by a space.
351This \UNIX\ is also followed by a space.
352\UNIX, followed by a comma, needs no additional markup.
353\end{verbatim}
354
Fred Draked097d482000-10-20 20:51:31 +0000355 An \dfn{environment} is a larger construct than a macro, and can
Fred Drake4c6f17a2001-04-18 05:12:47 +0000356 be used for things with more content than would conveniently fit
Fred Draked097d482000-10-20 20:51:31 +0000357 in a macro parameter. They are primarily used when formatting
358 parameters need to be changed before and after a large chunk of
359 content, but the content itself needs to be highly flexible. Code
360 samples are presented using an environment, and descriptions of
Fred Drake4c6f17a2001-04-18 05:12:47 +0000361 functions, methods, and classes are also marked using environments.
Fred Draked097d482000-10-20 20:51:31 +0000362
363 Since the content of an environment is free-form and can consist
364 of several paragraphs, they are actually marked using a pair of
365 macros: \macro{begin} and \macro{end}. These macros both take the
366 name of the environment as a parameter. An example is the
367 environment used to mark the abstract of a document:
368
369\begin{verbatim}
370\begin{abstract}
371 This is the text of the abstract. It concisely explains what
372 information is found in the document.
373
374 It can consist of multiple paragraphs.
375\end{abstract}
376\end{verbatim}
377
378 An environment can also have required and optional parameters of
379 its own. These follow the parameter of the \macro{begin} macro.
380 This example shows an environment which takes a single required
381 parameter:
382
383\begin{verbatim}
Fred Drake2bbc6972001-03-28 16:51:20 +0000384\begin{datadesc}{controlnames}
Fred Draked097d482000-10-20 20:51:31 +0000385 A 33-element string array that contains the \ASCII{} mnemonics for
386 the thirty-two \ASCII{} control characters from 0 (NUL) to 0x1f
387 (US), in order, plus the mnemonic \samp{SP} for the space character.
388\end{datadesc}
389\end{verbatim}
Fred Drake63568aa2000-10-19 05:36:10 +0000390
Fred Drake4c6f17a2001-04-18 05:12:47 +0000391 There are a number of less-used marks in \LaTeX{} which are used
392 to enter non-\ASCII{} characters, especially those used in
393 European names. Given that these are often used adjacent to other
Fred Draked097d482000-10-20 20:51:31 +0000394 characters, the markup required to produce the proper character
Fred Drake4c6f17a2001-04-18 05:12:47 +0000395 may need to be followed by a space or an empty group, or the
Fred Draked097d482000-10-20 20:51:31 +0000396 markup can be enclosed in a group. Some which are found in Python
397 documentation are:
Fred Drake63568aa2000-10-19 05:36:10 +0000398
Fred Draked097d482000-10-20 20:51:31 +0000399\begin{tableii}{c|l}{textrm}{Character}{Markup}
400 \lineii{\c c}{\code{\e c c}}
401 \lineii{\"o}{\code{\e"o}}
402 \lineii{\o}{\code{\e o}}
403\end{tableii}
Fred Drake63568aa2000-10-19 05:36:10 +0000404
405
Fred Drakef1b3de82001-07-24 14:38:34 +0000406 \subsection{Hierarchical Structure \label{latex-syntax}}
Fred Drake63568aa2000-10-19 05:36:10 +0000407
Fred Draked097d482000-10-20 20:51:31 +0000408 \LaTeX{} expects documents to be arranged in a conventional,
409 hierarchical way, with chapters, sections, sub-sections,
410 appendixes, and the like. These are marked using macros rather
411 than environments, probably because the end of a section can be
412 safely inferred when a section of equal or higher level starts.
413
414 There are six ``levels'' of sectioning in the document classes
Fred Drake4c6f17a2001-04-18 05:12:47 +0000415 used for Python documentation, and the deepest two
416 levels\footnote{The deepest levels have the highest numbers in the
417 table.} are not used. The levels are:
Fred Draked097d482000-10-20 20:51:31 +0000418
419 \begin{tableiii}{c|l|c}{textrm}{Level}{Macro Name}{Notes}
420 \lineiii{1}{\macro{chapter}}{(1)}
421 \lineiii{2}{\macro{section}}{}
422 \lineiii{3}{\macro{subsection}}{}
Fred Drakeb7a52c92000-11-27 20:10:18 +0000423 \lineiii{4}{\macro{subsubsection}}{}
Fred Draked097d482000-10-20 20:51:31 +0000424 \lineiii{5}{\macro{paragraph}}{(2)}
425 \lineiii{6}{\macro{subparagraph}}{}
426 \end{tableiii}
427
428 \noindent
429 Notes:
430
431 \begin{description}
432 \item[(1)]
433 Only used for the \code{manual} documents, as described in
434 section \ref{classes}, ``Document Classes.''
435 \item[(2)]
436 Not the same as a paragraph of text; nobody seems to use this.
437 \end{description}
Fred Drake2c4e0091999-03-29 14:55:55 +0000438
439
Fred Drakeadade921999-04-22 13:05:27 +0000440\section{Document Classes \label{classes}}
Fred Drakeacffaee1999-03-16 16:09:13 +0000441
442 Two \LaTeX{} document classes are defined specifically for use with
443 the Python documentation. The \code{manual} class is for large
444 documents which are sectioned into chapters, and the \code{howto}
445 class is for smaller documents.
446
447 The \code{manual} documents are larger and are used for most of the
448 standard documents. This document class is based on the standard
449 \LaTeX{} \code{report} class and is formatted very much like a long
Fred Drake698d5201999-11-10 15:54:57 +0000450 technical report. The \citetitle[../ref/ref.html]{Python Reference
451 Manual} is a good example of a \code{manual} document, and the
452 \citetitle[../lib/lib.html]{Python Library Reference} is a large
453 example.
Fred Drakeacffaee1999-03-16 16:09:13 +0000454
455 The \code{howto} documents are shorter, and don't have the large
456 structure of the \code{manual} documents. This class is based on
457 the standard \LaTeX{} \code{article} class and is formatted somewhat
458 like the Linux Documentation Project's ``HOWTO'' series as done
459 originally using the LinuxDoc software. The original intent for the
460 document class was that it serve a similar role as the LDP's HOWTO
461 series, but the applicability of the class turns out to be somewhat
Fred Drake02997492000-09-21 05:26:43 +0000462 broader. This class is used for ``how-to'' documents (this
Fred Drakeacffaee1999-03-16 16:09:13 +0000463 document is an example) and for shorter reference manuals for small,
464 fairly cohesive module libraries. Examples of the later use include
Fred Drake6a547c72000-09-15 22:11:24 +0000465\citetitle[http://starship.python.net/crew/fdrake/manuals/krb5py/krb5py.html]{Using
Fred Drakeacffaee1999-03-16 16:09:13 +0000466 Kerberos from Python}, which contains reference material for an
467 extension package. These documents are roughly equivalent to a
468 single chapter from a larger work.
469
470
Fred Drakef1b3de82001-07-24 14:38:34 +0000471\section{Special Markup Constructs \label{special-constructs}}
Fred Drakeacffaee1999-03-16 16:09:13 +0000472
Fred Drake2c4e0091999-03-29 14:55:55 +0000473 The Python document classes define a lot of new environments and
474 macros. This section contains the reference material for these
475 facilities.
476
Fred Drakeaf2b7142000-09-14 20:11:05 +0000477 \subsection{Markup for the Preamble \label{preamble-info}}
478
479 \begin{macrodesc}{release}{\p{ver}}
480 Set the version number for the software described in the
481 document.
482 \end{macrodesc}
483
484 \begin{macrodesc}{setshortversion}{\p{sver}}
485 Specify the ``short'' version number of the documented software
486 to be \var{sver}.
487 \end{macrodesc}
488
Fred Drakee15956b2000-04-03 04:51:13 +0000489 \subsection{Meta-information Markup \label{meta-info}}
490
491 \begin{macrodesc}{sectionauthor}{\p{author}\p{email}}
492 Identifies the author of the current section. \var{author}
493 should be the author's name such that it can be used for
494 presentation (though it isn't), and \var{email} should be the
495 author's email address. The domain name portion of
496 the address should be lower case.
497
498 No presentation is generated from this markup, but it is used to
499 help keep track of contributions.
500 \end{macrodesc}
501
Fred Drakeacffaee1999-03-16 16:09:13 +0000502 \subsection{Information Units \label{info-units}}
503
Fred Drake2f4bebd1999-04-28 16:43:11 +0000504 XXX Explain terminology, or come up with something more ``lay.''
Fred Drakeacffaee1999-03-16 16:09:13 +0000505
Fred Drakeadade921999-04-22 13:05:27 +0000506 There are a number of environments used to describe specific
507 features provided by modules. Each environment requires
508 parameters needed to provide basic information about what is being
509 described, and the environment content should be the description.
510 Most of these environments make entries in the general index (if
511 one is being produced for the document); if no index entry is
512 desired, non-indexing variants are available for many of these
513 environments. The environments have names of the form
514 \code{\var{feature}desc}, and the non-indexing variants are named
515 \code{\var{feature}descni}. The available variants are explicitly
516 included in the list below.
517
518 For each of these environments, the first parameter, \var{name},
519 provides the name by which the feature is accessed.
520
521 Environments which describe features of objects within a module,
522 such as object methods or data attributes, allow an optional
523 \var{type name} parameter. When the feature is an attribute of
524 class instances, \var{type name} only needs to be given if the
525 class was not the most recently described class in the module; the
526 \var{name} value from the most recent \env{classdesc} is implied.
527 For features of built-in or extension types, the \var{type name}
Fred Drake7a737df1999-04-23 14:41:44 +0000528 value should always be provided. Another special case includes
529 methods and members of general ``protocols,'' such as the
530 formatter and writer protocols described for the
531 \module{formatter} module: these may be documented without any
532 specific implementation classes, and will always require the
533 \var{type name} parameter to be provided.
Fred Drakeadade921999-04-22 13:05:27 +0000534
Fred Drake7be440d2000-09-16 21:23:25 +0000535 \begin{envdesc}{cfuncdesc}{\p{type}\p{name}\p{args}}
536 Environment used to described a C function. The \var{type}
537 should be specified as a \keyword{typedef} name, \code{struct
538 \var{tag}}, or the name of a primitive type. If it is a pointer
Fred Drake02997492000-09-21 05:26:43 +0000539 type, the trailing asterisk should not be preceded by a space.
Fred Drake7be440d2000-09-16 21:23:25 +0000540 \var{name} should be the name of the function (or function-like
541 pre-processor macro), and \var{args} should give the types and
542 names of the parameters. The names need to be given so they may
543 be used in the description.
544 \end{envdesc}
545
546 \begin{envdesc}{ctypedesc}{\op{tag}\p{name}}
547 Environment used to described a C type. The \var{name}
548 parameter should be the \keyword{typedef} name. If the type is
549 defined as a \keyword{struct} without a \keyword{typedef},
550 \var{name} should have the form \code{struct \var{tag}}.
551 \var{name} will be added to the index unless \var{tag} is
552 provided, in which case \var{tag} will be used instead.
553 \var{tag} should not be used for a \keyword{typedef} name.
554 \end{envdesc}
555
556 \begin{envdesc}{cvardesc}{\p{type}\p{name}}
557 Description of a global C variable. \var{type} should be the
558 \keyword{typedef} name, \code{struct \var{tag}}, or the name of
559 a primitive type. If variable has a pointer type, the trailing
Fred Drake02997492000-09-21 05:26:43 +0000560 asterisk should \emph{not} be preceded by a space.
Fred Drake7be440d2000-09-16 21:23:25 +0000561 \end{envdesc}
562
Fred Drakeadade921999-04-22 13:05:27 +0000563 \begin{envdesc}{datadesc}{\p{name}}
564 This environment is used to document global data in a module,
565 including both variables and values used as ``defined
566 constants.'' Class and object attributes are not documented
567 using this environment.
Fred Drakeacffaee1999-03-16 16:09:13 +0000568 \end{envdesc}
Fred Drake7a737df1999-04-23 14:41:44 +0000569 \begin{envdesc}{datadescni}{\p{name}}
Fred Drakeacffaee1999-03-16 16:09:13 +0000570 Like \env{datadesc}, but without creating any index entries.
571 \end{envdesc}
572
Fred Drake9f2376d2001-05-11 01:01:12 +0000573 \begin{envdesc}{excclassdesc}{\p{name}\p{constructor parameters}}
574 Descibe an exception defined by a class. \var{constructor
575 parameters} should not include the \var{self} parameter or
576 the parentheses used in the call syntax. To describe an
577 exception class without describing the parameters to its
578 constructor, use the \env{excdesc} environment.
579 \end{envdesc}
580
Fred Drakeadade921999-04-22 13:05:27 +0000581 \begin{envdesc}{excdesc}{\p{name}}
Fred Drakeacffaee1999-03-16 16:09:13 +0000582 Describe an exception. This may be either a string exception or
Fred Drake9f2376d2001-05-11 01:01:12 +0000583 a class exception. In the case of class exceptions, the
584 constructor parameters are not described; use \env{excclassdesc}
585 to describe an exception class and its constructor.
Fred Drakeacffaee1999-03-16 16:09:13 +0000586 \end{envdesc}
587
Fred Drakeadade921999-04-22 13:05:27 +0000588 \begin{envdesc}{funcdesc}{\p{name}\p{parameters}}
589 Describe a module-level function. \var{parameters} should
590 not include the parentheses used in the call syntax. Object
591 methods are not documented using this environment. Bound object
592 methods placed in the module namespace as part of the public
593 interface of the module are documented using this, as they are
594 equivalent to normal functions for most purposes.
595
596 The description should include information about the parameters
597 required and how they are used (especially whether mutable
598 objects passed as parameters are modified), side effects, and
599 possible exceptions. A small example may be provided.
Fred Drakeacffaee1999-03-16 16:09:13 +0000600 \end{envdesc}
Fred Drakeadade921999-04-22 13:05:27 +0000601 \begin{envdesc}{funcdescni}{\p{name}\p{parameters}}
Fred Drakeacffaee1999-03-16 16:09:13 +0000602 Like \env{funcdesc}, but without creating any index entries.
603 \end{envdesc}
604
Fred Drakeadade921999-04-22 13:05:27 +0000605 \begin{envdesc}{classdesc}{\p{name}\p{constructor parameters}}
606 Describe a class and its constructor. \var{constructor
607 parameters} should not include the \var{self} parameter or
608 the parentheses used in the call syntax.
Fred Drakeacffaee1999-03-16 16:09:13 +0000609 \end{envdesc}
610
Fred Drake9f2376d2001-05-11 01:01:12 +0000611 \begin{envdesc}{classdesc*}{\p{name}}
612 Describe a class without describing the constructor. This can
613 be used to describe classes that are merely containers for
614 attributes or which should never be instantiated or subclassed
615 by user code.
616 \end{envdesc}
617
Fred Drakeadade921999-04-22 13:05:27 +0000618 \begin{envdesc}{memberdesc}{\op{type name}\p{name}}
619 Describe an object data attribute. The description should
620 include information about the type of the data to be expected
621 and whether it may be changed directly.
Fred Drakeacffaee1999-03-16 16:09:13 +0000622 \end{envdesc}
Fred Drakeadade921999-04-22 13:05:27 +0000623 \begin{envdesc}{memberdescni}{\op{type name}\p{name}}
Fred Drakeacffaee1999-03-16 16:09:13 +0000624 Like \env{memberdesc}, but without creating any index entries.
625 \end{envdesc}
626
Fred Drakeadade921999-04-22 13:05:27 +0000627 \begin{envdesc}{methoddesc}{\op{type name}\p{name}\p{parameters}}
628 Describe an object method. \var{parameters} should not include
629 the \var{self} parameter or the parentheses used in the call
630 syntax. The description should include similar information to
631 that described for \env{funcdesc}.
Fred Drakeacffaee1999-03-16 16:09:13 +0000632 \end{envdesc}
Fred Drakeadade921999-04-22 13:05:27 +0000633 \begin{envdesc}{methoddescni}{\op{type name}\p{name}\p{parameters}}
Fred Drakeacffaee1999-03-16 16:09:13 +0000634 Like \env{methoddesc}, but without creating any index entries.
635 \end{envdesc}
636
637
Fred Drakef1b3de82001-07-24 14:38:34 +0000638 \subsection{Showing Code Examples \label{showing-examples}}
Fred Drake5eb992b1999-06-11 14:25:45 +0000639
640 Examples of Python source code or interactive sessions are
641 represented as \env{verbatim} environments. This environment
642 is a standard part of \LaTeX{}. It is important to only use
643 spaces for indentation in code examples since \TeX{} drops tabs
644 instead of converting them to spaces.
645
646 Representing an interactive session requires including the prompts
647 and output along with the Python code. No special markup is
Fred Drake63568aa2000-10-19 05:36:10 +0000648 required for interactive sessions. After the last line of input
649 or output presented, there should not be an ``unused'' primary
650 prompt; this is an example of what \emph{not} to do:
651
652\begin{verbatim}
653>>> 1 + 1
6542
655>>>
656\end{verbatim}
Fred Drake5eb992b1999-06-11 14:25:45 +0000657
658 Within the \env{verbatim} environment, characters special to
659 \LaTeX{} do not need to be specially marked in any way. The entire
660 example will be presented in a monospaced font; no attempt at
661 ``pretty-printing'' is made, as the environment must work for
Fred Drake63568aa2000-10-19 05:36:10 +0000662 non-Python code and non-code displays. There should be no blank
663 lines at the top or bottom of any \env{verbatim} display.
Fred Drake5eb992b1999-06-11 14:25:45 +0000664
Fred Drake66eed242001-06-18 14:59:58 +0000665 Longer displays of verbatim text may be included by storing the
666 example text in an external file containing only plain text. The
667 file may be included using the standard \macro{verbatiminput}
668 macro; this macro takes a single argument naming the file
669 containing the text. For example, to include the Python source
670 file \file{example.py}, use:
671
672\begin{verbatim}
673\verbatiminput{example.py}
674\end{verbatim}
675
676 Use of \macro{verbatiminput} allows easier use of special editing
677 modes for the included file. The file should be placed in the
678 same directory as the \LaTeX{} files for the document.
679
Fred Drake5eb992b1999-06-11 14:25:45 +0000680 The Python Documentation Special Interest Group has discussed a
681 number of approaches to creating pretty-printed code displays and
682 interactive sessions; see the Doc-SIG area on the Python Web site
683 for more information on this topic.
684
685
Fred Drakef1b3de82001-07-24 14:38:34 +0000686 \subsection{Inline Markup \label{inline-markup}}
Fred Drakeacffaee1999-03-16 16:09:13 +0000687
Fred Drake87f768e1999-05-17 15:22:45 +0000688 The macros described in this section are used to mark just about
689 anything interesting in the document text. They may be used in
690 headings (though anything involving hyperlinks should be avoided
691 there) as well as in the body text.
Fred Drake2f4bebd1999-04-28 16:43:11 +0000692
693 \begin{macrodesc}{bfcode}{\p{text}}
694 Like \macro{code}, but also makes the font bold-face.
695 \end{macrodesc}
696
697 \begin{macrodesc}{cdata}{\p{name}}
698 The name of a C-language variable.
699 \end{macrodesc}
700
701 \begin{macrodesc}{cfunction}{\p{name}}
702 The name of a C-language function. \var{name} should include the
703 function name and the trailing parentheses.
704 \end{macrodesc}
705
706 \begin{macrodesc}{character}{\p{char}}
707 A character when discussing the character rather than a one-byte
708 string value. The character will be typeset as with \macro{samp}.
709 \end{macrodesc}
710
Fred Drake29a710f1999-11-10 22:51:18 +0000711 \begin{macrodesc}{citetitle}{\op{url}\p{title}}
712 A title for a referenced publication. If \var{url} is specified,
713 the title will be made into a hyperlink when formatted as HTML.
714 \end{macrodesc}
715
Fred Drake2f4bebd1999-04-28 16:43:11 +0000716 \begin{macrodesc}{class}{\p{name}}
717 A class name; a dotted name may be used.
718 \end{macrodesc}
719
720 \begin{macrodesc}{code}{\p{text}}
721 A short code fragment or literal constant value. Typically, it
722 should not include any spaces since no quotation marks are
723 added.
724 \end{macrodesc}
725
726 \begin{macrodesc}{constant}{\p{name}}
727 The name of a ``defined'' constant. This may be a C-language
728 \code{\#define} or a Python variable that is not intended to be
729 changed.
730 \end{macrodesc}
731
732 \begin{macrodesc}{ctype}{\p{name}}
733 The name of a C \keyword{typedef} or structure. For structures
734 defined without a \keyword{typedef}, use \code{\e ctype\{struct
735 struct_tag\}} to make it clear that the \keyword{struct} is
736 required.
737 \end{macrodesc}
738
739 \begin{macrodesc}{deprecated}{\p{version}\p{what to do}}
740 Declare whatever is being described as being deprecated starting
741 with release \var{version}. The text given as \var{what to do}
742 should recommend something to use instead.
743 \end{macrodesc}
744
745 \begin{macrodesc}{dfn}{\p{term}}
746 Mark the defining instance of \var{term} in the text. (No index
747 entries are generated.)
748 \end{macrodesc}
749
Fred Draked1fb7791999-05-17 16:33:54 +0000750 \begin{macrodesc}{e}{}
751 Produces a backslash. This is convenient in \macro{code} and
Fred Drake31edf4d2000-09-07 20:06:07 +0000752 similar macros, and is only defined there. To create a
Fred Drake2b853412000-04-11 19:08:30 +0000753 backslash in ordinary text (such as the contents of the
754 \macro{file} macro), use the standard \macro{textbackslash} macro.
Fred Draked1fb7791999-05-17 16:33:54 +0000755 \end{macrodesc}
756
Fred Drake2f4bebd1999-04-28 16:43:11 +0000757 \begin{macrodesc}{email}{\p{address}}
758 An email address. Note that this is \emph{not} hyperlinked in
Fred Drakee15956b2000-04-03 04:51:13 +0000759 any of the possible output formats. The domain name portion of
760 the address should be lower case.
Fred Drake2f4bebd1999-04-28 16:43:11 +0000761 \end{macrodesc}
762
763 \begin{macrodesc}{emph}{\p{text}}
764 Emphasized text; this will be presented in an italic font.
765 \end{macrodesc}
766
767 \begin{macrodesc}{envvar}{\p{name}}
768 An environment variable. Index entries are generated.
769 \end{macrodesc}
770
771 \begin{macrodesc}{exception}{\p{name}}
772 The name of an exception. A dotted name may be used.
773 \end{macrodesc}
774
775 \begin{macrodesc}{file}{\p{file or dir}}
776 The name of a file or directory. In the PDF and PostScript
777 outputs, single quotes and a font change are used to indicate
778 the file name, but no quotes are used in the HTML output.
Fred Drake64a5aaf2001-10-20 04:18:14 +0000779 \warning{The \macro{file} macro cannot be used in the
780 content of a section title due to processing limitations.}
Fred Drake2f4bebd1999-04-28 16:43:11 +0000781 \end{macrodesc}
782
783 \begin{macrodesc}{filenq}{\p{file or dir}}
784 Like \macro{file}, but single quotes are never used. This can
785 be used in conjunction with tables if a column will only contain
786 file or directory names.
Fred Drake64a5aaf2001-10-20 04:18:14 +0000787 \warning{The \macro{filenq} macro cannot be used in the
788 content of a section title due to processing limitations.}
Fred Drake2f4bebd1999-04-28 16:43:11 +0000789 \end{macrodesc}
790
791 \begin{macrodesc}{function}{\p{name}}
792 The name of a Python function; dotted names may be used.
793 \end{macrodesc}
794
Fred Drake432cef02001-07-06 22:34:33 +0000795 \begin{macrodesc}{infinity}{}
796 The symbol for mathematical infinity: \infinity. Some Web
797 browsers are not able to render the HTML representation of this
798 symbol properly, but support is growing.
799 \end{macrodesc}
800
Fred Drake2f4bebd1999-04-28 16:43:11 +0000801 \begin{macrodesc}{kbd}{\p{key sequence}}
802 Mark a sequence of keystrokes. What form \var{key sequence}
803 takes may depend on platform- or application-specific
Fred Drake07178d22001-07-12 02:08:29 +0000804 conventions. When there are no relevant conventions, the names
805 of modifier keys should be spelled out, to improve accessibility
806 for new users and non-native speakers. For example, an
807 \program{xemacs} key sequence may be marked like
808 \code{\e kbd\{C-x C-f\}}, but without reference to a specific
809 application or platform, the same sequence should be marked as
810 \code{\e kbd\{Control-x Control-f\}}.
Fred Drake2f4bebd1999-04-28 16:43:11 +0000811 \end{macrodesc}
812
813 \begin{macrodesc}{keyword}{\p{name}}
814 The name of a keyword in a programming language.
815 \end{macrodesc}
816
Fred Drake8b3a7b52001-09-26 17:01:58 +0000817 \begin{macrodesc}{mailheader}{\p{name}}
818 The name of an \rfc{822}-style mail header. This markup does
819 not imply that the header is being used in an email message, but
820 can be used to refer to any header of the same ``style.'' This
821 is also used for headers defined by the various MIME
822 specifications. The header name should be entered in the same
823 way it would normally be found in practice, with the
824 camel-casing conventions being preferred where there is more
Fred Drake203d91a2001-09-26 18:43:20 +0000825 than one common usage. The colon which follows the name of the
826 header should not be included.
827 For example: \code{\e mailheader\{Content-Type\}}.
Fred Drake8b3a7b52001-09-26 17:01:58 +0000828 \end{macrodesc}
829
Fred Drake2f4bebd1999-04-28 16:43:11 +0000830 \begin{macrodesc}{makevar}{\p{name}}
831 The name of a \program{make} variable.
832 \end{macrodesc}
833
834 \begin{macrodesc}{manpage}{\p{name}\p{section}}
835 A reference to a \UNIX{} manual page.
836 \end{macrodesc}
837
838 \begin{macrodesc}{member}{\p{name}}
839 The name of a data attribute of an object.
840 \end{macrodesc}
841
842 \begin{macrodesc}{method}{\p{name}}
843 The name of a method of an object. \var{name} should include the
844 method name and the trailing parentheses. A dotted name may be
845 used.
846 \end{macrodesc}
847
848 \begin{macrodesc}{mimetype}{\p{name}}
Fred Drake8b3a7b52001-09-26 17:01:58 +0000849 The name of a MIME type, or a component of a MIME type (the
850 major or minor portion, taken alone).
Fred Drake2f4bebd1999-04-28 16:43:11 +0000851 \end{macrodesc}
852
853 \begin{macrodesc}{module}{\p{name}}
Fred Drake2b853412000-04-11 19:08:30 +0000854 The name of a module; a dotted name may be used. This should
855 also be used for package names.
Fred Drake2f4bebd1999-04-28 16:43:11 +0000856 \end{macrodesc}
857
858 \begin{macrodesc}{newsgroup}{\p{name}}
Fred Drake9120df32001-07-14 02:34:12 +0000859 The name of a Usenet newsgroup.
Fred Drake2f4bebd1999-04-28 16:43:11 +0000860 \end{macrodesc}
861
Fred Drake92350b32001-10-09 18:01:23 +0000862 \begin{macrodesc}{note}{\p{text}}
863 An especially important bit of information about an API that a
864 user should be aware of when using whatever bit of API the
865 note pertains to. This should be the last thing in the
866 paragraph as the end of the note is not visually marked in
Fred Drake64a5aaf2001-10-20 04:18:14 +0000867 any way. The content of \var{text} should be written in
868 complete sentences and include all appropriate punctuation.
Fred Drake92350b32001-10-09 18:01:23 +0000869 \end{macrodesc}
870
Fred Drake432cef02001-07-06 22:34:33 +0000871 \begin{macrodesc}{pep}{\p{number}}
872 A reference to a Python Enhancement Proposal. This generates
873 appropriate index entries. The text \samp{PEP \var{number}} is
874 generated; in the HTML output, this text is a hyperlink to an
875 online copy of the specified PEP.
876 \end{macrodesc}
877
878 \begin{macrodesc}{plusminus}{}
879 The symbol for indicating a value that may take a positive or
880 negative value of a specified magnitude, typically represented
881 by a plus sign placed over a minus sign. For example:
Fred Drake203d91a2001-09-26 18:43:20 +0000882 \code{\e plusminus 3\%{}}.
Fred Drake432cef02001-07-06 22:34:33 +0000883 \end{macrodesc}
884
Fred Drake2f4bebd1999-04-28 16:43:11 +0000885 \begin{macrodesc}{program}{\p{name}}
886 The name of an executable program. This may differ from the
887 file name for the executable for some platforms. In particular,
888 the \file{.exe} (or other) extension should be omitted for DOS
889 and Windows programs.
890 \end{macrodesc}
891
Fred Drake29a710f1999-11-10 22:51:18 +0000892 \begin{macrodesc}{programopt}{\p{option}}
Fred Drakece444982000-04-11 18:52:52 +0000893 A command-line option to an executable program. Use this only
894 for ``shot'' options, and include the leading hyphen.
895 \end{macrodesc}
896
897 \begin{macrodesc}{longprogramopt}{\p{option}}
898 A long command-line option to an executable program. This
899 should only be used for long option names which will be prefixed
900 by two hyphens; the hyphens should not be provided as part of
901 \var{option}.
Fred Drake29a710f1999-11-10 22:51:18 +0000902 \end{macrodesc}
903
Fred Drake2f4bebd1999-04-28 16:43:11 +0000904 \begin{macrodesc}{refmodule}{\op{key}\p{name}}
905 Like \macro{module}, but create a hyperlink to the documentation
906 for the named module. Note that the corresponding
907 \macro{declaremodule} must be in the same document. If the
908 \macro{declaremodule} defines a module key different from the
909 module name, it must also be provided as \var{key} to the
910 \macro{refmodule} macro.
911 \end{macrodesc}
912
913 \begin{macrodesc}{regexp}{\p{string}}
914 Mark a regular expression.
915 \end{macrodesc}
916
917 \begin{macrodesc}{rfc}{\p{number}}
918 A reference to an Internet Request for Comments. This generates
919 appropriate index entries. The text \samp{RFC \var{number}} is
920 generated; in the HTML output, this text is a hyperlink to an
921 online copy of the specified RFC.
922 \end{macrodesc}
923
924 \begin{macrodesc}{samp}{\p{text}}
925 A short code sample, but possibly longer than would be given
926 using \macro{code}. Since quotation marks are added, spaces are
927 acceptable.
928 \end{macrodesc}
929
Fred Drakeaf2b7142000-09-14 20:11:05 +0000930 \begin{macrodesc}{shortversion}{}
931 The ``short'' version number of the documented software, as
932 specified using the \macro{setshortversion} macro in the
933 preamble. For Python, the short version number for a release is
934 the first three characters of the \code{sys.version} value. For
935 example, versions 2.0b1 and 2.0.1 both have a short version of
936 2.0. This may not apply for all packages; if
937 \macro{setshortversion} is not used, this produces an empty
938 expansion. See also the \macro{version} macro.
939 \end{macrodesc}
940
Fred Drake2f4bebd1999-04-28 16:43:11 +0000941 \begin{macrodesc}{strong}{\p{text}}
942 Strongly emphasized text; this will be presented using a bold
943 font.
944 \end{macrodesc}
945
Fred Drake432cef02001-07-06 22:34:33 +0000946 \begin{macrodesc}{ulink}{\p{text}\p{url}}
947 A hypertext link with a target specified by a URL, but for which
948 the link text should not be the title of the resource. For
949 resources being referenced by name, use the \macro{citetitle}
950 macro. Not all formatted versions support arbitrary hypertext
951 links. Note that many characters are special to \LaTeX{} and
952 this macro does not always do the right thing. In particular,
953 the tilde character (\character{\~}) is mis-handled; encoding it
954 as a hex-sequence does work, use \samp{\%7e} in place of the
955 tilde character.
956 \end{macrodesc}
957
Fred Draked1fb7791999-05-17 16:33:54 +0000958 \begin{macrodesc}{url}{\p{url}}
959 A URL (or URN). The URL will be presented as text. In the HTML
960 and PDF formatted versions, the URL will also be a hyperlink.
Fred Drake432cef02001-07-06 22:34:33 +0000961 This can be used when referring to external resources without
962 specific titles; references to resources which have titles
963 should be marked using the \macro{citetitle} macro. See the
964 comments about special characters in the description of the
965 \macro{ulink} macro for special considerations.
Fred Draked1fb7791999-05-17 16:33:54 +0000966 \end{macrodesc}
967
Fred Drake2f4bebd1999-04-28 16:43:11 +0000968 \begin{macrodesc}{var}{\p{name}}
969 The name of a variable or formal parameter in running text.
970 \end{macrodesc}
971
972 \begin{macrodesc}{version}{}
Fred Drakeaf2b7142000-09-14 20:11:05 +0000973 The version number of the described software, as specified using
974 \macro{release} in the preamble. See also the
975 \macro{shortversion} macro.
Fred Drake2f4bebd1999-04-28 16:43:11 +0000976 \end{macrodesc}
Fred Drakeacffaee1999-03-16 16:09:13 +0000977
Fred Drake3151f442001-04-18 05:19:06 +0000978 \begin{macrodesc}{versionadded}{\op{explanation}\p{version}}
Fred Drakec26cc912000-05-02 17:43:44 +0000979 The version of Python which added the described feature to the
Fred Drake3151f442001-04-18 05:19:06 +0000980 library or C API. \var{explanation} should be a \emph{brief}
981 explanation of the change consisting of a capitalized sentence
982 fragment; a period will be appended by the formatting process.
983 This is typically added to the end of the first paragraph of the
984 description before any availability notes. The location should
985 be selected so the explanation makes sense and may vary as
986 needed.
Fred Drakec26cc912000-05-02 17:43:44 +0000987 \end{macrodesc}
988
989 \begin{macrodesc}{versionchanged}{\op{explanation}\p{version}}
990 The version of Python in which the named feature was changed in
991 some way (new parameters, changed side effects, etc.).
992 \var{explanation} should be a \emph{brief} explanation of the
Fred Drake63568aa2000-10-19 05:36:10 +0000993 change consisting of a capitalized sentence fragment; a
Fred Drakec26cc912000-05-02 17:43:44 +0000994 period will be appended by the formatting process.
995 This is typically added to the end of the first paragraph of the
996 description before any availability notes and after
997 \macro{versionadded}. The location should be selected so the
998 explanation makes sense and may vary as needed.
999 \end{macrodesc}
1000
Fred Drake92350b32001-10-09 18:01:23 +00001001 \begin{macrodesc}{warning}{\p{text}}
1002 An important bit of information about an API that a user should
1003 be very aware of when using whatever bit of API the warning
1004 pertains to. This should be the last thing in the paragraph as
Fred Drake64a5aaf2001-10-20 04:18:14 +00001005 the end of the warning is not visually marked in any way. The
1006 content of \var{text} should be written in complete sentences
1007 and include all appropriate punctuation. This differs from
1008 \macro{note} in that it is recommended over \macro{note} for
1009 information regarding security.
Fred Drake92350b32001-10-09 18:01:23 +00001010 \end{macrodesc}
1011
Fred Drakeacffaee1999-03-16 16:09:13 +00001012
Fred Drakef1b3de82001-07-24 14:38:34 +00001013 \subsection{Module-specific Markup \label{module-markup}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001014
1015 The markup described in this section is used to provide information
1016 about a module being documented. A typical use of this markup
1017 appears at the top of the section used to document a module. A
1018 typical example might look like this:
1019
1020\begin{verbatim}
1021\section{\module{spam} ---
1022 Access to the SPAM facility}
1023
1024\declaremodule{extension}{spam}
Fred Drake2c4e0091999-03-29 14:55:55 +00001025 \platform{Unix}
Fred Drake9120df32001-07-14 02:34:12 +00001026\modulesynopsis{Access to the SPAM facility of \UNIX.}
Fred Drake2c4e0091999-03-29 14:55:55 +00001027\moduleauthor{Jane Doe}{jane.doe@frobnitz.org}
Fred Drakeacffaee1999-03-16 16:09:13 +00001028\end{verbatim}
1029
Fred Drake7932ed02000-08-11 17:37:33 +00001030 Python packages\index{packages} --- collections of modules that can
1031 be described as a unit --- are documented using the same markup as
1032 modules. The name for a module in a package should be typed in
Fred Drake432cef02001-07-06 22:34:33 +00001033 ``fully qualified'' form (it should include the package name).
Fred Drake7932ed02000-08-11 17:37:33 +00001034 For example, a module ``foo'' in package ``bar'' should be marked as
Fred Drake203d91a2001-09-26 18:43:20 +00001035 \code{\e module\{bar.foo\}}, and the beginning of the reference
Fred Drake7932ed02000-08-11 17:37:33 +00001036 section would appear as:
1037
1038\begin{verbatim}
1039\section{\module{bar.foo} ---
1040 Module from the \module{bar} package}
1041
1042\declaremodule{extension}{bar.foo}
1043\modulesynopsis{Nifty module from the \module{bar} package.}
1044\moduleauthor{Jane Doe}{jane.doe@frobnitz.org}
1045\end{verbatim}
1046
1047 Note that the name of a package is also marked using
1048 \macro{module}.
1049
Fred Drakeadade921999-04-22 13:05:27 +00001050 \begin{macrodesc}{declaremodule}{\op{key}\p{type}\p{name}}
Fred Drake87f768e1999-05-17 15:22:45 +00001051 Requires two parameters: module type (\samp{standard},
1052 \samp{builtin}, \samp{extension}, or \samp{}), and the module
1053 name. An optional parameter should be given as the basis for the
1054 module's ``key'' used for linking to or referencing the section.
1055 The ``key'' should only be given if the module's name contains any
1056 underscores, and should be the name with the underscores stripped.
1057 Note that the \var{type} parameter must be one of the values
1058 listed above or an error will be printed. For modules which are
1059 contained in packages, the fully-qualified name should be given as
1060 \var{name} parameter. This should be the first thing after the
1061 \macro{section} used to introduce the module.
Fred Drakeacffaee1999-03-16 16:09:13 +00001062 \end{macrodesc}
1063
Fred Drakeadade921999-04-22 13:05:27 +00001064 \begin{macrodesc}{platform}{\p{specifier}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001065 Specifies the portability of the module. \var{specifier} is a
1066 comma-separated list of keys that specify what platforms the
1067 module is available on. The keys are short identifiers;
1068 examples that are in use include \samp{IRIX}, \samp{Mac},
1069 \samp{Windows}, and \samp{Unix}. It is important to use a key
Fred Drake7a737df1999-04-23 14:41:44 +00001070 which has already been used when applicable. This is used to
1071 provide annotations in the Module Index and the HTML and GNU info
1072 output.
Fred Drakeacffaee1999-03-16 16:09:13 +00001073 \end{macrodesc}
1074
Fred Drakeadade921999-04-22 13:05:27 +00001075 \begin{macrodesc}{modulesynopsis}{\p{text}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001076 The \var{text} is a short, ``one line'' description of the
1077 module that can be used as part of the chapter introduction.
Fred Drakeadade921999-04-22 13:05:27 +00001078 This is must be placed after \macro{declaremodule}.
Fred Drakeacffaee1999-03-16 16:09:13 +00001079 The synopsis is used in building the contents of the table
1080 inserted as the \macro{localmoduletable}. No text is
1081 produced at the point of the markup.
1082 \end{macrodesc}
1083
Fred Drakeadade921999-04-22 13:05:27 +00001084 \begin{macrodesc}{moduleauthor}{\p{name}\p{email}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001085 This macro is used to encode information about who authored a
1086 module. This is currently not used to generate output, but can be
1087 used to help determine the origin of the module.
1088 \end{macrodesc}
1089
1090
Fred Drakef1b3de82001-07-24 14:38:34 +00001091 \subsection{Library-level Markup \label{library-markup}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001092
1093 This markup is used when describing a selection of modules. For
Fred Drake698d5201999-11-10 15:54:57 +00001094 example, the \citetitle[../mac/mac.html]{Macintosh Library
1095 Modules} document uses this to help provide an overview of the
1096 modules in the collection, and many chapters in the
1097 \citetitle[../lib/lib.html]{Python Library Reference} use it for
Fred Drakeacffaee1999-03-16 16:09:13 +00001098 the same purpose.
1099
1100 \begin{macrodesc}{localmoduletable}{}
Fred Drake2c4e0091999-03-29 14:55:55 +00001101 If a \file{.syn} file exists for the current
Fred Drakeacffaee1999-03-16 16:09:13 +00001102 chapter (or for the entire document in \code{howto} documents), a
1103 \env{synopsistable} is created with the contents loaded from the
1104 \file{.syn} file.
1105 \end{macrodesc}
1106
1107
Fred Drakef1b3de82001-07-24 14:38:34 +00001108 \subsection{Table Markup \label{table-markup}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001109
1110 There are three general-purpose table environments defined which
1111 should be used whenever possible. These environments are defined
1112 to provide tables of specific widths and some convenience for
1113 formatting. These environments are not meant to be general
1114 replacements for the standard \LaTeX{} table environments, but can
1115 be used for an advantage when the documents are processed using
1116 the tools for Python documentation processing. In particular, the
1117 generated HTML looks good! There is also an advantage for the
Fred Drake67f193f2001-07-09 16:04:03 +00001118 eventual conversion of the documentation to XML (see section
Fred Drake2c4e0091999-03-29 14:55:55 +00001119 \ref{futures}, ``Future Directions'').
Fred Drakeacffaee1999-03-16 16:09:13 +00001120
1121 Each environment is named \env{table\var{cols}}, where \var{cols}
1122 is the number of columns in the table specified in lower-case
1123 Roman numerals. Within each of these environments, an additional
1124 macro, \macro{line\var{cols}}, is defined, where \var{cols}
1125 matches the \var{cols} value of the corresponding table
Fred Drake2c4e0091999-03-29 14:55:55 +00001126 environment. These are supported for \var{cols} values of
1127 \code{ii}, \code{iii}, and \code{iv}. These environments are all
Fred Drakeda72b932000-09-21 15:58:02 +00001128 built on top of the \env{tabular} environment. Variants based on
1129 the \env{longtable} environment are also provided.
Fred Drakeacffaee1999-03-16 16:09:13 +00001130
Fred Drake2b853412000-04-11 19:08:30 +00001131 Note that all tables in the standard Python documentation use
1132 vertical lines between columns, and this must be specified in the
1133 markup for each table. A general border around the outside of the
1134 table is not used, but would be the responsibility of the
Fred Drakeda72b932000-09-21 15:58:02 +00001135 processor; the document markup should not include an exterior
1136 border.
1137
1138 The \env{longtable}-based variants of the table environments are
1139 formatted with extra space before and after, so should only be
1140 used on tables which are long enough that splitting over multiple
1141 pages is reasonable; tables with fewer than twenty rows should
1142 never by marked using the long flavors of the table environments.
1143 The header row is repeated across the top of each part of the
1144 table.
Fred Drake2b853412000-04-11 19:08:30 +00001145
Fred Drakeadade921999-04-22 13:05:27 +00001146 \begin{envdesc}{tableii}{\p{colspec}\p{col1font}\p{heading1}\p{heading2}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001147 Create a two-column table using the \LaTeX{} column specifier
1148 \var{colspec}. The column specifier should indicate vertical
1149 bars between columns as appropriate for the specific table, but
1150 should not specify vertical bars on the outside of the table
1151 (that is considered a stylesheet issue). The \var{col1font}
1152 parameter is used as a stylistic treatment of the first column
1153 of the table: the first column is presented as
1154 \code{\e\var{col1font}\{column1\}}. To avoid treating the first
Fred Drakeadade921999-04-22 13:05:27 +00001155 column specially, \var{col1font} may be \samp{textrm}. The
Fred Drakeacffaee1999-03-16 16:09:13 +00001156 column headings are taken from the values \var{heading1} and
1157 \var{heading2}.
1158 \end{envdesc}
1159
Fred Drakeda72b932000-09-21 15:58:02 +00001160 \begin{envdesc}{longtableii}{\unspecified}
1161 Like \env{tableii}, but produces a table which may be broken
1162 across page boundaries. The parameters are the same as for
1163 \env{tableii}.
1164 \end{envdesc}
1165
Fred Drakeadade921999-04-22 13:05:27 +00001166 \begin{macrodesc}{lineii}{\p{column1}\p{column2}}
Fred Drakeda72b932000-09-21 15:58:02 +00001167 Create a single table row within a \env{tableii} or
1168 \env{longtableii} environment.
Fred Drakeacffaee1999-03-16 16:09:13 +00001169 The text for the first column will be generated by applying the
1170 macro named by the \var{col1font} value when the \env{tableii}
1171 was opened.
1172 \end{macrodesc}
1173
Fred Drakeadade921999-04-22 13:05:27 +00001174 \begin{envdesc}{tableiii}{\p{colspec}\p{col1font}\p{heading1}\p{heading2}\p{heading3}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001175 Like the \env{tableii} environment, but with a third column.
1176 The heading for the third column is given by \var{heading3}.
1177 \end{envdesc}
1178
Fred Drakeda72b932000-09-21 15:58:02 +00001179 \begin{envdesc}{longtableiii}{\unspecified}
1180 Like \env{tableiii}, but produces a table which may be broken
1181 across page boundaries. The parameters are the same as for
1182 \env{tableiii}.
1183 \end{envdesc}
1184
Fred Drakeadade921999-04-22 13:05:27 +00001185 \begin{macrodesc}{lineiii}{\p{column1}\p{column2}\p{column3}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001186 Like the \macro{lineii} macro, but with a third column. The
1187 text for the third column is given by \var{column3}.
1188 \end{macrodesc}
1189
Fred Drakeadade921999-04-22 13:05:27 +00001190 \begin{envdesc}{tableiv}{\p{colspec}\p{col1font}\p{heading1}\p{heading2}\p{heading3}\p{heading4}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001191 Like the \env{tableiii} environment, but with a fourth column.
1192 The heading for the fourth column is given by \var{heading4}.
1193 \end{envdesc}
1194
Fred Drakeda72b932000-09-21 15:58:02 +00001195 \begin{envdesc}{longtableiv}{\unspecified}
1196 Like \env{tableiv}, but produces a table which may be broken
1197 across page boundaries. The parameters are the same as for
1198 \env{tableiv}.
1199 \end{envdesc}
1200
Fred Drakeadade921999-04-22 13:05:27 +00001201 \begin{macrodesc}{lineiv}{\p{column1}\p{column2}\p{column3}\p{column4}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001202 Like the \macro{lineiii} macro, but with a fourth column. The
1203 text for the fourth column is given by \var{column4}.
1204 \end{macrodesc}
1205
Fred Drakef269e592001-07-17 23:05:57 +00001206 \begin{envdesc}{tablev}{\p{colspec}\p{col1font}\p{heading1}\p{heading2}\p{heading3}\p{heading4}\p{heading5}}
1207 Like the \env{tableiv} environment, but with a fifth column.
1208 The heading for the fifth column is given by \var{heading5}.
1209 \end{envdesc}
1210
1211 \begin{envdesc}{longtablev}{\unspecified}
1212 Like \env{tablev}, but produces a table which may be broken
1213 across page boundaries. The parameters are the same as for
1214 \env{tablev}.
1215 \end{envdesc}
1216
1217 \begin{macrodesc}{linev}{\p{column1}\p{column2}\p{column3}\p{column4}\p{column5}}
1218 Like the \macro{lineiv} macro, but with a fifth column. The
1219 text for the fifth column is given by \var{column5}.
1220 \end{macrodesc}
1221
Fred Drakeacffaee1999-03-16 16:09:13 +00001222
1223 An additional table-like environment is \env{synopsistable}. The
1224 table generated by this environment contains two columns, and each
1225 row is defined by an alternate definition of
Fred Drakee15956b2000-04-03 04:51:13 +00001226 \macro{modulesynopsis}. This environment is not normally used by
1227 authors, but is created by the \macro{localmoduletable} macro.
Fred Drakeacffaee1999-03-16 16:09:13 +00001228
Fred Drake0cac5f62001-08-14 21:36:19 +00001229 Here is a small example of a table given in the documentation for
1230 the \module{warnings} module; markup inside the table cells is
1231 minimal so the markup for the table itself is readily discernable.
1232 Here is the markup for the table:
1233
1234\begin{verbatim}
1235\begin{tableii}{l|l}{exception}{Class}{Description}
1236 \lineii{Warning}
1237 {This is the base class of all warning category classes. It
1238 is a subclass of \exception{Exception}.}
1239 \lineii{UserWarning}
1240 {The default category for \function{warn()}.}
1241 \lineii{DeprecationWarning}
1242 {Base category for warnings about deprecated features.}
1243 \lineii{SyntaxWarning}
1244 {Base category for warnings about dubious syntactic
1245 features.}
1246 \lineii{RuntimeWarning}
1247 {Base category for warnings about dubious runtime features.}
1248\end{tableii}
1249\end{verbatim}
1250
1251 Here is the resulting table:
1252
1253\begin{tableii}{l|l}{exception}{Class}{Description}
1254 \lineii{Warning}
1255 {This is the base class of all warning category classes. It
1256 is a subclass of \exception{Exception}.}
1257 \lineii{UserWarning}
1258 {The default category for \function{warn()}.}
1259 \lineii{DeprecationWarning}
1260 {Base category for warnings about deprecated features.}
1261 \lineii{SyntaxWarning}
1262 {Base category for warnings about dubious syntactic
1263 features.}
1264 \lineii{RuntimeWarning}
1265 {Base category for warnings about dubious runtime features.}
1266\end{tableii}
1267
1268 Note that the class names are implicitly marked using the
1269 \macro{exception} macro, since that is given as the \var{col1font}
1270 value for the \env{tableii} environment. To create a table using
1271 different markup for the first column, use \code{textrm} for the
1272 \var{col1font} value and mark each entry individually.
1273
1274 To add a horizontal line between vertical sections of a table, use
1275 the standard \macro{hline} macro between the rows which should be
1276 separated:
1277
1278\begin{verbatim}
1279\begin{tableii}{l|l}{constant}{Language}{Audience}
1280 \lineii{APL}{Masochists.}
1281 \lineii{BASIC}{First-time programmers on PC hardware.}
1282 \lineii{C}{\UNIX{} \&\ Linux kernel developers.}
1283 \hline
1284 \lineii{Python}{Everyone!}
1285\end{tableii}
1286\end{verbatim}
1287
1288 Note that not all presentation formats are capable of displaying a
1289 horizontal rule in this position. This is how the table looks in
1290 the format you're reading now:
1291
1292\begin{tableii}{l|l}{constant}{Language}{Audience}
1293 \lineii{APL}{Masochists.}
1294 \lineii{C}{\UNIX{} \&\ Linux kernel developers.}
1295 \lineii{JavaScript}{Web developers.}
1296 \hline
1297 \lineii{Python}{Everyone!}
1298\end{tableii}
1299
Fred Drakeacffaee1999-03-16 16:09:13 +00001300
1301 \subsection{Reference List Markup \label{references}}
1302
1303 Many sections include a list of references to module documentation
1304 or external documents. These lists are created using the
1305 \env{seealso} environment. This environment defines some
1306 additional macros to support creating reference entries in a
1307 reasonable manner.
1308
Fred Drake5802e482000-07-06 05:24:41 +00001309 The \env{seealso} environment is typically placed in a section
1310 just before any sub-sections. This is done to ensure that
1311 reference links related to the section are not hidden in a
1312 subsection in the hypertext renditions of the documentation.
1313
Fred Drakeacffaee1999-03-16 16:09:13 +00001314 \begin{envdesc}{seealso}{}
1315 This environment creates a ``See also:'' heading and defines the
1316 markup used to describe individual references.
1317 \end{envdesc}
1318
Fred Drake48449982000-09-12 17:52:33 +00001319 For each of the following macros, \var{why} should be one or more
1320 complete sentences, starting with a capital letter (unless it
1321 starts with an identifier, which should not be modified), and
1322 ending with the apropriate punctuation.
Fred Drake5802e482000-07-06 05:24:41 +00001323
Fred Drakeb7cf3782000-09-12 19:58:10 +00001324 These macros are only defined within the content of the
1325 \env{seealso} environment.
1326
Fred Drakeadade921999-04-22 13:05:27 +00001327 \begin{macrodesc}{seemodule}{\op{key}\p{name}\p{why}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001328 Refer to another module. \var{why} should be a brief
1329 explanation of why the reference may be interesting. The module
1330 name is given in \var{name}, with the link key given in
1331 \var{key} if necessary. In the HTML and PDF conversions, the
1332 module name will be a hyperlink to the referred-to module.
Fred Drake64a5aaf2001-10-20 04:18:14 +00001333 \note{The module must be documented in the same
1334 document (the corresponding \macro{declaremodule} is required).}
Fred Drakeacffaee1999-03-16 16:09:13 +00001335 \end{macrodesc}
1336
Fred Drake08c5d0c2000-09-11 05:22:30 +00001337 \begin{macrodesc}{seepep}{\p{number}\p{title}\p{why}}
1338 Refer to an Python Enhancement Proposal (PEP). \var{number}
1339 should be the official number assigned by the PEP Editor,
1340 \var{title} should be the human-readable title of the PEP as
Fred Drake5802e482000-07-06 05:24:41 +00001341 found in the official copy of the document, and \var{why} should
Fred Drake08c5d0c2000-09-11 05:22:30 +00001342 explain what's interesting about the PEP. This should be used
1343 to refer the reader to PEPs which specify interfaces or language
1344 features relevant to the material in the annotated section of the
1345 documentation.
1346 \end{macrodesc}
1347
1348 \begin{macrodesc}{seerfc}{\p{number}\p{title}\p{why}}
1349 Refer to an IETF Request for Comments (RFC). Otherwise very
1350 similar to \macro{seepep}. This should be used
1351 to refer the reader to PEPs which specify protocols or data
Fred Drake5802e482000-07-06 05:24:41 +00001352 formats relevant to the material in the annotated section of the
1353 documentation.
1354 \end{macrodesc}
1355
Fred Drakeadade921999-04-22 13:05:27 +00001356 \begin{macrodesc}{seetext}{\p{text}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001357 Add arbitrary text \var{text} to the ``See also:'' list. This
1358 can be used to refer to off-line materials or on-line materials
Fred Drake5802e482000-07-06 05:24:41 +00001359 using the \macro{url} macro. This should consist of one or more
1360 complete sentences.
1361 \end{macrodesc}
1362
Fred Drake48449982000-09-12 17:52:33 +00001363 \begin{macrodesc}{seetitle}{\op{url}\p{title}\p{why}}
1364 Add a reference to an external document named \var{title}. If
1365 \var{url} is given, the title is made a hyperlink in the HTML
1366 version of the documentation, and displayed below the title in
1367 the typeset versions of the documentation.
1368 \end{macrodesc}
1369
Fred Drake5802e482000-07-06 05:24:41 +00001370 \begin{macrodesc}{seeurl}{\p{url}\p{why}}
1371 References to specific on-line resources should be given using
1372 the \macro{seeurl} macro. No title is associated with the
1373 reference, but the \var{why} text may include a title marked
1374 using the \macro{citetitle} macro.
Fred Drakeacffaee1999-03-16 16:09:13 +00001375 \end{macrodesc}
1376
1377
1378 \subsection{Index-generating Markup \label{indexing}}
1379
1380 Effective index generation for technical documents can be very
Fred Drakee15956b2000-04-03 04:51:13 +00001381 difficult, especially for someone familiar with the topic but not
Fred Drakeacffaee1999-03-16 16:09:13 +00001382 the creation of indexes. Much of the difficulty arises in the
1383 area of terminology: including the terms an expert would use for a
1384 concept is not sufficient. Coming up with the terms that a novice
Fred Drake2c4e0091999-03-29 14:55:55 +00001385 would look up is fairly difficult for an author who, typically, is
Fred Drakeacffaee1999-03-16 16:09:13 +00001386 an expert in the area she is writing on.
1387
Fred Drake2c4e0091999-03-29 14:55:55 +00001388 The truly difficult aspects of index generation are not areas with
1389 which the documentation tools can help. However, ease
Fred Drakee15956b2000-04-03 04:51:13 +00001390 of producing the index once content decisions are made is within
Fred Drakeacffaee1999-03-16 16:09:13 +00001391 the scope of the tools. Markup is provided which the processing
1392 software is able to use to generate a variety of kinds of index
1393 entry with minimal effort. Additionally, many of the environments
Fred Drake7a737df1999-04-23 14:41:44 +00001394 described in section \ref{info-units}, ``Information Units,'' will
Fred Drakeacffaee1999-03-16 16:09:13 +00001395 generate appropriate entries into the general and module indexes.
1396
1397 The following macro can be used to control the generation of index
Fred Drakeadade921999-04-22 13:05:27 +00001398 data, and should be used in the document preamble:
Fred Drakeacffaee1999-03-16 16:09:13 +00001399
1400 \begin{macrodesc}{makemodindex}{}
Fred Drakeadade921999-04-22 13:05:27 +00001401 This should be used in the document preamble if a ``Module
Fred Drakeacffaee1999-03-16 16:09:13 +00001402 Index'' is desired for a document containing reference material
1403 on many modules. This causes a data file
Fred Draked1fb7791999-05-17 16:33:54 +00001404 \code{lib\var{jobname}.idx} to be created from the
Fred Drakeacffaee1999-03-16 16:09:13 +00001405 \macro{declaremodule} macros. This file can be processed by the
1406 \program{makeindex} program to generate a file which can be
1407 \macro{input} into the document at the desired location of the
1408 module index.
1409 \end{macrodesc}
1410
1411 There are a number of macros that are useful for adding index
1412 entries for particular concepts, many of which are specific to
1413 programming languages or even Python.
1414
Fred Drakeadade921999-04-22 13:05:27 +00001415 \begin{macrodesc}{bifuncindex}{\p{name}}
Fred Drakeec8b9051999-04-23 20:01:17 +00001416 Add an index entry referring to a built-in function named
1417 \var{name}; parentheses should not be included after
Fred Drake2c4e0091999-03-29 14:55:55 +00001418 \var{name}.
Fred Drakeacffaee1999-03-16 16:09:13 +00001419 \end{macrodesc}
1420
Fred Drakeadade921999-04-22 13:05:27 +00001421 \begin{macrodesc}{exindex}{\p{exception}}
Fred Drake2c4e0091999-03-29 14:55:55 +00001422 Add a reference to an exception named \var{exception}. The
1423 exception may be either string- or class-based.
Fred Drakeacffaee1999-03-16 16:09:13 +00001424 \end{macrodesc}
1425
Fred Drakeadade921999-04-22 13:05:27 +00001426 \begin{macrodesc}{kwindex}{\p{keyword}}
Fred Drake2c4e0091999-03-29 14:55:55 +00001427 Add a reference to a language keyword (not a keyword parameter
1428 in a function or method call).
Fred Drakeacffaee1999-03-16 16:09:13 +00001429 \end{macrodesc}
1430
Fred Drakeadade921999-04-22 13:05:27 +00001431 \begin{macrodesc}{obindex}{\p{object type}}
Fred Drake2c4e0091999-03-29 14:55:55 +00001432 Add an index entry for a built-in object type.
Fred Drakeacffaee1999-03-16 16:09:13 +00001433 \end{macrodesc}
1434
Fred Drakeadade921999-04-22 13:05:27 +00001435 \begin{macrodesc}{opindex}{\p{operator}}
Fred Drake2c4e0091999-03-29 14:55:55 +00001436 Add a reference to an operator, such as \samp{+}.
Fred Drakeacffaee1999-03-16 16:09:13 +00001437 \end{macrodesc}
1438
Fred Drakeadade921999-04-22 13:05:27 +00001439 \begin{macrodesc}{refmodindex}{\op{key}\p{module}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001440 Add an index entry for module \var{module}; if \var{module}
1441 contains an underscore, the optional parameter \var{key} should
1442 be provided as the same string with underscores removed. An
1443 index entry ``\var{module} (module)'' will be generated. This
1444 is intended for use with non-standard modules implemented in
1445 Python.
1446 \end{macrodesc}
1447
Fred Drakeadade921999-04-22 13:05:27 +00001448 \begin{macrodesc}{refexmodindex}{\op{key}\p{module}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001449 As for \macro{refmodindex}, but the index entry will be
1450 ``\var{module} (extension module).'' This is intended for use
1451 with non-standard modules not implemented in Python.
1452 \end{macrodesc}
1453
Fred Drakeadade921999-04-22 13:05:27 +00001454 \begin{macrodesc}{refbimodindex}{\op{key}\p{module}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001455 As for \macro{refmodindex}, but the index entry will be
1456 ``\var{module} (built-in module).'' This is intended for use
1457 with standard modules not implemented in Python.
1458 \end{macrodesc}
1459
Fred Drakeadade921999-04-22 13:05:27 +00001460 \begin{macrodesc}{refstmodindex}{\op{key}\p{module}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001461 As for \macro{refmodindex}, but the index entry will be
1462 ``\var{module} (standard module).'' This is intended for use
1463 with standard modules implemented in Python.
1464 \end{macrodesc}
1465
Fred Drakeadade921999-04-22 13:05:27 +00001466 \begin{macrodesc}{stindex}{\p{statement}}
Fred Drake2c4e0091999-03-29 14:55:55 +00001467 Add an index entry for a statement type, such as \keyword{print}
Fred Drakeadade921999-04-22 13:05:27 +00001468 or \keyword{try}/\keyword{finally}.
1469
1470 XXX Need better examples of difference from \macro{kwindex}.
Fred Drakeacffaee1999-03-16 16:09:13 +00001471 \end{macrodesc}
1472
1473
1474 Additional macros are provided which are useful for conveniently
1475 creating general index entries which should appear at many places
1476 in the index by rotating a list of words. These are simple macros
1477 that simply use \macro{index} to build some number of index
1478 entries. Index entries build using these macros contain both
1479 primary and secondary text.
1480
Fred Drakeadade921999-04-22 13:05:27 +00001481 \begin{macrodesc}{indexii}{\p{word1}\p{word2}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001482 Build two index entries. This is exactly equivalent to using
1483 \code{\e index\{\var{word1}!\var{word2}\}} and
1484 \code{\e index\{\var{word2}!\var{word1}\}}.
1485 \end{macrodesc}
1486
Fred Drakeadade921999-04-22 13:05:27 +00001487 \begin{macrodesc}{indexiii}{\p{word1}\p{word2}\p{word3}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001488 Build three index entries. This is exactly equivalent to using
1489 \code{\e index\{\var{word1}!\var{word2} \var{word3}\}},
1490 \code{\e index\{\var{word2}!\var{word3}, \var{word1}\}}, and
1491 \code{\e index\{\var{word3}!\var{word1} \var{word2}\}}.
1492 \end{macrodesc}
1493
Fred Drakeadade921999-04-22 13:05:27 +00001494 \begin{macrodesc}{indexiv}{\p{word1}\p{word2}\p{word3}\p{word4}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001495 Build four index entries. This is exactly equivalent to using
1496 \code{\e index\{\var{word1}!\var{word2} \var{word3} \var{word4}\}},
1497 \code{\e index\{\var{word2}!\var{word3} \var{word4}, \var{word1}\}},
1498 \code{\e index\{\var{word3}!\var{word4}, \var{word1} \var{word2}\}},
1499 and
1500 \code{\e index\{\var{word4}!\var{word1} \var{word2} \var{word3}\}}.
1501 \end{macrodesc}
1502
Fred Drake432cef02001-07-06 22:34:33 +00001503 \subsection{Grammar Production Displays \label{grammar-displays}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001504
Fred Drake432cef02001-07-06 22:34:33 +00001505 Special markup is available for displaying the productions of a
1506 formal grammar. The markup is simple and does not attempt to
1507 model all aspects of BNF (or any derived forms), but provides
1508 enough to allow context-free grammars to be displayed in a way
1509 that causes uses of a symbol to be rendered as hyperlinks to the
1510 definition of the symbol. There is one environment and a pair of
1511 macros:
Fred Drakeacffaee1999-03-16 16:09:13 +00001512
Fred Drake432cef02001-07-06 22:34:33 +00001513 \begin{envdesc}{productionlist}{\op{language}}
1514 This environment is used to enclose a group of productions. The
1515 two macros are only defined within this environment. If a
1516 document descibes more than one language, the optional parameter
1517 \var{language} should be used to distinguish productions between
1518 languages. The value of the parameter should be a short name
1519 that can be used as part of a filename; colons or other
1520 characters that can't be used in filename across platforms
1521 should be included.
1522 \end{envdesc}
Fred Drakeacffaee1999-03-16 16:09:13 +00001523
Fred Drake432cef02001-07-06 22:34:33 +00001524 \begin{macrodesc}{production}{\p{name}\p{definition}}
1525 A production rule in the grammar. The rule defines the symbol
1526 \var{name} to be \var{definition}. \var{name} should not
1527 contain any markup, and the use of hyphens in a document which
1528 supports more than one grammar is undefined. \var{definition}
1529 may contain \macro{token} macros and any additional content
1530 needed to describe the grammatical model of \var{symbol}. Only
1531 one \macro{production} may be used to define a symbol ---
1532 multiple definitions are not allowed.
1533 \end{macrodesc}
Fred Drakeacffaee1999-03-16 16:09:13 +00001534
Fred Drake432cef02001-07-06 22:34:33 +00001535 \begin{macrodesc}{token}{\p{name}}
1536 The name of a symbol defined by a \macro{production} macro, used
1537 in the \var{definition} of a symbol. Where possible, this will
1538 be rendered as a hyperlink to the definition of the symbol
1539 \var{name}.
1540 \end{macrodesc}
Fred Drake42934682000-04-03 15:00:28 +00001541
Fred Drake432cef02001-07-06 22:34:33 +00001542 Note that the entire grammar does not need to be defined in a
1543 single \env{productionlist} environment; any number of
1544 groupings may be used to describe the grammar. Every use of the
1545 \macro{token} must correspond to a \macro{production}.
1546
1547 The following is an example taken from the
1548 \citetitle[../ref/identifiers.html]{Python Reference Manual}:
1549
1550\begin{verbatim}
1551\begin{productionlist}
1552 \production{identifier}
1553 {(\token{letter}|"_") (\token{letter} | \token{digit} | "_")*}
1554 \production{letter}
1555 {\token{lowercase} | \token{uppercase}}
1556 \production{lowercase}
1557 {"a"..."z"}
1558 \production{uppercase}
1559 {"A"..."Z"}
1560 \production{digit}
1561 {"0"..."9"}
1562\end{productionlist}
1563\end{verbatim}
1564
1565
Fred Drakef1b3de82001-07-24 14:38:34 +00001566\section{Graphical Interface Components \label{gui-markup}}
Fred Drake432cef02001-07-06 22:34:33 +00001567
1568 The components of graphical interfaces will be assigned markup, but
1569 the specifics have not been determined.
Fred Drakeacffaee1999-03-16 16:09:13 +00001570
1571
Fred Drakef1b3de82001-07-24 14:38:34 +00001572\section{Processing Tools \label{tools}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001573
Fred Drakef1b3de82001-07-24 14:38:34 +00001574 \subsection{External Tools \label{tools-external}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001575
1576 Many tools are needed to be able to process the Python
1577 documentation if all supported formats are required. This
Fred Drakeadade921999-04-22 13:05:27 +00001578 section lists the tools used and when each is required. Consult
1579 the \file{Doc/README} file to see if there are specific version
1580 requirements for any of these.
Fred Drakeacffaee1999-03-16 16:09:13 +00001581
1582 \begin{description}
1583 \item[\program{dvips}]
1584 This program is a typical part of \TeX{} installations. It is
1585 used to generate PostScript from the ``device independent''
Fred Drake2c4e0091999-03-29 14:55:55 +00001586 \file{.dvi} files. It is needed for the conversion to
Fred Drakeacffaee1999-03-16 16:09:13 +00001587 PostScript.
1588
1589 \item[\program{emacs}]
1590 Emacs is the kitchen sink of programmers' editors, and a damn
1591 fine kitchen sink it is. It also comes with some of the
1592 processing needed to support the proper menu structures for
1593 Texinfo documents when an info conversion is desired. This is
Fred Drake2c4e0091999-03-29 14:55:55 +00001594 needed for the info conversion. Using \program{xemacs}
Fred Drakeacffaee1999-03-16 16:09:13 +00001595 instead of FSF \program{emacs} may lead to instability in the
1596 conversion, but that's because nobody seems to maintain the
1597 Emacs Texinfo code in a portable manner.
1598
1599 \item[\program{latex}]
Fred Drakeb5f17f22001-08-28 18:09:11 +00001600 \LaTeX{} is a large and extensible macro package by Leslie
1601 Lamport, based on \TeX, a world-class typesetter by Donald
1602 Knuth. It is used for the conversion to PostScript, and is
1603 needed for the HTML conversion as well (\LaTeX2HTML requires
1604 one of the intermediate files it creates).
Fred Drakeacffaee1999-03-16 16:09:13 +00001605
1606 \item[\program{latex2html}]
1607 Probably the longest Perl script anyone ever attempted to
1608 maintain. This converts \LaTeX{} documents to HTML documents,
1609 and does a pretty reasonable job. It is required for the
1610 conversions to HTML and GNU info.
1611
1612 \item[\program{lynx}]
1613 This is a text-mode Web browser which includes an
1614 HTML-to-plain text conversion. This is used to convert
1615 \code{howto} documents to text.
1616
1617 \item[\program{make}]
1618 Just about any version should work for the standard documents,
1619 but GNU \program{make} is required for the experimental
1620 processes in \file{Doc/tools/sgmlconv/}, at least while
Fred Drakeb5f17f22001-08-28 18:09:11 +00001621 they're experimental. This is not required for running the
Fred Drakef9dc0432001-08-29 02:34:10 +00001622 \program{mkhowto} script.
Fred Drakeacffaee1999-03-16 16:09:13 +00001623
1624 \item[\program{makeindex}]
1625 This is a standard program for converting \LaTeX{} index data
1626 to a formatted index; it should be included with all \LaTeX{}
1627 installations. It is needed for the PDF and PostScript
1628 conversions.
1629
1630 \item[\program{makeinfo}]
1631 GNU \program{makeinfo} is used to convert Texinfo documents to
1632 GNU info files. Since Texinfo is used as an intermediate
1633 format in the info conversion, this program is needed in that
1634 conversion.
1635
1636 \item[\program{pdflatex}]
1637 pdf\TeX{} is a relatively new variant of \TeX, and is used to
1638 generate the PDF version of the manuals. It is typically
1639 installed as part of most of the large \TeX{} distributions.
Fred Drake7a737df1999-04-23 14:41:44 +00001640 \program{pdflatex} is pdf\TeX{} using the \LaTeX{} format.
Fred Drakeacffaee1999-03-16 16:09:13 +00001641
1642 \item[\program{perl}]
1643 Perl is required for \LaTeX2HTML{} and one of the scripts used
1644 to post-process \LaTeX2HTML output, as well as the
Fred Drake2c4e0091999-03-29 14:55:55 +00001645 HTML-to-Texinfo conversion. This is required for
Fred Drakeacffaee1999-03-16 16:09:13 +00001646 the HTML and GNU info conversions.
1647
1648 \item[\program{python}]
1649 Python is used for many of the scripts in the
1650 \file{Doc/tools/} directory; it is required for all
1651 conversions. This shouldn't be a problem if you're interested
1652 in writing documentation for Python!
1653 \end{description}
1654
1655
Fred Drakef1b3de82001-07-24 14:38:34 +00001656 \subsection{Internal Tools \label{tools-internal}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001657
1658 This section describes the various scripts that are used to
1659 implement various stages of document processing or to orchestrate
Fred Drake2c4e0091999-03-29 14:55:55 +00001660 entire build sequences. Most of these tools are only useful
Fred Drakeacffaee1999-03-16 16:09:13 +00001661 in the context of building the standard documentation, but some
1662 are more general.
1663
1664 \begin{description}
1665 \item[\program{mkhowto}]
Fred Drake87f768e1999-05-17 15:22:45 +00001666 This is the primary script used to format third-party
1667 documents. It contains all the logic needed to ``get it
1668 right.'' The proper way to use this script is to make a
1669 symbolic link to it or run it in place; the actual script file
1670 must be stored as part of the documentation source tree,
1671 though it may be used to format documents outside the
Fred Drakece444982000-04-11 18:52:52 +00001672 tree. Use \program{mkhowto} \longprogramopt{help}
Fred Draked290c101999-11-09 18:03:00 +00001673 for a list of
Fred Draked2a727f1999-05-27 21:45:54 +00001674 command line options.
Fred Drake87f768e1999-05-17 15:22:45 +00001675
Fred Draked1fb7791999-05-17 16:33:54 +00001676 \program{mkhowto} can be used for both \code{howto} and
1677 \code{manual} class documents. (For the later, be sure to get
1678 the latest version from the Python CVS repository rather than
1679 the version distributed in the \file{latex-1.5.2.tgz} source
1680 archive.)
1681
Fred Drake87f768e1999-05-17 15:22:45 +00001682 XXX Need more here.
Fred Drakeacffaee1999-03-16 16:09:13 +00001683 \end{description}
1684
1685
1686\section{Future Directions \label{futures}}
1687
1688 The history of the Python documentation is full of changes, most of
1689 which have been fairly small and evolutionary. There has been a
1690 great deal of discussion about making large changes in the markup
1691 languages and tools used to process the documentation. This section
1692 deals with the nature of the changes and what appears to be the most
1693 likely path of future development.
1694
1695 \subsection{Structured Documentation \label{structured}}
1696
1697 Most of the small changes to the \LaTeX{} markup have been made
1698 with an eye to divorcing the markup from the presentation, making
1699 both a bit more maintainable. Over the course of 1998, a large
1700 number of changes were made with exactly this in mind; previously,
1701 changes had been made but in a less systematic manner and with
1702 more concern for not needing to update the existing content. The
1703 result has been a highly structured and semantically loaded markup
1704 language implemented in \LaTeX. With almost no basic \TeX{} or
1705 \LaTeX{} markup in use, however, the markup syntax is about the
1706 only evidence of \LaTeX{} in the actual document sources.
1707
1708 One side effect of this is that while we've been able to use
1709 standard ``engines'' for manipulating the documents, such as
1710 \LaTeX{} and \LaTeX2HTML, most of the actual transformations have
Fred Drake7a737df1999-04-23 14:41:44 +00001711 been created specifically for Python. The \LaTeX{} document
1712 classes and \LaTeX2HTML support are both complete implementations
1713 of the specific markup designed for these documents.
Fred Drakeacffaee1999-03-16 16:09:13 +00001714
1715 Combining highly customized markup with the somewhat esoteric
1716 systems used to process the documents leads us to ask some
1717 questions: Can we do this more easily? and, Can we do this
1718 better? After a great deal of discussion with the community, we
1719 have determined that actively pursuing modern structured
Fred Drake2c4e0091999-03-29 14:55:55 +00001720 documentation systems is worth some investment of time.
Fred Drakeacffaee1999-03-16 16:09:13 +00001721
1722 There appear to be two real contenders in this arena: the Standard
1723 General Markup Language (SGML), and the Extensible Markup Language
1724 (XML). Both of these standards have advantages and disadvantages,
1725 and many advantages are shared.
1726
1727 SGML offers advantages which may appeal most to authors,
1728 especially those using ordinary text editors. There are also
1729 additional abilities to define content models. A number of
Fred Drake67f193f2001-07-09 16:04:03 +00001730 high-quality tools with demonstrated maturity are available, but
Fred Drakeacffaee1999-03-16 16:09:13 +00001731 most are not free; for those which are, portability issues remain
1732 a problem.
1733
1734 The advantages of XML include the availability of a large number
1735 of evolving tools. Unfortunately, many of the associated
1736 standards are still evolving, and the tools will have to follow
1737 along. This means that developing a robust tool set that uses
1738 more than the basic XML 1.0 recommendation is not possible in the
1739 short term. The promised availability of a wide variety of
1740 high-quality tools which support some of the most important
1741 related standards is not immediate. Many tools are likely to be
Fred Drake67f193f2001-07-09 16:04:03 +00001742 free, and the portability issues of those which are, are not
1743 expected to be significant.
Fred Drakeacffaee1999-03-16 16:09:13 +00001744
Fred Drake67f193f2001-07-09 16:04:03 +00001745 It turns out that converting to an XML or SGML system holds
1746 promise for translators as well; how much can be done to ease the
1747 burden on translators remains to be seen, and may have some impact
1748 on the schema and specific technologies used.
1749
1750 XXX Eventual migration to XML.
1751
1752 The documentation will be moved to XML in the future, and tools
1753 are being written which will convert the documentation from the
1754 current format to something close to a finished version, to the
1755 extent that the desired information is already present in the
1756 documentation. Some XSLT stylesheets have been started for
1757 presenting a preliminary XML version as HTML, but the results are
1758 fairly rough..
1759
1760 The timeframe for the conversion is not clear since there doesn't
1761 seem to be much time available to work on this, but the appearant
1762 benefits are growing more substantial at a moderately rapid pace.
1763
Fred Drakeacffaee1999-03-16 16:09:13 +00001764
1765 \subsection{Discussion Forums \label{discussion}}
1766
1767 Discussion of the future of the Python documentation and related
Fred Drake7a737df1999-04-23 14:41:44 +00001768 topics takes place in the Documentation Special Interest Group, or
1769 ``Doc-SIG.'' Information on the group, including mailing list
1770 archives and subscription information, is available at
Fred Drakeacffaee1999-03-16 16:09:13 +00001771 \url{http://www.python.org/sigs/doc-sig/}. The SIG is open to all
1772 interested parties.
1773
1774 Comments and bug reports on the standard documents should be sent
1775 to \email{python-docs@python.org}. This may include comments
Fred Drakeadade921999-04-22 13:05:27 +00001776 about formatting, content, grammatical and spelling errors, or
Fred Draked1fb7791999-05-17 16:33:54 +00001777 this document. You can also send comments on this document
1778 directly to the author at \email{fdrake@acm.org}.
Fred Drakeacffaee1999-03-16 16:09:13 +00001779
1780\end{document}