blob: 7069f2f6d6c410c868eb95f29303c90ddea2382c [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 \\
14 E-mail: \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
41\section{Introduction}
42
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
74\section{Directory Structure}
75
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 Drake432cef02001-07-06 22:34:33 +0000156\section{Style Guide}
157
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
173 past their usefulness. In the current markup, these entities are
174 not assigned any special markup, but the preferred spellings are
175 given here to aid authors in maintaining the consistency of
176 presentation in the Python documentation.
177
178 \begin{description}
179 \item[POSIX]
180 The name assigned to a particular group of standards. This is
181 always uppercase.
182
183 \item[Python]
184 The name of our favorite programming language is always
185 capitalized.
186
187 \item[Unicode]
188 The name of a character set and matching encoding. This is
189 always written capitalized.
190 \end{description}
191
192
Fred Drakeadade921999-04-22 13:05:27 +0000193\section{\LaTeX{} Primer \label{latex-primer}}
Fred Drake2c4e0091999-03-29 14:55:55 +0000194
Fred Drakeadade921999-04-22 13:05:27 +0000195 This section is a brief introduction to \LaTeX{} concepts and
196 syntax, to provide authors enough information to author documents
197 productively without having to become ``\TeX{}nicians.''
198
Fred Drake5eb992b1999-06-11 14:25:45 +0000199 Perhaps the most important concept to keep in mind while marking up
Fred Drake02997492000-09-21 05:26:43 +0000200 Python documentation is that while \TeX{} is unstructured, \LaTeX{} was
Fred Drake5eb992b1999-06-11 14:25:45 +0000201 designed as a layer on top of \TeX{} which specifically supports
202 structured markup. The Python-specific markup is intended to extend
203 the structure provided by standard \LaTeX{} document classes to
204 support additional information specific to Python.
205
Fred Drakeadade921999-04-22 13:05:27 +0000206 \LaTeX{} documents contain two parts: the preamble and the body.
207 The preamble is used to specify certain metadata about the document
208 itself, such as the title, the list of authors, the date, and the
209 \emph{class} the document belongs to. Additional information used
210 to control index generation and the use of bibliographic databases
Fred Drake7a737df1999-04-23 14:41:44 +0000211 can also be placed in the preamble. For most authors, the preamble
Fred Drakeadade921999-04-22 13:05:27 +0000212 can be most easily created by copying it from an existing document
213 and modifying a few key pieces of information.
214
215 The \dfn{class} of a document is used to place a document within a
216 broad category of documents and set some fundamental formatting
217 properties. For Python documentation, two classes are used: the
218 \code{manual} class and the \code{howto} class. These classes also
219 define the additional markup used to document Python concepts and
220 structures. Specific information about these classes is provided in
Fred Drake7a737df1999-04-23 14:41:44 +0000221 section \ref{classes}, ``Document Classes,'' below. The first thing
Fred Drakeadade921999-04-22 13:05:27 +0000222 in the preamble is the declaration of the document's class.
223
224 After the class declaration, a number of \emph{macros} are used to
225 provide further information about the document and setup any
Fred Drake7a737df1999-04-23 14:41:44 +0000226 additional markup that is needed. No output is generated from the
227 preamble; it is an error to include free text in the preamble
228 because it would cause output.
Fred Drakeadade921999-04-22 13:05:27 +0000229
230 The document body follows the preamble. This contains all the
Fred Drake63568aa2000-10-19 05:36:10 +0000231 printed components of the document marked up structurally. Generic
Fred Drake4c6f17a2001-04-18 05:12:47 +0000232 \LaTeX{} structures include hierarchical sections, numbered and
233 bulleted lists, and special structures for the document abstract and
234 indexes.
Fred Drakeadade921999-04-22 13:05:27 +0000235
Fred Drake63568aa2000-10-19 05:36:10 +0000236 \subsection{Syntax}
237
Fred Drake4c6f17a2001-04-18 05:12:47 +0000238 There are some things that an author of Python documentation needs
239 to know about \LaTeX{} syntax.
Fred Drake63568aa2000-10-19 05:36:10 +0000240
241 A \dfn{comment} is started by the ``percent'' character
242 (\character{\%}) and continues through the end of the line and all
243 leading whitespace on the following line. This is a little
244 different from any programming language I know of, so an example
245 is in order:
246
247\begin{verbatim}
248This is text.% comment
249 This is more text. % another comment
250Still more text.
251\end{verbatim}
252
253 The first non-comment character following the first comment is the
254 letter \character{T} on the second line; the leading whitespace on
255 that line is consumed as part of the first comment. This means
256 that there is no space between the first and second sentences, so
257 the period and letter \character{T} will be directly adjacent in
258 the typeset document.
259
260 Note also that though the first non-comment character after the
261 second comment is the letter \character{S}, there is whitespace
262 preceding the comment, so the two sentences are separated as
263 expected.
264
265 A \dfn{group} is an enclosure for a collection of text and
266 commands which encloses the formatting context and constrains the
267 scope of any changes to that context made by commands within the
268 group. Groups can be nested hierarchically. The formatting
269 context includes the font and the definition of additional macros
270 (or overrides of macros defined in outer groups). Syntactically,
271 groups are enclosed in braces:
272
273\begin{verbatim}
274{text in a group}
275\end{verbatim}
276
Fred Drake4c6f17a2001-04-18 05:12:47 +0000277 An alternate syntax for a group using brackets, \code{[...]}, is
Fred Drake63568aa2000-10-19 05:36:10 +0000278 used by macros and environment constructors which take optional
279 parameters; brackets do not normally hold syntactic significance.
280 A degenerate group, containing only one atomic bit of content,
281 does not need to have an explicit group, unless it is required to
282 avoid ambiguity. Since Python tends toward the explicit, groups
283 are also made explicit in the documentation markup.
284
285 Groups are used only sparingly in the Python documentation, except
286 for their use in marking parameters to macros and environments.
287
Fred Drake4c6f17a2001-04-18 05:12:47 +0000288 A \dfn{macro} is usually a simple construct which is identified by
Fred Drake63568aa2000-10-19 05:36:10 +0000289 name and can take some number of parameters. In normal \LaTeX{}
290 usage, one of these can be optional. The markup is introduced
291 using the backslash character (\character{\e}), and the name is
292 given by alphabetic characters (no digits, hyphens, or
293 underscores). Required parameters should be marked as a group,
294 and optional parameters should be marked using the alternate
295 syntax for a group.
296
297 For example, a macro named ``foo'' which takes a single parameter
298 would appear like this:
299
300\begin{verbatim}
301\name{parameter}
302\end{verbatim}
303
304 A macro which takes an optional parameter would be typed like this
305 when the optional paramter is given:
306
307\begin{verbatim}
308\name[optional]
309\end{verbatim}
310
311 If both optional and required parameters are to be required, it
312 looks like this:
313
314\begin{verbatim}
315\name[optional]{required}
316\end{verbatim}
317
318 A macro name may be followed by a space or newline; a space
319 between the macro name and any parameters will be consumed, but
320 this usage is not practiced in the Python documentation. Such a
Fred Drake4c6f17a2001-04-18 05:12:47 +0000321 space is still consumed if there are no parameters to the macro,
Fred Drake63568aa2000-10-19 05:36:10 +0000322 in which case inserting an empty group (\code{\{\}}) or explicit
323 word space (\samp{\e\ }) immediately after the macro name helps to
324 avoid running the expansion of the macro into the following text.
325 Macros which take no parameters but which should not be followed
326 by a word space do not need special treatment if the following
327 character in the document source if not a name character (such as
Fred Drake4c6f17a2001-04-18 05:12:47 +0000328 punctuation).
Fred Drake63568aa2000-10-19 05:36:10 +0000329
330 Each line of this example shows an appropriate way to write text
331 which includes a macro which takes no parameters:
332
333\begin{verbatim}
334This \UNIX{} is followed by a space.
335This \UNIX\ is also followed by a space.
336\UNIX, followed by a comma, needs no additional markup.
337\end{verbatim}
338
Fred Draked097d482000-10-20 20:51:31 +0000339 An \dfn{environment} is a larger construct than a macro, and can
Fred Drake4c6f17a2001-04-18 05:12:47 +0000340 be used for things with more content than would conveniently fit
Fred Draked097d482000-10-20 20:51:31 +0000341 in a macro parameter. They are primarily used when formatting
342 parameters need to be changed before and after a large chunk of
343 content, but the content itself needs to be highly flexible. Code
344 samples are presented using an environment, and descriptions of
Fred Drake4c6f17a2001-04-18 05:12:47 +0000345 functions, methods, and classes are also marked using environments.
Fred Draked097d482000-10-20 20:51:31 +0000346
347 Since the content of an environment is free-form and can consist
348 of several paragraphs, they are actually marked using a pair of
349 macros: \macro{begin} and \macro{end}. These macros both take the
350 name of the environment as a parameter. An example is the
351 environment used to mark the abstract of a document:
352
353\begin{verbatim}
354\begin{abstract}
355 This is the text of the abstract. It concisely explains what
356 information is found in the document.
357
358 It can consist of multiple paragraphs.
359\end{abstract}
360\end{verbatim}
361
362 An environment can also have required and optional parameters of
363 its own. These follow the parameter of the \macro{begin} macro.
364 This example shows an environment which takes a single required
365 parameter:
366
367\begin{verbatim}
Fred Drake2bbc6972001-03-28 16:51:20 +0000368\begin{datadesc}{controlnames}
Fred Draked097d482000-10-20 20:51:31 +0000369 A 33-element string array that contains the \ASCII{} mnemonics for
370 the thirty-two \ASCII{} control characters from 0 (NUL) to 0x1f
371 (US), in order, plus the mnemonic \samp{SP} for the space character.
372\end{datadesc}
373\end{verbatim}
Fred Drake63568aa2000-10-19 05:36:10 +0000374
Fred Drake4c6f17a2001-04-18 05:12:47 +0000375 There are a number of less-used marks in \LaTeX{} which are used
376 to enter non-\ASCII{} characters, especially those used in
377 European names. Given that these are often used adjacent to other
Fred Draked097d482000-10-20 20:51:31 +0000378 characters, the markup required to produce the proper character
Fred Drake4c6f17a2001-04-18 05:12:47 +0000379 may need to be followed by a space or an empty group, or the
Fred Draked097d482000-10-20 20:51:31 +0000380 markup can be enclosed in a group. Some which are found in Python
381 documentation are:
Fred Drake63568aa2000-10-19 05:36:10 +0000382
Fred Draked097d482000-10-20 20:51:31 +0000383\begin{tableii}{c|l}{textrm}{Character}{Markup}
384 \lineii{\c c}{\code{\e c c}}
385 \lineii{\"o}{\code{\e"o}}
386 \lineii{\o}{\code{\e o}}
387\end{tableii}
Fred Drake63568aa2000-10-19 05:36:10 +0000388
389
390 \subsection{Hierarchical Structure}
391
Fred Draked097d482000-10-20 20:51:31 +0000392 \LaTeX{} expects documents to be arranged in a conventional,
393 hierarchical way, with chapters, sections, sub-sections,
394 appendixes, and the like. These are marked using macros rather
395 than environments, probably because the end of a section can be
396 safely inferred when a section of equal or higher level starts.
397
398 There are six ``levels'' of sectioning in the document classes
Fred Drake4c6f17a2001-04-18 05:12:47 +0000399 used for Python documentation, and the deepest two
400 levels\footnote{The deepest levels have the highest numbers in the
401 table.} are not used. The levels are:
Fred Draked097d482000-10-20 20:51:31 +0000402
403 \begin{tableiii}{c|l|c}{textrm}{Level}{Macro Name}{Notes}
404 \lineiii{1}{\macro{chapter}}{(1)}
405 \lineiii{2}{\macro{section}}{}
406 \lineiii{3}{\macro{subsection}}{}
Fred Drakeb7a52c92000-11-27 20:10:18 +0000407 \lineiii{4}{\macro{subsubsection}}{}
Fred Draked097d482000-10-20 20:51:31 +0000408 \lineiii{5}{\macro{paragraph}}{(2)}
409 \lineiii{6}{\macro{subparagraph}}{}
410 \end{tableiii}
411
412 \noindent
413 Notes:
414
415 \begin{description}
416 \item[(1)]
417 Only used for the \code{manual} documents, as described in
418 section \ref{classes}, ``Document Classes.''
419 \item[(2)]
420 Not the same as a paragraph of text; nobody seems to use this.
421 \end{description}
Fred Drake2c4e0091999-03-29 14:55:55 +0000422
423
Fred Drakeadade921999-04-22 13:05:27 +0000424\section{Document Classes \label{classes}}
Fred Drakeacffaee1999-03-16 16:09:13 +0000425
426 Two \LaTeX{} document classes are defined specifically for use with
427 the Python documentation. The \code{manual} class is for large
428 documents which are sectioned into chapters, and the \code{howto}
429 class is for smaller documents.
430
431 The \code{manual} documents are larger and are used for most of the
432 standard documents. This document class is based on the standard
433 \LaTeX{} \code{report} class and is formatted very much like a long
Fred Drake698d5201999-11-10 15:54:57 +0000434 technical report. The \citetitle[../ref/ref.html]{Python Reference
435 Manual} is a good example of a \code{manual} document, and the
436 \citetitle[../lib/lib.html]{Python Library Reference} is a large
437 example.
Fred Drakeacffaee1999-03-16 16:09:13 +0000438
439 The \code{howto} documents are shorter, and don't have the large
440 structure of the \code{manual} documents. This class is based on
441 the standard \LaTeX{} \code{article} class and is formatted somewhat
442 like the Linux Documentation Project's ``HOWTO'' series as done
443 originally using the LinuxDoc software. The original intent for the
444 document class was that it serve a similar role as the LDP's HOWTO
445 series, but the applicability of the class turns out to be somewhat
Fred Drake02997492000-09-21 05:26:43 +0000446 broader. This class is used for ``how-to'' documents (this
Fred Drakeacffaee1999-03-16 16:09:13 +0000447 document is an example) and for shorter reference manuals for small,
448 fairly cohesive module libraries. Examples of the later use include
Fred Drake698d5201999-11-10 15:54:57 +0000449 the standard \citetitle[../mac/mac.html]{Macintosh Library Modules}
450 and
Fred Drake6a547c72000-09-15 22:11:24 +0000451\citetitle[http://starship.python.net/crew/fdrake/manuals/krb5py/krb5py.html]{Using
Fred Drakeacffaee1999-03-16 16:09:13 +0000452 Kerberos from Python}, which contains reference material for an
453 extension package. These documents are roughly equivalent to a
454 single chapter from a larger work.
455
456
Fred Drake7a737df1999-04-23 14:41:44 +0000457\section{Special Markup Constructs}
Fred Drakeacffaee1999-03-16 16:09:13 +0000458
Fred Drake2c4e0091999-03-29 14:55:55 +0000459 The Python document classes define a lot of new environments and
460 macros. This section contains the reference material for these
461 facilities.
462
Fred Drakeaf2b7142000-09-14 20:11:05 +0000463 \subsection{Markup for the Preamble \label{preamble-info}}
464
465 \begin{macrodesc}{release}{\p{ver}}
466 Set the version number for the software described in the
467 document.
468 \end{macrodesc}
469
470 \begin{macrodesc}{setshortversion}{\p{sver}}
471 Specify the ``short'' version number of the documented software
472 to be \var{sver}.
473 \end{macrodesc}
474
Fred Drakee15956b2000-04-03 04:51:13 +0000475 \subsection{Meta-information Markup \label{meta-info}}
476
477 \begin{macrodesc}{sectionauthor}{\p{author}\p{email}}
478 Identifies the author of the current section. \var{author}
479 should be the author's name such that it can be used for
480 presentation (though it isn't), and \var{email} should be the
481 author's email address. The domain name portion of
482 the address should be lower case.
483
484 No presentation is generated from this markup, but it is used to
485 help keep track of contributions.
486 \end{macrodesc}
487
Fred Drakeacffaee1999-03-16 16:09:13 +0000488 \subsection{Information Units \label{info-units}}
489
Fred Drake2f4bebd1999-04-28 16:43:11 +0000490 XXX Explain terminology, or come up with something more ``lay.''
Fred Drakeacffaee1999-03-16 16:09:13 +0000491
Fred Drakeadade921999-04-22 13:05:27 +0000492 There are a number of environments used to describe specific
493 features provided by modules. Each environment requires
494 parameters needed to provide basic information about what is being
495 described, and the environment content should be the description.
496 Most of these environments make entries in the general index (if
497 one is being produced for the document); if no index entry is
498 desired, non-indexing variants are available for many of these
499 environments. The environments have names of the form
500 \code{\var{feature}desc}, and the non-indexing variants are named
501 \code{\var{feature}descni}. The available variants are explicitly
502 included in the list below.
503
504 For each of these environments, the first parameter, \var{name},
505 provides the name by which the feature is accessed.
506
507 Environments which describe features of objects within a module,
508 such as object methods or data attributes, allow an optional
509 \var{type name} parameter. When the feature is an attribute of
510 class instances, \var{type name} only needs to be given if the
511 class was not the most recently described class in the module; the
512 \var{name} value from the most recent \env{classdesc} is implied.
513 For features of built-in or extension types, the \var{type name}
Fred Drake7a737df1999-04-23 14:41:44 +0000514 value should always be provided. Another special case includes
515 methods and members of general ``protocols,'' such as the
516 formatter and writer protocols described for the
517 \module{formatter} module: these may be documented without any
518 specific implementation classes, and will always require the
519 \var{type name} parameter to be provided.
Fred Drakeadade921999-04-22 13:05:27 +0000520
Fred Drake7be440d2000-09-16 21:23:25 +0000521 \begin{envdesc}{cfuncdesc}{\p{type}\p{name}\p{args}}
522 Environment used to described a C function. The \var{type}
523 should be specified as a \keyword{typedef} name, \code{struct
524 \var{tag}}, or the name of a primitive type. If it is a pointer
Fred Drake02997492000-09-21 05:26:43 +0000525 type, the trailing asterisk should not be preceded by a space.
Fred Drake7be440d2000-09-16 21:23:25 +0000526 \var{name} should be the name of the function (or function-like
527 pre-processor macro), and \var{args} should give the types and
528 names of the parameters. The names need to be given so they may
529 be used in the description.
530 \end{envdesc}
531
532 \begin{envdesc}{ctypedesc}{\op{tag}\p{name}}
533 Environment used to described a C type. The \var{name}
534 parameter should be the \keyword{typedef} name. If the type is
535 defined as a \keyword{struct} without a \keyword{typedef},
536 \var{name} should have the form \code{struct \var{tag}}.
537 \var{name} will be added to the index unless \var{tag} is
538 provided, in which case \var{tag} will be used instead.
539 \var{tag} should not be used for a \keyword{typedef} name.
540 \end{envdesc}
541
542 \begin{envdesc}{cvardesc}{\p{type}\p{name}}
543 Description of a global C variable. \var{type} should be the
544 \keyword{typedef} name, \code{struct \var{tag}}, or the name of
545 a primitive type. If variable has a pointer type, the trailing
Fred Drake02997492000-09-21 05:26:43 +0000546 asterisk should \emph{not} be preceded by a space.
Fred Drake7be440d2000-09-16 21:23:25 +0000547 \end{envdesc}
548
Fred Drakeadade921999-04-22 13:05:27 +0000549 \begin{envdesc}{datadesc}{\p{name}}
550 This environment is used to document global data in a module,
551 including both variables and values used as ``defined
552 constants.'' Class and object attributes are not documented
553 using this environment.
Fred Drakeacffaee1999-03-16 16:09:13 +0000554 \end{envdesc}
Fred Drake7a737df1999-04-23 14:41:44 +0000555 \begin{envdesc}{datadescni}{\p{name}}
Fred Drakeacffaee1999-03-16 16:09:13 +0000556 Like \env{datadesc}, but without creating any index entries.
557 \end{envdesc}
558
Fred Drake9f2376d2001-05-11 01:01:12 +0000559 \begin{envdesc}{excclassdesc}{\p{name}\p{constructor parameters}}
560 Descibe an exception defined by a class. \var{constructor
561 parameters} should not include the \var{self} parameter or
562 the parentheses used in the call syntax. To describe an
563 exception class without describing the parameters to its
564 constructor, use the \env{excdesc} environment.
565 \end{envdesc}
566
Fred Drakeadade921999-04-22 13:05:27 +0000567 \begin{envdesc}{excdesc}{\p{name}}
Fred Drakeacffaee1999-03-16 16:09:13 +0000568 Describe an exception. This may be either a string exception or
Fred Drake9f2376d2001-05-11 01:01:12 +0000569 a class exception. In the case of class exceptions, the
570 constructor parameters are not described; use \env{excclassdesc}
571 to describe an exception class and its constructor.
Fred Drakeacffaee1999-03-16 16:09:13 +0000572 \end{envdesc}
573
Fred Drakeadade921999-04-22 13:05:27 +0000574 \begin{envdesc}{funcdesc}{\p{name}\p{parameters}}
575 Describe a module-level function. \var{parameters} should
576 not include the parentheses used in the call syntax. Object
577 methods are not documented using this environment. Bound object
578 methods placed in the module namespace as part of the public
579 interface of the module are documented using this, as they are
580 equivalent to normal functions for most purposes.
581
582 The description should include information about the parameters
583 required and how they are used (especially whether mutable
584 objects passed as parameters are modified), side effects, and
585 possible exceptions. A small example may be provided.
Fred Drakeacffaee1999-03-16 16:09:13 +0000586 \end{envdesc}
Fred Drakeadade921999-04-22 13:05:27 +0000587 \begin{envdesc}{funcdescni}{\p{name}\p{parameters}}
Fred Drakeacffaee1999-03-16 16:09:13 +0000588 Like \env{funcdesc}, but without creating any index entries.
589 \end{envdesc}
590
Fred Drakeadade921999-04-22 13:05:27 +0000591 \begin{envdesc}{classdesc}{\p{name}\p{constructor parameters}}
592 Describe a class and its constructor. \var{constructor
593 parameters} should not include the \var{self} parameter or
594 the parentheses used in the call syntax.
Fred Drakeacffaee1999-03-16 16:09:13 +0000595 \end{envdesc}
596
Fred Drake9f2376d2001-05-11 01:01:12 +0000597 \begin{envdesc}{classdesc*}{\p{name}}
598 Describe a class without describing the constructor. This can
599 be used to describe classes that are merely containers for
600 attributes or which should never be instantiated or subclassed
601 by user code.
602 \end{envdesc}
603
Fred Drakeadade921999-04-22 13:05:27 +0000604 \begin{envdesc}{memberdesc}{\op{type name}\p{name}}
605 Describe an object data attribute. The description should
606 include information about the type of the data to be expected
607 and whether it may be changed directly.
Fred Drakeacffaee1999-03-16 16:09:13 +0000608 \end{envdesc}
Fred Drakeadade921999-04-22 13:05:27 +0000609 \begin{envdesc}{memberdescni}{\op{type name}\p{name}}
Fred Drakeacffaee1999-03-16 16:09:13 +0000610 Like \env{memberdesc}, but without creating any index entries.
611 \end{envdesc}
612
Fred Drakeadade921999-04-22 13:05:27 +0000613 \begin{envdesc}{methoddesc}{\op{type name}\p{name}\p{parameters}}
614 Describe an object method. \var{parameters} should not include
615 the \var{self} parameter or the parentheses used in the call
616 syntax. The description should include similar information to
617 that described for \env{funcdesc}.
Fred Drakeacffaee1999-03-16 16:09:13 +0000618 \end{envdesc}
Fred Drakeadade921999-04-22 13:05:27 +0000619 \begin{envdesc}{methoddescni}{\op{type name}\p{name}\p{parameters}}
Fred Drakeacffaee1999-03-16 16:09:13 +0000620 Like \env{methoddesc}, but without creating any index entries.
621 \end{envdesc}
622
623
Fred Drake5eb992b1999-06-11 14:25:45 +0000624 \subsection{Showing Code Examples}
625
626 Examples of Python source code or interactive sessions are
627 represented as \env{verbatim} environments. This environment
628 is a standard part of \LaTeX{}. It is important to only use
629 spaces for indentation in code examples since \TeX{} drops tabs
630 instead of converting them to spaces.
631
632 Representing an interactive session requires including the prompts
633 and output along with the Python code. No special markup is
Fred Drake63568aa2000-10-19 05:36:10 +0000634 required for interactive sessions. After the last line of input
635 or output presented, there should not be an ``unused'' primary
636 prompt; this is an example of what \emph{not} to do:
637
638\begin{verbatim}
639>>> 1 + 1
6402
641>>>
642\end{verbatim}
Fred Drake5eb992b1999-06-11 14:25:45 +0000643
644 Within the \env{verbatim} environment, characters special to
645 \LaTeX{} do not need to be specially marked in any way. The entire
646 example will be presented in a monospaced font; no attempt at
647 ``pretty-printing'' is made, as the environment must work for
Fred Drake63568aa2000-10-19 05:36:10 +0000648 non-Python code and non-code displays. There should be no blank
649 lines at the top or bottom of any \env{verbatim} display.
Fred Drake5eb992b1999-06-11 14:25:45 +0000650
Fred Drake66eed242001-06-18 14:59:58 +0000651 Longer displays of verbatim text may be included by storing the
652 example text in an external file containing only plain text. The
653 file may be included using the standard \macro{verbatiminput}
654 macro; this macro takes a single argument naming the file
655 containing the text. For example, to include the Python source
656 file \file{example.py}, use:
657
658\begin{verbatim}
659\verbatiminput{example.py}
660\end{verbatim}
661
662 Use of \macro{verbatiminput} allows easier use of special editing
663 modes for the included file. The file should be placed in the
664 same directory as the \LaTeX{} files for the document.
665
Fred Drake5eb992b1999-06-11 14:25:45 +0000666 The Python Documentation Special Interest Group has discussed a
667 number of approaches to creating pretty-printed code displays and
668 interactive sessions; see the Doc-SIG area on the Python Web site
669 for more information on this topic.
670
671
Fred Drakeacffaee1999-03-16 16:09:13 +0000672 \subsection{Inline Markup}
673
Fred Drake87f768e1999-05-17 15:22:45 +0000674 The macros described in this section are used to mark just about
675 anything interesting in the document text. They may be used in
676 headings (though anything involving hyperlinks should be avoided
677 there) as well as in the body text.
Fred Drake2f4bebd1999-04-28 16:43:11 +0000678
679 \begin{macrodesc}{bfcode}{\p{text}}
680 Like \macro{code}, but also makes the font bold-face.
681 \end{macrodesc}
682
683 \begin{macrodesc}{cdata}{\p{name}}
684 The name of a C-language variable.
685 \end{macrodesc}
686
687 \begin{macrodesc}{cfunction}{\p{name}}
688 The name of a C-language function. \var{name} should include the
689 function name and the trailing parentheses.
690 \end{macrodesc}
691
692 \begin{macrodesc}{character}{\p{char}}
693 A character when discussing the character rather than a one-byte
694 string value. The character will be typeset as with \macro{samp}.
695 \end{macrodesc}
696
Fred Drake29a710f1999-11-10 22:51:18 +0000697 \begin{macrodesc}{citetitle}{\op{url}\p{title}}
698 A title for a referenced publication. If \var{url} is specified,
699 the title will be made into a hyperlink when formatted as HTML.
700 \end{macrodesc}
701
Fred Drake2f4bebd1999-04-28 16:43:11 +0000702 \begin{macrodesc}{class}{\p{name}}
703 A class name; a dotted name may be used.
704 \end{macrodesc}
705
706 \begin{macrodesc}{code}{\p{text}}
707 A short code fragment or literal constant value. Typically, it
708 should not include any spaces since no quotation marks are
709 added.
710 \end{macrodesc}
711
712 \begin{macrodesc}{constant}{\p{name}}
713 The name of a ``defined'' constant. This may be a C-language
714 \code{\#define} or a Python variable that is not intended to be
715 changed.
716 \end{macrodesc}
717
718 \begin{macrodesc}{ctype}{\p{name}}
719 The name of a C \keyword{typedef} or structure. For structures
720 defined without a \keyword{typedef}, use \code{\e ctype\{struct
721 struct_tag\}} to make it clear that the \keyword{struct} is
722 required.
723 \end{macrodesc}
724
725 \begin{macrodesc}{deprecated}{\p{version}\p{what to do}}
726 Declare whatever is being described as being deprecated starting
727 with release \var{version}. The text given as \var{what to do}
728 should recommend something to use instead.
729 \end{macrodesc}
730
731 \begin{macrodesc}{dfn}{\p{term}}
732 Mark the defining instance of \var{term} in the text. (No index
733 entries are generated.)
734 \end{macrodesc}
735
Fred Draked1fb7791999-05-17 16:33:54 +0000736 \begin{macrodesc}{e}{}
737 Produces a backslash. This is convenient in \macro{code} and
Fred Drake31edf4d2000-09-07 20:06:07 +0000738 similar macros, and is only defined there. To create a
Fred Drake2b853412000-04-11 19:08:30 +0000739 backslash in ordinary text (such as the contents of the
740 \macro{file} macro), use the standard \macro{textbackslash} macro.
Fred Draked1fb7791999-05-17 16:33:54 +0000741 \end{macrodesc}
742
Fred Drake2f4bebd1999-04-28 16:43:11 +0000743 \begin{macrodesc}{email}{\p{address}}
744 An email address. Note that this is \emph{not} hyperlinked in
Fred Drakee15956b2000-04-03 04:51:13 +0000745 any of the possible output formats. The domain name portion of
746 the address should be lower case.
Fred Drake2f4bebd1999-04-28 16:43:11 +0000747 \end{macrodesc}
748
749 \begin{macrodesc}{emph}{\p{text}}
750 Emphasized text; this will be presented in an italic font.
751 \end{macrodesc}
752
753 \begin{macrodesc}{envvar}{\p{name}}
754 An environment variable. Index entries are generated.
755 \end{macrodesc}
756
757 \begin{macrodesc}{exception}{\p{name}}
758 The name of an exception. A dotted name may be used.
759 \end{macrodesc}
760
761 \begin{macrodesc}{file}{\p{file or dir}}
762 The name of a file or directory. In the PDF and PostScript
763 outputs, single quotes and a font change are used to indicate
764 the file name, but no quotes are used in the HTML output.
Fred Drake31edf4d2000-09-07 20:06:07 +0000765 \strong{Warning:} The \macro{file} macro cannot be used in the
766 content of a section title due to processing limitations.
Fred Drake2f4bebd1999-04-28 16:43:11 +0000767 \end{macrodesc}
768
769 \begin{macrodesc}{filenq}{\p{file or dir}}
770 Like \macro{file}, but single quotes are never used. This can
771 be used in conjunction with tables if a column will only contain
772 file or directory names.
Fred Drake31edf4d2000-09-07 20:06:07 +0000773 \strong{Warning:} The \macro{filenq} macro cannot be used in the
774 content of a section title due to processing limitations.
Fred Drake2f4bebd1999-04-28 16:43:11 +0000775 \end{macrodesc}
776
777 \begin{macrodesc}{function}{\p{name}}
778 The name of a Python function; dotted names may be used.
779 \end{macrodesc}
780
Fred Drake432cef02001-07-06 22:34:33 +0000781 \begin{macrodesc}{infinity}{}
782 The symbol for mathematical infinity: \infinity. Some Web
783 browsers are not able to render the HTML representation of this
784 symbol properly, but support is growing.
785 \end{macrodesc}
786
Fred Drake2f4bebd1999-04-28 16:43:11 +0000787 \begin{macrodesc}{kbd}{\p{key sequence}}
788 Mark a sequence of keystrokes. What form \var{key sequence}
789 takes may depend on platform- or application-specific
790 conventions. For example, an \program{xemacs} key sequence
791 may be marked like \code{\e kbd\{C-x C-f\}}.
792 \end{macrodesc}
793
794 \begin{macrodesc}{keyword}{\p{name}}
795 The name of a keyword in a programming language.
796 \end{macrodesc}
797
798 \begin{macrodesc}{makevar}{\p{name}}
799 The name of a \program{make} variable.
800 \end{macrodesc}
801
802 \begin{macrodesc}{manpage}{\p{name}\p{section}}
803 A reference to a \UNIX{} manual page.
804 \end{macrodesc}
805
806 \begin{macrodesc}{member}{\p{name}}
807 The name of a data attribute of an object.
808 \end{macrodesc}
809
810 \begin{macrodesc}{method}{\p{name}}
811 The name of a method of an object. \var{name} should include the
812 method name and the trailing parentheses. A dotted name may be
813 used.
814 \end{macrodesc}
815
816 \begin{macrodesc}{mimetype}{\p{name}}
817 The name of a MIME type.
818 \end{macrodesc}
819
820 \begin{macrodesc}{module}{\p{name}}
Fred Drake2b853412000-04-11 19:08:30 +0000821 The name of a module; a dotted name may be used. This should
822 also be used for package names.
Fred Drake2f4bebd1999-04-28 16:43:11 +0000823 \end{macrodesc}
824
825 \begin{macrodesc}{newsgroup}{\p{name}}
826 The name of a USENET newsgroup.
827 \end{macrodesc}
828
Fred Drake432cef02001-07-06 22:34:33 +0000829 \begin{macrodesc}{pep}{\p{number}}
830 A reference to a Python Enhancement Proposal. This generates
831 appropriate index entries. The text \samp{PEP \var{number}} is
832 generated; in the HTML output, this text is a hyperlink to an
833 online copy of the specified PEP.
834 \end{macrodesc}
835
836 \begin{macrodesc}{plusminus}{}
837 The symbol for indicating a value that may take a positive or
838 negative value of a specified magnitude, typically represented
839 by a plus sign placed over a minus sign. For example:
840 \emph{The lateral movement has a tolerance of \plusminus 3\%{}}.
841 \end{macrodesc}
842
Fred Drake2f4bebd1999-04-28 16:43:11 +0000843 \begin{macrodesc}{program}{\p{name}}
844 The name of an executable program. This may differ from the
845 file name for the executable for some platforms. In particular,
846 the \file{.exe} (or other) extension should be omitted for DOS
847 and Windows programs.
848 \end{macrodesc}
849
Fred Drake29a710f1999-11-10 22:51:18 +0000850 \begin{macrodesc}{programopt}{\p{option}}
Fred Drakece444982000-04-11 18:52:52 +0000851 A command-line option to an executable program. Use this only
852 for ``shot'' options, and include the leading hyphen.
853 \end{macrodesc}
854
855 \begin{macrodesc}{longprogramopt}{\p{option}}
856 A long command-line option to an executable program. This
857 should only be used for long option names which will be prefixed
858 by two hyphens; the hyphens should not be provided as part of
859 \var{option}.
Fred Drake29a710f1999-11-10 22:51:18 +0000860 \end{macrodesc}
861
Fred Drake2f4bebd1999-04-28 16:43:11 +0000862 \begin{macrodesc}{refmodule}{\op{key}\p{name}}
863 Like \macro{module}, but create a hyperlink to the documentation
864 for the named module. Note that the corresponding
865 \macro{declaremodule} must be in the same document. If the
866 \macro{declaremodule} defines a module key different from the
867 module name, it must also be provided as \var{key} to the
868 \macro{refmodule} macro.
869 \end{macrodesc}
870
871 \begin{macrodesc}{regexp}{\p{string}}
872 Mark a regular expression.
873 \end{macrodesc}
874
875 \begin{macrodesc}{rfc}{\p{number}}
876 A reference to an Internet Request for Comments. This generates
877 appropriate index entries. The text \samp{RFC \var{number}} is
878 generated; in the HTML output, this text is a hyperlink to an
879 online copy of the specified RFC.
880 \end{macrodesc}
881
882 \begin{macrodesc}{samp}{\p{text}}
883 A short code sample, but possibly longer than would be given
884 using \macro{code}. Since quotation marks are added, spaces are
885 acceptable.
886 \end{macrodesc}
887
Fred Drakeaf2b7142000-09-14 20:11:05 +0000888 \begin{macrodesc}{shortversion}{}
889 The ``short'' version number of the documented software, as
890 specified using the \macro{setshortversion} macro in the
891 preamble. For Python, the short version number for a release is
892 the first three characters of the \code{sys.version} value. For
893 example, versions 2.0b1 and 2.0.1 both have a short version of
894 2.0. This may not apply for all packages; if
895 \macro{setshortversion} is not used, this produces an empty
896 expansion. See also the \macro{version} macro.
897 \end{macrodesc}
898
Fred Drake2f4bebd1999-04-28 16:43:11 +0000899 \begin{macrodesc}{strong}{\p{text}}
900 Strongly emphasized text; this will be presented using a bold
901 font.
902 \end{macrodesc}
903
Fred Drake432cef02001-07-06 22:34:33 +0000904 \begin{macrodesc}{ulink}{\p{text}\p{url}}
905 A hypertext link with a target specified by a URL, but for which
906 the link text should not be the title of the resource. For
907 resources being referenced by name, use the \macro{citetitle}
908 macro. Not all formatted versions support arbitrary hypertext
909 links. Note that many characters are special to \LaTeX{} and
910 this macro does not always do the right thing. In particular,
911 the tilde character (\character{\~}) is mis-handled; encoding it
912 as a hex-sequence does work, use \samp{\%7e} in place of the
913 tilde character.
914 \end{macrodesc}
915
Fred Draked1fb7791999-05-17 16:33:54 +0000916 \begin{macrodesc}{url}{\p{url}}
917 A URL (or URN). The URL will be presented as text. In the HTML
918 and PDF formatted versions, the URL will also be a hyperlink.
Fred Drake432cef02001-07-06 22:34:33 +0000919 This can be used when referring to external resources without
920 specific titles; references to resources which have titles
921 should be marked using the \macro{citetitle} macro. See the
922 comments about special characters in the description of the
923 \macro{ulink} macro for special considerations.
Fred Draked1fb7791999-05-17 16:33:54 +0000924 \end{macrodesc}
925
Fred Drake2f4bebd1999-04-28 16:43:11 +0000926 \begin{macrodesc}{var}{\p{name}}
927 The name of a variable or formal parameter in running text.
928 \end{macrodesc}
929
930 \begin{macrodesc}{version}{}
Fred Drakeaf2b7142000-09-14 20:11:05 +0000931 The version number of the described software, as specified using
932 \macro{release} in the preamble. See also the
933 \macro{shortversion} macro.
Fred Drake2f4bebd1999-04-28 16:43:11 +0000934 \end{macrodesc}
Fred Drakeacffaee1999-03-16 16:09:13 +0000935
Fred Drake3151f442001-04-18 05:19:06 +0000936 \begin{macrodesc}{versionadded}{\op{explanation}\p{version}}
Fred Drakec26cc912000-05-02 17:43:44 +0000937 The version of Python which added the described feature to the
Fred Drake3151f442001-04-18 05:19:06 +0000938 library or C API. \var{explanation} should be a \emph{brief}
939 explanation of the change consisting of a capitalized sentence
940 fragment; a period will be appended by the formatting process.
941 This is typically added to the end of the first paragraph of the
942 description before any availability notes. The location should
943 be selected so the explanation makes sense and may vary as
944 needed.
Fred Drakec26cc912000-05-02 17:43:44 +0000945 \end{macrodesc}
946
947 \begin{macrodesc}{versionchanged}{\op{explanation}\p{version}}
948 The version of Python in which the named feature was changed in
949 some way (new parameters, changed side effects, etc.).
950 \var{explanation} should be a \emph{brief} explanation of the
Fred Drake63568aa2000-10-19 05:36:10 +0000951 change consisting of a capitalized sentence fragment; a
Fred Drakec26cc912000-05-02 17:43:44 +0000952 period will be appended by the formatting process.
953 This is typically added to the end of the first paragraph of the
954 description before any availability notes and after
955 \macro{versionadded}. The location should be selected so the
956 explanation makes sense and may vary as needed.
957 \end{macrodesc}
958
Fred Drakeacffaee1999-03-16 16:09:13 +0000959
960 \subsection{Module-specific Markup}
961
962 The markup described in this section is used to provide information
963 about a module being documented. A typical use of this markup
964 appears at the top of the section used to document a module. A
965 typical example might look like this:
966
967\begin{verbatim}
968\section{\module{spam} ---
969 Access to the SPAM facility}
970
971\declaremodule{extension}{spam}
Fred Drake2c4e0091999-03-29 14:55:55 +0000972 \platform{Unix}
Fred Drakeadade921999-04-22 13:05:27 +0000973\modulesynopsis{Access to the SPAM facility of \UNIX{}.}
Fred Drake2c4e0091999-03-29 14:55:55 +0000974\moduleauthor{Jane Doe}{jane.doe@frobnitz.org}
Fred Drakeacffaee1999-03-16 16:09:13 +0000975\end{verbatim}
976
Fred Drake7932ed02000-08-11 17:37:33 +0000977 Python packages\index{packages} --- collections of modules that can
978 be described as a unit --- are documented using the same markup as
979 modules. The name for a module in a package should be typed in
Fred Drake432cef02001-07-06 22:34:33 +0000980 ``fully qualified'' form (it should include the package name).
Fred Drake7932ed02000-08-11 17:37:33 +0000981 For example, a module ``foo'' in package ``bar'' should be marked as
982 \samp{\e module\{bar.foo\}}, and the beginning of the reference
983 section would appear as:
984
985\begin{verbatim}
986\section{\module{bar.foo} ---
987 Module from the \module{bar} package}
988
989\declaremodule{extension}{bar.foo}
990\modulesynopsis{Nifty module from the \module{bar} package.}
991\moduleauthor{Jane Doe}{jane.doe@frobnitz.org}
992\end{verbatim}
993
994 Note that the name of a package is also marked using
995 \macro{module}.
996
Fred Drakeadade921999-04-22 13:05:27 +0000997 \begin{macrodesc}{declaremodule}{\op{key}\p{type}\p{name}}
Fred Drake87f768e1999-05-17 15:22:45 +0000998 Requires two parameters: module type (\samp{standard},
999 \samp{builtin}, \samp{extension}, or \samp{}), and the module
1000 name. An optional parameter should be given as the basis for the
1001 module's ``key'' used for linking to or referencing the section.
1002 The ``key'' should only be given if the module's name contains any
1003 underscores, and should be the name with the underscores stripped.
1004 Note that the \var{type} parameter must be one of the values
1005 listed above or an error will be printed. For modules which are
1006 contained in packages, the fully-qualified name should be given as
1007 \var{name} parameter. This should be the first thing after the
1008 \macro{section} used to introduce the module.
Fred Drakeacffaee1999-03-16 16:09:13 +00001009 \end{macrodesc}
1010
Fred Drakeadade921999-04-22 13:05:27 +00001011 \begin{macrodesc}{platform}{\p{specifier}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001012 Specifies the portability of the module. \var{specifier} is a
1013 comma-separated list of keys that specify what platforms the
1014 module is available on. The keys are short identifiers;
1015 examples that are in use include \samp{IRIX}, \samp{Mac},
1016 \samp{Windows}, and \samp{Unix}. It is important to use a key
Fred Drake7a737df1999-04-23 14:41:44 +00001017 which has already been used when applicable. This is used to
1018 provide annotations in the Module Index and the HTML and GNU info
1019 output.
Fred Drakeacffaee1999-03-16 16:09:13 +00001020 \end{macrodesc}
1021
Fred Drakeadade921999-04-22 13:05:27 +00001022 \begin{macrodesc}{modulesynopsis}{\p{text}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001023 The \var{text} is a short, ``one line'' description of the
1024 module that can be used as part of the chapter introduction.
Fred Drakeadade921999-04-22 13:05:27 +00001025 This is must be placed after \macro{declaremodule}.
Fred Drakeacffaee1999-03-16 16:09:13 +00001026 The synopsis is used in building the contents of the table
1027 inserted as the \macro{localmoduletable}. No text is
1028 produced at the point of the markup.
1029 \end{macrodesc}
1030
Fred Drakeadade921999-04-22 13:05:27 +00001031 \begin{macrodesc}{moduleauthor}{\p{name}\p{email}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001032 This macro is used to encode information about who authored a
1033 module. This is currently not used to generate output, but can be
1034 used to help determine the origin of the module.
1035 \end{macrodesc}
1036
1037
1038 \subsection{Library-level Markup}
1039
1040 This markup is used when describing a selection of modules. For
Fred Drake698d5201999-11-10 15:54:57 +00001041 example, the \citetitle[../mac/mac.html]{Macintosh Library
1042 Modules} document uses this to help provide an overview of the
1043 modules in the collection, and many chapters in the
1044 \citetitle[../lib/lib.html]{Python Library Reference} use it for
Fred Drakeacffaee1999-03-16 16:09:13 +00001045 the same purpose.
1046
1047 \begin{macrodesc}{localmoduletable}{}
Fred Drake2c4e0091999-03-29 14:55:55 +00001048 If a \file{.syn} file exists for the current
Fred Drakeacffaee1999-03-16 16:09:13 +00001049 chapter (or for the entire document in \code{howto} documents), a
1050 \env{synopsistable} is created with the contents loaded from the
1051 \file{.syn} file.
1052 \end{macrodesc}
1053
1054
1055 \subsection{Table Markup}
1056
1057 There are three general-purpose table environments defined which
1058 should be used whenever possible. These environments are defined
1059 to provide tables of specific widths and some convenience for
1060 formatting. These environments are not meant to be general
1061 replacements for the standard \LaTeX{} table environments, but can
1062 be used for an advantage when the documents are processed using
1063 the tools for Python documentation processing. In particular, the
1064 generated HTML looks good! There is also an advantage for the
Fred Drake67f193f2001-07-09 16:04:03 +00001065 eventual conversion of the documentation to XML (see section
Fred Drake2c4e0091999-03-29 14:55:55 +00001066 \ref{futures}, ``Future Directions'').
Fred Drakeacffaee1999-03-16 16:09:13 +00001067
1068 Each environment is named \env{table\var{cols}}, where \var{cols}
1069 is the number of columns in the table specified in lower-case
1070 Roman numerals. Within each of these environments, an additional
1071 macro, \macro{line\var{cols}}, is defined, where \var{cols}
1072 matches the \var{cols} value of the corresponding table
Fred Drake2c4e0091999-03-29 14:55:55 +00001073 environment. These are supported for \var{cols} values of
1074 \code{ii}, \code{iii}, and \code{iv}. These environments are all
Fred Drakeda72b932000-09-21 15:58:02 +00001075 built on top of the \env{tabular} environment. Variants based on
1076 the \env{longtable} environment are also provided.
Fred Drakeacffaee1999-03-16 16:09:13 +00001077
Fred Drake2b853412000-04-11 19:08:30 +00001078 Note that all tables in the standard Python documentation use
1079 vertical lines between columns, and this must be specified in the
1080 markup for each table. A general border around the outside of the
1081 table is not used, but would be the responsibility of the
Fred Drakeda72b932000-09-21 15:58:02 +00001082 processor; the document markup should not include an exterior
1083 border.
1084
1085 The \env{longtable}-based variants of the table environments are
1086 formatted with extra space before and after, so should only be
1087 used on tables which are long enough that splitting over multiple
1088 pages is reasonable; tables with fewer than twenty rows should
1089 never by marked using the long flavors of the table environments.
1090 The header row is repeated across the top of each part of the
1091 table.
Fred Drake2b853412000-04-11 19:08:30 +00001092
Fred Drakeadade921999-04-22 13:05:27 +00001093 \begin{envdesc}{tableii}{\p{colspec}\p{col1font}\p{heading1}\p{heading2}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001094 Create a two-column table using the \LaTeX{} column specifier
1095 \var{colspec}. The column specifier should indicate vertical
1096 bars between columns as appropriate for the specific table, but
1097 should not specify vertical bars on the outside of the table
1098 (that is considered a stylesheet issue). The \var{col1font}
1099 parameter is used as a stylistic treatment of the first column
1100 of the table: the first column is presented as
1101 \code{\e\var{col1font}\{column1\}}. To avoid treating the first
Fred Drakeadade921999-04-22 13:05:27 +00001102 column specially, \var{col1font} may be \samp{textrm}. The
Fred Drakeacffaee1999-03-16 16:09:13 +00001103 column headings are taken from the values \var{heading1} and
1104 \var{heading2}.
1105 \end{envdesc}
1106
Fred Drakeda72b932000-09-21 15:58:02 +00001107 \begin{envdesc}{longtableii}{\unspecified}
1108 Like \env{tableii}, but produces a table which may be broken
1109 across page boundaries. The parameters are the same as for
1110 \env{tableii}.
1111 \end{envdesc}
1112
Fred Drakeadade921999-04-22 13:05:27 +00001113 \begin{macrodesc}{lineii}{\p{column1}\p{column2}}
Fred Drakeda72b932000-09-21 15:58:02 +00001114 Create a single table row within a \env{tableii} or
1115 \env{longtableii} environment.
Fred Drakeacffaee1999-03-16 16:09:13 +00001116 The text for the first column will be generated by applying the
1117 macro named by the \var{col1font} value when the \env{tableii}
1118 was opened.
1119 \end{macrodesc}
1120
Fred Drakeadade921999-04-22 13:05:27 +00001121 \begin{envdesc}{tableiii}{\p{colspec}\p{col1font}\p{heading1}\p{heading2}\p{heading3}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001122 Like the \env{tableii} environment, but with a third column.
1123 The heading for the third column is given by \var{heading3}.
1124 \end{envdesc}
1125
Fred Drakeda72b932000-09-21 15:58:02 +00001126 \begin{envdesc}{longtableiii}{\unspecified}
1127 Like \env{tableiii}, but produces a table which may be broken
1128 across page boundaries. The parameters are the same as for
1129 \env{tableiii}.
1130 \end{envdesc}
1131
Fred Drakeadade921999-04-22 13:05:27 +00001132 \begin{macrodesc}{lineiii}{\p{column1}\p{column2}\p{column3}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001133 Like the \macro{lineii} macro, but with a third column. The
1134 text for the third column is given by \var{column3}.
1135 \end{macrodesc}
1136
Fred Drakeadade921999-04-22 13:05:27 +00001137 \begin{envdesc}{tableiv}{\p{colspec}\p{col1font}\p{heading1}\p{heading2}\p{heading3}\p{heading4}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001138 Like the \env{tableiii} environment, but with a fourth column.
1139 The heading for the fourth column is given by \var{heading4}.
1140 \end{envdesc}
1141
Fred Drakeda72b932000-09-21 15:58:02 +00001142 \begin{envdesc}{longtableiv}{\unspecified}
1143 Like \env{tableiv}, but produces a table which may be broken
1144 across page boundaries. The parameters are the same as for
1145 \env{tableiv}.
1146 \end{envdesc}
1147
Fred Drakeadade921999-04-22 13:05:27 +00001148 \begin{macrodesc}{lineiv}{\p{column1}\p{column2}\p{column3}\p{column4}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001149 Like the \macro{lineiii} macro, but with a fourth column. The
1150 text for the fourth column is given by \var{column4}.
1151 \end{macrodesc}
1152
1153
1154 An additional table-like environment is \env{synopsistable}. The
1155 table generated by this environment contains two columns, and each
1156 row is defined by an alternate definition of
Fred Drakee15956b2000-04-03 04:51:13 +00001157 \macro{modulesynopsis}. This environment is not normally used by
1158 authors, but is created by the \macro{localmoduletable} macro.
Fred Drakeacffaee1999-03-16 16:09:13 +00001159
1160
1161 \subsection{Reference List Markup \label{references}}
1162
1163 Many sections include a list of references to module documentation
1164 or external documents. These lists are created using the
1165 \env{seealso} environment. This environment defines some
1166 additional macros to support creating reference entries in a
1167 reasonable manner.
1168
Fred Drake5802e482000-07-06 05:24:41 +00001169 The \env{seealso} environment is typically placed in a section
1170 just before any sub-sections. This is done to ensure that
1171 reference links related to the section are not hidden in a
1172 subsection in the hypertext renditions of the documentation.
1173
Fred Drakeacffaee1999-03-16 16:09:13 +00001174 \begin{envdesc}{seealso}{}
1175 This environment creates a ``See also:'' heading and defines the
1176 markup used to describe individual references.
1177 \end{envdesc}
1178
Fred Drake48449982000-09-12 17:52:33 +00001179 For each of the following macros, \var{why} should be one or more
1180 complete sentences, starting with a capital letter (unless it
1181 starts with an identifier, which should not be modified), and
1182 ending with the apropriate punctuation.
Fred Drake5802e482000-07-06 05:24:41 +00001183
Fred Drakeb7cf3782000-09-12 19:58:10 +00001184 These macros are only defined within the content of the
1185 \env{seealso} environment.
1186
Fred Drakeadade921999-04-22 13:05:27 +00001187 \begin{macrodesc}{seemodule}{\op{key}\p{name}\p{why}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001188 Refer to another module. \var{why} should be a brief
1189 explanation of why the reference may be interesting. The module
1190 name is given in \var{name}, with the link key given in
1191 \var{key} if necessary. In the HTML and PDF conversions, the
1192 module name will be a hyperlink to the referred-to module.
Fred Drakeadade921999-04-22 13:05:27 +00001193 \strong{Note:} The module must be documented in the same
1194 document (the corresponding \macro{declaremodule} is required).
Fred Drakeacffaee1999-03-16 16:09:13 +00001195 \end{macrodesc}
1196
Fred Drake08c5d0c2000-09-11 05:22:30 +00001197 \begin{macrodesc}{seepep}{\p{number}\p{title}\p{why}}
1198 Refer to an Python Enhancement Proposal (PEP). \var{number}
1199 should be the official number assigned by the PEP Editor,
1200 \var{title} should be the human-readable title of the PEP as
Fred Drake5802e482000-07-06 05:24:41 +00001201 found in the official copy of the document, and \var{why} should
Fred Drake08c5d0c2000-09-11 05:22:30 +00001202 explain what's interesting about the PEP. This should be used
1203 to refer the reader to PEPs which specify interfaces or language
1204 features relevant to the material in the annotated section of the
1205 documentation.
1206 \end{macrodesc}
1207
1208 \begin{macrodesc}{seerfc}{\p{number}\p{title}\p{why}}
1209 Refer to an IETF Request for Comments (RFC). Otherwise very
1210 similar to \macro{seepep}. This should be used
1211 to refer the reader to PEPs which specify protocols or data
Fred Drake5802e482000-07-06 05:24:41 +00001212 formats relevant to the material in the annotated section of the
1213 documentation.
1214 \end{macrodesc}
1215
Fred Drakeadade921999-04-22 13:05:27 +00001216 \begin{macrodesc}{seetext}{\p{text}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001217 Add arbitrary text \var{text} to the ``See also:'' list. This
1218 can be used to refer to off-line materials or on-line materials
Fred Drake5802e482000-07-06 05:24:41 +00001219 using the \macro{url} macro. This should consist of one or more
1220 complete sentences.
1221 \end{macrodesc}
1222
Fred Drake48449982000-09-12 17:52:33 +00001223 \begin{macrodesc}{seetitle}{\op{url}\p{title}\p{why}}
1224 Add a reference to an external document named \var{title}. If
1225 \var{url} is given, the title is made a hyperlink in the HTML
1226 version of the documentation, and displayed below the title in
1227 the typeset versions of the documentation.
1228 \end{macrodesc}
1229
Fred Drake5802e482000-07-06 05:24:41 +00001230 \begin{macrodesc}{seeurl}{\p{url}\p{why}}
1231 References to specific on-line resources should be given using
1232 the \macro{seeurl} macro. No title is associated with the
1233 reference, but the \var{why} text may include a title marked
1234 using the \macro{citetitle} macro.
Fred Drakeacffaee1999-03-16 16:09:13 +00001235 \end{macrodesc}
1236
1237
1238 \subsection{Index-generating Markup \label{indexing}}
1239
1240 Effective index generation for technical documents can be very
Fred Drakee15956b2000-04-03 04:51:13 +00001241 difficult, especially for someone familiar with the topic but not
Fred Drakeacffaee1999-03-16 16:09:13 +00001242 the creation of indexes. Much of the difficulty arises in the
1243 area of terminology: including the terms an expert would use for a
1244 concept is not sufficient. Coming up with the terms that a novice
Fred Drake2c4e0091999-03-29 14:55:55 +00001245 would look up is fairly difficult for an author who, typically, is
Fred Drakeacffaee1999-03-16 16:09:13 +00001246 an expert in the area she is writing on.
1247
Fred Drake2c4e0091999-03-29 14:55:55 +00001248 The truly difficult aspects of index generation are not areas with
1249 which the documentation tools can help. However, ease
Fred Drakee15956b2000-04-03 04:51:13 +00001250 of producing the index once content decisions are made is within
Fred Drakeacffaee1999-03-16 16:09:13 +00001251 the scope of the tools. Markup is provided which the processing
1252 software is able to use to generate a variety of kinds of index
1253 entry with minimal effort. Additionally, many of the environments
Fred Drake7a737df1999-04-23 14:41:44 +00001254 described in section \ref{info-units}, ``Information Units,'' will
Fred Drakeacffaee1999-03-16 16:09:13 +00001255 generate appropriate entries into the general and module indexes.
1256
1257 The following macro can be used to control the generation of index
Fred Drakeadade921999-04-22 13:05:27 +00001258 data, and should be used in the document preamble:
Fred Drakeacffaee1999-03-16 16:09:13 +00001259
1260 \begin{macrodesc}{makemodindex}{}
Fred Drakeadade921999-04-22 13:05:27 +00001261 This should be used in the document preamble if a ``Module
Fred Drakeacffaee1999-03-16 16:09:13 +00001262 Index'' is desired for a document containing reference material
1263 on many modules. This causes a data file
Fred Draked1fb7791999-05-17 16:33:54 +00001264 \code{lib\var{jobname}.idx} to be created from the
Fred Drakeacffaee1999-03-16 16:09:13 +00001265 \macro{declaremodule} macros. This file can be processed by the
1266 \program{makeindex} program to generate a file which can be
1267 \macro{input} into the document at the desired location of the
1268 module index.
1269 \end{macrodesc}
1270
1271 There are a number of macros that are useful for adding index
1272 entries for particular concepts, many of which are specific to
1273 programming languages or even Python.
1274
Fred Drakeadade921999-04-22 13:05:27 +00001275 \begin{macrodesc}{bifuncindex}{\p{name}}
Fred Drakeec8b9051999-04-23 20:01:17 +00001276 Add an index entry referring to a built-in function named
1277 \var{name}; parentheses should not be included after
Fred Drake2c4e0091999-03-29 14:55:55 +00001278 \var{name}.
Fred Drakeacffaee1999-03-16 16:09:13 +00001279 \end{macrodesc}
1280
Fred Drakeadade921999-04-22 13:05:27 +00001281 \begin{macrodesc}{exindex}{\p{exception}}
Fred Drake2c4e0091999-03-29 14:55:55 +00001282 Add a reference to an exception named \var{exception}. The
1283 exception may be either string- or class-based.
Fred Drakeacffaee1999-03-16 16:09:13 +00001284 \end{macrodesc}
1285
Fred Drakeadade921999-04-22 13:05:27 +00001286 \begin{macrodesc}{kwindex}{\p{keyword}}
Fred Drake2c4e0091999-03-29 14:55:55 +00001287 Add a reference to a language keyword (not a keyword parameter
1288 in a function or method call).
Fred Drakeacffaee1999-03-16 16:09:13 +00001289 \end{macrodesc}
1290
Fred Drakeadade921999-04-22 13:05:27 +00001291 \begin{macrodesc}{obindex}{\p{object type}}
Fred Drake2c4e0091999-03-29 14:55:55 +00001292 Add an index entry for a built-in object type.
Fred Drakeacffaee1999-03-16 16:09:13 +00001293 \end{macrodesc}
1294
Fred Drakeadade921999-04-22 13:05:27 +00001295 \begin{macrodesc}{opindex}{\p{operator}}
Fred Drake2c4e0091999-03-29 14:55:55 +00001296 Add a reference to an operator, such as \samp{+}.
Fred Drakeacffaee1999-03-16 16:09:13 +00001297 \end{macrodesc}
1298
Fred Drakeadade921999-04-22 13:05:27 +00001299 \begin{macrodesc}{refmodindex}{\op{key}\p{module}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001300 Add an index entry for module \var{module}; if \var{module}
1301 contains an underscore, the optional parameter \var{key} should
1302 be provided as the same string with underscores removed. An
1303 index entry ``\var{module} (module)'' will be generated. This
1304 is intended for use with non-standard modules implemented in
1305 Python.
1306 \end{macrodesc}
1307
Fred Drakeadade921999-04-22 13:05:27 +00001308 \begin{macrodesc}{refexmodindex}{\op{key}\p{module}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001309 As for \macro{refmodindex}, but the index entry will be
1310 ``\var{module} (extension module).'' This is intended for use
1311 with non-standard modules not implemented in Python.
1312 \end{macrodesc}
1313
Fred Drakeadade921999-04-22 13:05:27 +00001314 \begin{macrodesc}{refbimodindex}{\op{key}\p{module}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001315 As for \macro{refmodindex}, but the index entry will be
1316 ``\var{module} (built-in module).'' This is intended for use
1317 with standard modules not implemented in Python.
1318 \end{macrodesc}
1319
Fred Drakeadade921999-04-22 13:05:27 +00001320 \begin{macrodesc}{refstmodindex}{\op{key}\p{module}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001321 As for \macro{refmodindex}, but the index entry will be
1322 ``\var{module} (standard module).'' This is intended for use
1323 with standard modules implemented in Python.
1324 \end{macrodesc}
1325
Fred Drakeadade921999-04-22 13:05:27 +00001326 \begin{macrodesc}{stindex}{\p{statement}}
Fred Drake2c4e0091999-03-29 14:55:55 +00001327 Add an index entry for a statement type, such as \keyword{print}
Fred Drakeadade921999-04-22 13:05:27 +00001328 or \keyword{try}/\keyword{finally}.
1329
1330 XXX Need better examples of difference from \macro{kwindex}.
Fred Drakeacffaee1999-03-16 16:09:13 +00001331 \end{macrodesc}
1332
1333
1334 Additional macros are provided which are useful for conveniently
1335 creating general index entries which should appear at many places
1336 in the index by rotating a list of words. These are simple macros
1337 that simply use \macro{index} to build some number of index
1338 entries. Index entries build using these macros contain both
1339 primary and secondary text.
1340
Fred Drakeadade921999-04-22 13:05:27 +00001341 \begin{macrodesc}{indexii}{\p{word1}\p{word2}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001342 Build two index entries. This is exactly equivalent to using
1343 \code{\e index\{\var{word1}!\var{word2}\}} and
1344 \code{\e index\{\var{word2}!\var{word1}\}}.
1345 \end{macrodesc}
1346
Fred Drakeadade921999-04-22 13:05:27 +00001347 \begin{macrodesc}{indexiii}{\p{word1}\p{word2}\p{word3}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001348 Build three index entries. This is exactly equivalent to using
1349 \code{\e index\{\var{word1}!\var{word2} \var{word3}\}},
1350 \code{\e index\{\var{word2}!\var{word3}, \var{word1}\}}, and
1351 \code{\e index\{\var{word3}!\var{word1} \var{word2}\}}.
1352 \end{macrodesc}
1353
Fred Drakeadade921999-04-22 13:05:27 +00001354 \begin{macrodesc}{indexiv}{\p{word1}\p{word2}\p{word3}\p{word4}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001355 Build four index entries. This is exactly equivalent to using
1356 \code{\e index\{\var{word1}!\var{word2} \var{word3} \var{word4}\}},
1357 \code{\e index\{\var{word2}!\var{word3} \var{word4}, \var{word1}\}},
1358 \code{\e index\{\var{word3}!\var{word4}, \var{word1} \var{word2}\}},
1359 and
1360 \code{\e index\{\var{word4}!\var{word1} \var{word2} \var{word3}\}}.
1361 \end{macrodesc}
1362
Fred Drake432cef02001-07-06 22:34:33 +00001363 \subsection{Grammar Production Displays \label{grammar-displays}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001364
Fred Drake432cef02001-07-06 22:34:33 +00001365 Special markup is available for displaying the productions of a
1366 formal grammar. The markup is simple and does not attempt to
1367 model all aspects of BNF (or any derived forms), but provides
1368 enough to allow context-free grammars to be displayed in a way
1369 that causes uses of a symbol to be rendered as hyperlinks to the
1370 definition of the symbol. There is one environment and a pair of
1371 macros:
Fred Drakeacffaee1999-03-16 16:09:13 +00001372
Fred Drake432cef02001-07-06 22:34:33 +00001373 \begin{envdesc}{productionlist}{\op{language}}
1374 This environment is used to enclose a group of productions. The
1375 two macros are only defined within this environment. If a
1376 document descibes more than one language, the optional parameter
1377 \var{language} should be used to distinguish productions between
1378 languages. The value of the parameter should be a short name
1379 that can be used as part of a filename; colons or other
1380 characters that can't be used in filename across platforms
1381 should be included.
1382 \end{envdesc}
Fred Drakeacffaee1999-03-16 16:09:13 +00001383
Fred Drake432cef02001-07-06 22:34:33 +00001384 \begin{macrodesc}{production}{\p{name}\p{definition}}
1385 A production rule in the grammar. The rule defines the symbol
1386 \var{name} to be \var{definition}. \var{name} should not
1387 contain any markup, and the use of hyphens in a document which
1388 supports more than one grammar is undefined. \var{definition}
1389 may contain \macro{token} macros and any additional content
1390 needed to describe the grammatical model of \var{symbol}. Only
1391 one \macro{production} may be used to define a symbol ---
1392 multiple definitions are not allowed.
1393 \end{macrodesc}
Fred Drakeacffaee1999-03-16 16:09:13 +00001394
Fred Drake432cef02001-07-06 22:34:33 +00001395 \begin{macrodesc}{token}{\p{name}}
1396 The name of a symbol defined by a \macro{production} macro, used
1397 in the \var{definition} of a symbol. Where possible, this will
1398 be rendered as a hyperlink to the definition of the symbol
1399 \var{name}.
1400 \end{macrodesc}
Fred Drake42934682000-04-03 15:00:28 +00001401
Fred Drake432cef02001-07-06 22:34:33 +00001402 Note that the entire grammar does not need to be defined in a
1403 single \env{productionlist} environment; any number of
1404 groupings may be used to describe the grammar. Every use of the
1405 \macro{token} must correspond to a \macro{production}.
1406
1407 The following is an example taken from the
1408 \citetitle[../ref/identifiers.html]{Python Reference Manual}:
1409
1410\begin{verbatim}
1411\begin{productionlist}
1412 \production{identifier}
1413 {(\token{letter}|"_") (\token{letter} | \token{digit} | "_")*}
1414 \production{letter}
1415 {\token{lowercase} | \token{uppercase}}
1416 \production{lowercase}
1417 {"a"..."z"}
1418 \production{uppercase}
1419 {"A"..."Z"}
1420 \production{digit}
1421 {"0"..."9"}
1422\end{productionlist}
1423\end{verbatim}
1424
1425
1426\section{Graphical Interface Components}
1427
1428 The components of graphical interfaces will be assigned markup, but
1429 the specifics have not been determined.
Fred Drakeacffaee1999-03-16 16:09:13 +00001430
1431
1432\section{Processing Tools}
1433
1434 \subsection{External Tools}
1435
1436 Many tools are needed to be able to process the Python
1437 documentation if all supported formats are required. This
Fred Drakeadade921999-04-22 13:05:27 +00001438 section lists the tools used and when each is required. Consult
1439 the \file{Doc/README} file to see if there are specific version
1440 requirements for any of these.
Fred Drakeacffaee1999-03-16 16:09:13 +00001441
1442 \begin{description}
1443 \item[\program{dvips}]
1444 This program is a typical part of \TeX{} installations. It is
1445 used to generate PostScript from the ``device independent''
Fred Drake2c4e0091999-03-29 14:55:55 +00001446 \file{.dvi} files. It is needed for the conversion to
Fred Drakeacffaee1999-03-16 16:09:13 +00001447 PostScript.
1448
1449 \item[\program{emacs}]
1450 Emacs is the kitchen sink of programmers' editors, and a damn
1451 fine kitchen sink it is. It also comes with some of the
1452 processing needed to support the proper menu structures for
1453 Texinfo documents when an info conversion is desired. This is
Fred Drake2c4e0091999-03-29 14:55:55 +00001454 needed for the info conversion. Using \program{xemacs}
Fred Drakeacffaee1999-03-16 16:09:13 +00001455 instead of FSF \program{emacs} may lead to instability in the
1456 conversion, but that's because nobody seems to maintain the
1457 Emacs Texinfo code in a portable manner.
1458
1459 \item[\program{latex}]
1460 This is a world-class typesetter by Donald Knuth. It is used
1461 for the conversion to PostScript, and is needed for the HTML
1462 conversion as well (\LaTeX2HTML requires one of the
1463 intermediate files it creates).
1464
1465 \item[\program{latex2html}]
1466 Probably the longest Perl script anyone ever attempted to
1467 maintain. This converts \LaTeX{} documents to HTML documents,
1468 and does a pretty reasonable job. It is required for the
1469 conversions to HTML and GNU info.
1470
1471 \item[\program{lynx}]
1472 This is a text-mode Web browser which includes an
1473 HTML-to-plain text conversion. This is used to convert
1474 \code{howto} documents to text.
1475
1476 \item[\program{make}]
1477 Just about any version should work for the standard documents,
1478 but GNU \program{make} is required for the experimental
1479 processes in \file{Doc/tools/sgmlconv/}, at least while
1480 they're experimental.
1481
1482 \item[\program{makeindex}]
1483 This is a standard program for converting \LaTeX{} index data
1484 to a formatted index; it should be included with all \LaTeX{}
1485 installations. It is needed for the PDF and PostScript
1486 conversions.
1487
1488 \item[\program{makeinfo}]
1489 GNU \program{makeinfo} is used to convert Texinfo documents to
1490 GNU info files. Since Texinfo is used as an intermediate
1491 format in the info conversion, this program is needed in that
1492 conversion.
1493
1494 \item[\program{pdflatex}]
1495 pdf\TeX{} is a relatively new variant of \TeX, and is used to
1496 generate the PDF version of the manuals. It is typically
1497 installed as part of most of the large \TeX{} distributions.
Fred Drake7a737df1999-04-23 14:41:44 +00001498 \program{pdflatex} is pdf\TeX{} using the \LaTeX{} format.
Fred Drakeacffaee1999-03-16 16:09:13 +00001499
1500 \item[\program{perl}]
1501 Perl is required for \LaTeX2HTML{} and one of the scripts used
1502 to post-process \LaTeX2HTML output, as well as the
Fred Drake2c4e0091999-03-29 14:55:55 +00001503 HTML-to-Texinfo conversion. This is required for
Fred Drakeacffaee1999-03-16 16:09:13 +00001504 the HTML and GNU info conversions.
1505
1506 \item[\program{python}]
1507 Python is used for many of the scripts in the
1508 \file{Doc/tools/} directory; it is required for all
1509 conversions. This shouldn't be a problem if you're interested
1510 in writing documentation for Python!
1511 \end{description}
1512
1513
1514 \subsection{Internal Tools}
1515
1516 This section describes the various scripts that are used to
1517 implement various stages of document processing or to orchestrate
Fred Drake2c4e0091999-03-29 14:55:55 +00001518 entire build sequences. Most of these tools are only useful
Fred Drakeacffaee1999-03-16 16:09:13 +00001519 in the context of building the standard documentation, but some
1520 are more general.
1521
1522 \begin{description}
1523 \item[\program{mkhowto}]
Fred Drake87f768e1999-05-17 15:22:45 +00001524 This is the primary script used to format third-party
1525 documents. It contains all the logic needed to ``get it
1526 right.'' The proper way to use this script is to make a
1527 symbolic link to it or run it in place; the actual script file
1528 must be stored as part of the documentation source tree,
1529 though it may be used to format documents outside the
Fred Drakece444982000-04-11 18:52:52 +00001530 tree. Use \program{mkhowto} \longprogramopt{help}
Fred Draked290c101999-11-09 18:03:00 +00001531 for a list of
Fred Draked2a727f1999-05-27 21:45:54 +00001532 command line options.
Fred Drake87f768e1999-05-17 15:22:45 +00001533
Fred Draked1fb7791999-05-17 16:33:54 +00001534 \program{mkhowto} can be used for both \code{howto} and
1535 \code{manual} class documents. (For the later, be sure to get
1536 the latest version from the Python CVS repository rather than
1537 the version distributed in the \file{latex-1.5.2.tgz} source
1538 archive.)
1539
Fred Drake87f768e1999-05-17 15:22:45 +00001540 XXX Need more here.
Fred Drakeacffaee1999-03-16 16:09:13 +00001541 \end{description}
1542
1543
1544\section{Future Directions \label{futures}}
1545
1546 The history of the Python documentation is full of changes, most of
1547 which have been fairly small and evolutionary. There has been a
1548 great deal of discussion about making large changes in the markup
1549 languages and tools used to process the documentation. This section
1550 deals with the nature of the changes and what appears to be the most
1551 likely path of future development.
1552
1553 \subsection{Structured Documentation \label{structured}}
1554
1555 Most of the small changes to the \LaTeX{} markup have been made
1556 with an eye to divorcing the markup from the presentation, making
1557 both a bit more maintainable. Over the course of 1998, a large
1558 number of changes were made with exactly this in mind; previously,
1559 changes had been made but in a less systematic manner and with
1560 more concern for not needing to update the existing content. The
1561 result has been a highly structured and semantically loaded markup
1562 language implemented in \LaTeX. With almost no basic \TeX{} or
1563 \LaTeX{} markup in use, however, the markup syntax is about the
1564 only evidence of \LaTeX{} in the actual document sources.
1565
1566 One side effect of this is that while we've been able to use
1567 standard ``engines'' for manipulating the documents, such as
1568 \LaTeX{} and \LaTeX2HTML, most of the actual transformations have
Fred Drake7a737df1999-04-23 14:41:44 +00001569 been created specifically for Python. The \LaTeX{} document
1570 classes and \LaTeX2HTML support are both complete implementations
1571 of the specific markup designed for these documents.
Fred Drakeacffaee1999-03-16 16:09:13 +00001572
1573 Combining highly customized markup with the somewhat esoteric
1574 systems used to process the documents leads us to ask some
1575 questions: Can we do this more easily? and, Can we do this
1576 better? After a great deal of discussion with the community, we
1577 have determined that actively pursuing modern structured
Fred Drake2c4e0091999-03-29 14:55:55 +00001578 documentation systems is worth some investment of time.
Fred Drakeacffaee1999-03-16 16:09:13 +00001579
1580 There appear to be two real contenders in this arena: the Standard
1581 General Markup Language (SGML), and the Extensible Markup Language
1582 (XML). Both of these standards have advantages and disadvantages,
1583 and many advantages are shared.
1584
1585 SGML offers advantages which may appeal most to authors,
1586 especially those using ordinary text editors. There are also
1587 additional abilities to define content models. A number of
Fred Drake67f193f2001-07-09 16:04:03 +00001588 high-quality tools with demonstrated maturity are available, but
Fred Drakeacffaee1999-03-16 16:09:13 +00001589 most are not free; for those which are, portability issues remain
1590 a problem.
1591
1592 The advantages of XML include the availability of a large number
1593 of evolving tools. Unfortunately, many of the associated
1594 standards are still evolving, and the tools will have to follow
1595 along. This means that developing a robust tool set that uses
1596 more than the basic XML 1.0 recommendation is not possible in the
1597 short term. The promised availability of a wide variety of
1598 high-quality tools which support some of the most important
1599 related standards is not immediate. Many tools are likely to be
Fred Drake67f193f2001-07-09 16:04:03 +00001600 free, and the portability issues of those which are, are not
1601 expected to be significant.
Fred Drakeacffaee1999-03-16 16:09:13 +00001602
Fred Drake67f193f2001-07-09 16:04:03 +00001603 It turns out that converting to an XML or SGML system holds
1604 promise for translators as well; how much can be done to ease the
1605 burden on translators remains to be seen, and may have some impact
1606 on the schema and specific technologies used.
1607
1608 XXX Eventual migration to XML.
1609
1610 The documentation will be moved to XML in the future, and tools
1611 are being written which will convert the documentation from the
1612 current format to something close to a finished version, to the
1613 extent that the desired information is already present in the
1614 documentation. Some XSLT stylesheets have been started for
1615 presenting a preliminary XML version as HTML, but the results are
1616 fairly rough..
1617
1618 The timeframe for the conversion is not clear since there doesn't
1619 seem to be much time available to work on this, but the appearant
1620 benefits are growing more substantial at a moderately rapid pace.
1621
Fred Drakeacffaee1999-03-16 16:09:13 +00001622
1623 \subsection{Discussion Forums \label{discussion}}
1624
1625 Discussion of the future of the Python documentation and related
Fred Drake7a737df1999-04-23 14:41:44 +00001626 topics takes place in the Documentation Special Interest Group, or
1627 ``Doc-SIG.'' Information on the group, including mailing list
1628 archives and subscription information, is available at
Fred Drakeacffaee1999-03-16 16:09:13 +00001629 \url{http://www.python.org/sigs/doc-sig/}. The SIG is open to all
1630 interested parties.
1631
1632 Comments and bug reports on the standard documents should be sent
1633 to \email{python-docs@python.org}. This may include comments
Fred Drakeadade921999-04-22 13:05:27 +00001634 about formatting, content, grammatical and spelling errors, or
Fred Draked1fb7791999-05-17 16:33:54 +00001635 this document. You can also send comments on this document
1636 directly to the author at \email{fdrake@acm.org}.
Fred Drakeacffaee1999-03-16 16:09:13 +00001637
1638\end{document}