source: vendor/python/2.5/Doc/doc/doc.tex

Last change on this file was 3225, checked in by bird, 18 years ago

Python 2.5

File size: 90.8 KB
Line 
1\documentclass{howto}
2\usepackage{ltxmarkup}
3
4\title{Documenting Python}
5
6\makeindex
7
8\input{boilerplate}
9
10% Now override the stuff that includes author information;
11% Guido did *not* write this one!
12
13\author{Fred L. Drake, Jr.}
14\authoraddress{
15 PythonLabs \\
16 Email: \email{fdrake@acm.org}
17}
18
19
20\begin{document}
21
22\maketitle
23
24\begin{abstract}
25\noindent
26The Python language has a substantial body of
27documentation, much of it contributed by various authors. The markup
28used for the Python documentation is based on \LaTeX{} and requires a
29significant set of macros written specifically for documenting Python.
30This document describes the macros introduced to support Python
31documentation and how they should be used to support a wide range of
32output formats.
33
34This document describes the document classes and special markup used
35in the Python documentation. Authors may use this guide, in
36conjunction with the template files provided with the
37distribution, to create or maintain whole documents or sections.
38
39If you're interested in contributing to Python's documentation,
40there's no need to learn \LaTeX{} if you're not so inclined; plain
41text contributions are more than welcome as well.
42\end{abstract}
43
44\tableofcontents
45
46
47\section{Introduction \label{intro}}
48
49 Python's documentation has long been considered to be good for a
50 free programming language. There are a number of reasons for this,
51 the most important being the early commitment of Python's creator,
52 Guido van Rossum, to providing documentation on the language and its
53 libraries, and the continuing involvement of the user community in
54 providing assistance for creating and maintaining documentation.
55
56 The involvement of the community takes many forms, from authoring to
57 bug reports to just plain complaining when the documentation could
58 be more complete or easier to use. All of these forms of input from
59 the community have proved useful during the time I've been involved
60 in maintaining the documentation.
61
62 This document is aimed at authors and potential authors of
63 documentation for Python. More specifically, it is for people
64 contributing to the standard documentation and developing additional
65 documents using the same tools as the standard documents. This
66 guide will be less useful for authors using the Python documentation
67 tools for topics other than Python, and less useful still for
68 authors not using the tools at all.
69
70 The material in this guide is intended to assist authors using the
71 Python documentation tools. It includes information on the source
72 distribution of the standard documentation, a discussion of the
73 document types, reference material on the markup defined in the
74 document classes, a list of the external tools needed for processing
75 documents, and reference material on the tools provided with the
76 documentation resources. At the end, there is also a section
77 discussing future directions for the Python documentation and where
78 to turn for more information.
79
80 If your interest is in contributing to the Python documentation, but
81 you don't have the time or inclination to learn \LaTeX{} and the
82 markup structures documented here, there's a welcoming place for you
83 among the Python contributors as well. Any time you feel that you
84 can clarify existing documentation or provide documentation that's
85 missing, the existing documentation team will gladly work with you
86 to integrate your text, dealing with the markup for you. Please
87 don't let the material in this document stand between the
88 documentation and your desire to help out!
89
90\section{Directory Structure \label{directories}}
91
92 The source distribution for the standard Python documentation
93 contains a large number of directories. While third-party documents
94 do not need to be placed into this structure or need to be placed
95 within a similar structure, it can be helpful to know where to look
96 for examples and tools when developing new documents using the
97 Python documentation tools. This section describes this directory
98 structure.
99
100 The documentation sources are usually placed within the Python
101 source distribution as the top-level directory \file{Doc/}, but
102 are not dependent on the Python source distribution in any way.
103
104 The \file{Doc/} directory contains a few files and several
105 subdirectories. The files are mostly self-explanatory, including a
106 \file{README} and a \file{Makefile}. The directories fall into
107 three categories:
108
109 \begin{definitions}
110 \term{Document Sources}
111 The \LaTeX{} sources for each document are placed in a
112 separate directory. These directories are given short
113 names which vaguely indicate the document in each:
114
115 \begin{tableii}{p{.75in}|p{3in}}{filenq}{Directory}{Document Title}
116 \lineii{api/}
117 {\citetitle[../api/api.html]{The Python/C API}}
118 \lineii{dist/}
119 {\citetitle[../dist/dist.html]{Distributing Python Modules}}
120 \lineii{doc/}
121 {\citetitle[../doc/doc.html]{Documenting Python}}
122 \lineii{ext/}
123 {\citetitle[../ext/ext.html]
124 {Extending and Embedding the Python Interpreter}}
125 \lineii{inst/}
126 {\citetitle[../inst/inst.html]{Installing Python Modules}}
127 \lineii{lib/}
128 {\citetitle[../lib/lib.html]{Python Library Reference}}
129 \lineii{mac/}
130 {\citetitle[../mac/mac.html]{Macintosh Module Reference}}
131 \lineii{ref/}
132 {\citetitle[../ref/ref.html]{Python Reference Manual}}
133 \lineii{tut/}
134 {\citetitle[../tut/tut.html]{Python Tutorial}}
135 \lineii{whatsnew/}
136 {\citetitle[../whatsnew/whatsnew24.html]
137 {What's New in Python \shortversion}}
138 \end{tableii}
139
140 \term{Format-Specific Output}
141 Most output formats have a directory which contains a
142 \file{Makefile} which controls the generation of that format
143 and provides storage for the formatted documents. The only
144 variations within this category are the Portable Document
145 Format (PDF) and PostScript versions are placed in the
146 directories \file{paper-a4/} and \file{paper-letter/} (this
147 causes all the temporary files created by \LaTeX{} to be kept
148 in the same place for each paper size, where they can be more
149 easily ignored).
150
151 \begin{tableii}{p{.75in}|p{3in}}{filenq}{Directory}{Output Formats}
152 \lineii{html/}{HTML output}
153 \lineii{info/}{GNU info output}
154 \lineii{isilo/}{\ulink{iSilo}{http://www.isilo.com/}
155 documents (for Palm OS devices)}
156 \lineii{paper-a4/}{PDF and PostScript, A4 paper}
157 \lineii{paper-letter/}{PDF and PostScript, US-Letter paper}
158 \end{tableii}
159
160 \term{Supplemental Files}
161 Some additional directories are used to store supplemental
162 files used for the various processes. Directories are
163 included for the shared \LaTeX{} document classes, the
164 \LaTeX2HTML support, template files for various document
165 components, and the scripts used to perform various steps in
166 the formatting processes.
167
168 \begin{tableii}{p{.75in}|p{3in}}{filenq}{Directory}{Contents}
169 \lineii{commontex/}{Document content shared among documents}
170 \lineii{perl/} {Support for \LaTeX2HTML processing}
171 \lineii{templates/}{Example files for source documents}
172 \lineii{texinputs/}{Style implementation for \LaTeX}
173 \lineii{tools/} {Custom processing scripts}
174 \end{tableii}
175
176 \end{definitions}
177
178
179\section{Style Guide \label{style-guide}}
180
181 The Python documentation should follow the \citetitle
182 [http://developer.apple.com/documentation/UserExperience/Conceptual/APStyleGuide/AppleStyleGuide2003.pdf]
183 {Apple Publications Style Guide} wherever possible. This particular
184 style guide was selected mostly because it seems reasonable and is
185 easy to get online.
186
187 Topics which are not covered in the Apple's style guide will be
188 discussed in this document if necessary.
189
190 Footnotes are generally discouraged due to the pain of using
191 footnotes in the HTML conversion of documents. Footnotes may be
192 used when they are the best way to present specific information.
193 When a footnote reference is added at the end of the sentence, it
194 should follow the sentence-ending punctuation. The \LaTeX{} markup
195 should appear something like this:
196
197\begin{verbatim}
198This sentence has a footnote reference.%
199 \footnote{This is the footnote text.}
200\end{verbatim}
201
202 Footnotes may appear in the middle of sentences where appropriate.
203
204 Many special names are used in the Python documentation, including
205 the names of operating systems, programming languages, standards
206 bodies, and the like. Many of these were assigned \LaTeX{} macros
207 at some point in the distant past, and these macros lived on long
208 past their usefulness. In the current markup, most of these entities
209 are not assigned any special markup, but the preferred spellings are
210 given here to aid authors in maintaining the consistency of
211 presentation in the Python documentation.
212
213 Other terms and words deserve special mention as well; these conventions
214 should be used to ensure consistency throughout the documentation:
215
216 \begin{description}
217 \item[CPU]
218 For ``central processing unit.'' Many style guides say this
219 should be spelled out on the first use (and if you must use it,
220 do so!). For the Python documentation, this abbreviation should
221 be avoided since there's no reasonable way to predict which occurrence
222 will be the first seen by the reader. It is better to use the
223 word ``processor'' instead.
224
225 \item[\POSIX]
226 The name assigned to a particular group of standards. This is
227 always uppercase. Use the macro \macro{POSIX} to represent this
228 name.
229
230 \item[Python]
231 The name of our favorite programming language is always
232 capitalized.
233
234 \item[Unicode]
235 The name of a character set and matching encoding. This is
236 always written capitalized.
237
238 \item[\UNIX]
239 The name of the operating system developed at AT\&T Bell Labs
240 in the early 1970s. Use the macro \macro{UNIX} to use this
241 name.
242 \end{description}
243
244
245\section{\LaTeX{} Primer \label{latex-primer}}
246
247 This section is a brief introduction to \LaTeX{} concepts and
248 syntax, to provide authors enough information to author documents
249 productively without having to become ``\TeX{}nicians.'' This does
250 not teach everything needed to know about writing \LaTeX{} for
251 Python documentation; many of the standard ``environments'' are not
252 described here (though you will learn how to mark something as an
253 environment).
254
255 Perhaps the most important concept to keep in mind while marking up
256 Python documentation is that while \TeX{} is unstructured, \LaTeX{} was
257 designed as a layer on top of \TeX{} which specifically supports
258 structured markup. The Python-specific markup is intended to extend
259 the structure provided by standard \LaTeX{} document classes to
260 support additional information specific to Python.
261
262 \LaTeX{} documents contain two parts: the preamble and the body.
263 The preamble is used to specify certain metadata about the document
264 itself, such as the title, the list of authors, the date, and the
265 \emph{class} the document belongs to. Additional information used
266 to control index generation and the use of bibliographic databases
267 can also be placed in the preamble. For most authors, the preamble
268 can be most easily created by copying it from an existing document
269 and modifying a few key pieces of information.
270
271 The \dfn{class} of a document is used to place a document within a
272 broad category of documents and set some fundamental formatting
273 properties. For Python documentation, two classes are used: the
274 \code{manual} class and the \code{howto} class. These classes also
275 define the additional markup used to document Python concepts and
276 structures. Specific information about these classes is provided in
277 section \ref{classes}, ``Document Classes,'' below. The first thing
278 in the preamble is the declaration of the document's class.
279
280 After the class declaration, a number of \emph{macros} are used to
281 provide further information about the document and setup any
282 additional markup that is needed. No output is generated from the
283 preamble; it is an error to include free text in the preamble
284 because it would cause output.
285
286 The document body follows the preamble. This contains all the
287 printed components of the document marked up structurally. Generic
288 \LaTeX{} structures include hierarchical sections, numbered and
289 bulleted lists, and special structures for the document abstract and
290 indexes.
291
292 \subsection{Syntax \label{latex-syntax}}
293
294 There are some things that an author of Python documentation needs
295 to know about \LaTeX{} syntax.
296
297 A \dfn{comment} is started by the ``percent'' character
298 (\character{\%}) and continues through the end of the line
299 \emph{and all leading whitespace on the following line}. This is
300 a little different from any programming language I know of, so an
301 example is in order:
302
303\begin{verbatim}
304This is text.% comment
305 This is more text. % another comment
306Still more text.
307\end{verbatim}
308
309 The first non-comment character following the first comment is the
310 letter \character{T} on the second line; the leading whitespace on
311 that line is consumed as part of the first comment. This means
312 that there is no space between the first and second sentences, so
313 the period and letter \character{T} will be directly adjacent in
314 the typeset document.
315
316 Note also that though the first non-comment character after the
317 second comment is the letter \character{S}, there is whitespace
318 preceding the comment, so the two sentences are separated as
319 expected.
320
321 A \dfn{group} is an enclosure for a collection of text and
322 commands which encloses the formatting context and constrains the
323 scope of any changes to that context made by commands within the
324 group. Groups can be nested hierarchically. The formatting
325 context includes the font and the definition of additional macros
326 (or overrides of macros defined in outer groups). Syntactically,
327 groups are enclosed in braces:
328
329\begin{verbatim}
330{text in a group}
331\end{verbatim}
332
333 An alternate syntax for a group using brackets, \code{[...]}, is
334 used by macros and environment constructors which take optional
335 parameters; brackets do not normally hold syntactic significance.
336 A degenerate group, containing only one atomic bit of content,
337 does not need to have an explicit group, unless it is required to
338 avoid ambiguity. Since Python tends toward the explicit, groups
339 are also made explicit in the documentation markup.
340
341 Groups are used only sparingly in the Python documentation, except
342 for their use in marking parameters to macros and environments.
343
344 A \dfn{macro} is usually a simple construct which is identified by
345 name and can take some number of parameters. In normal \LaTeX{}
346 usage, one of these can be optional. The markup is introduced
347 using the backslash character (\character{\e}), and the name is
348 given by alphabetic characters (no digits, hyphens, or
349 underscores). Required parameters should be marked as a group,
350 and optional parameters should be marked using the alternate
351 syntax for a group.
352
353 For example, a macro which takes a single parameter
354 would appear like this:
355
356\begin{verbatim}
357\name{parameter}
358\end{verbatim}
359
360 A macro which takes an optional parameter would be typed like this
361 when the optional parameter is given:
362
363\begin{verbatim}
364\name[optional]
365\end{verbatim}
366
367 If both optional and required parameters are to be required, it
368 looks like this:
369
370\begin{verbatim}
371\name[optional]{required}
372\end{verbatim}
373
374 A macro name may be followed by a space or newline; a space
375 between the macro name and any parameters will be consumed, but
376 this usage is not practiced in the Python documentation. Such a
377 space is still consumed if there are no parameters to the macro,
378 in which case inserting an empty group (\code{\{\}}) or explicit
379 word space (\samp{\e\ }) immediately after the macro name helps to
380 avoid running the expansion of the macro into the following text.
381 Macros which take no parameters but which should not be followed
382 by a word space do not need special treatment if the following
383 character in the document source if not a name character (such as
384 punctuation).
385
386 Each line of this example shows an appropriate way to write text
387 which includes a macro which takes no parameters:
388
389\begin{verbatim}
390This \UNIX{} is followed by a space.
391This \UNIX\ is also followed by a space.
392\UNIX, followed by a comma, needs no additional markup.
393\end{verbatim}
394
395 An \dfn{environment} is a larger construct than a macro, and can
396 be used for things with more content than would conveniently fit
397 in a macro parameter. They are primarily used when formatting
398 parameters need to be changed before and after a large chunk of
399 content, but the content itself needs to be highly flexible. Code
400 samples are presented using an environment, and descriptions of
401 functions, methods, and classes are also marked using environments.
402
403 Since the content of an environment is free-form and can consist
404 of several paragraphs, they are actually marked using a pair of
405 macros: \macro{begin} and \macro{end}. These macros both take the
406 name of the environment as a parameter. An example is the
407 environment used to mark the abstract of a document:
408
409\begin{verbatim}
410\begin{abstract}
411 This is the text of the abstract. It concisely explains what
412 information is found in the document.
413
414 It can consist of multiple paragraphs.
415\end{abstract}
416\end{verbatim}
417
418 An environment can also have required and optional parameters of
419 its own. These follow the parameter of the \macro{begin} macro.
420 This example shows an environment which takes a single required
421 parameter:
422
423\begin{verbatim}
424\begin{datadesc}{controlnames}
425 A 33-element string array that contains the \ASCII{} mnemonics for
426 the thirty-two \ASCII{} control characters from 0 (NUL) to 0x1f
427 (US), in order, plus the mnemonic \samp{SP} for the space character.
428\end{datadesc}
429\end{verbatim}
430
431 There are a number of less-used marks in \LaTeX{} which are used
432 to enter characters which are not found in \ASCII{} or which a
433 considered special, or \emph{active} in \TeX{} or \LaTeX. Given
434 that these are often used adjacent to other characters, the markup
435 required to produce the proper character may need to be followed
436 by a space or an empty group, or the markup can be enclosed in a
437 group. Some which are found in Python documentation are:
438
439\begin{tableii}{c|l}{textrm}{Character}{Markup}
440 \lineii{\textasciicircum}{\code{\e textasciicircum}}
441 \lineii{\textasciitilde}{\code{\e textasciitilde}}
442 \lineii{\textgreater}{\code{\e textgreater}}
443 \lineii{\textless}{\code{\e textless}}
444 \lineii{\c c}{\code{\e c c}}
445 \lineii{\"o}{\code{\e"o}}
446 \lineii{\o}{\code{\e o}}
447\end{tableii}
448
449
450 \subsection{Hierarchical Structure \label{latex-structure}}
451
452 \LaTeX{} expects documents to be arranged in a conventional,
453 hierarchical way, with chapters, sections, sub-sections,
454 appendixes, and the like. These are marked using macros rather
455 than environments, probably because the end of a section can be
456 safely inferred when a section of equal or higher level starts.
457
458 There are six ``levels'' of sectioning in the document classes
459 used for Python documentation, and the deepest two
460 levels\footnote{The deepest levels have the highest numbers in the
461 table.} are not used. The levels are:
462
463 \begin{tableiii}{c|l|c}{textrm}{Level}{Macro Name}{Notes}
464 \lineiii{1}{\macro{chapter}}{(1)}
465 \lineiii{2}{\macro{section}}{}
466 \lineiii{3}{\macro{subsection}}{}
467 \lineiii{4}{\macro{subsubsection}}{}
468 \lineiii{5}{\macro{paragraph}}{(2)}
469 \lineiii{6}{\macro{subparagraph}}{}
470 \end{tableiii}
471
472 \noindent
473 Notes:
474
475 \begin{description}
476 \item[(1)]
477 Only used for the \code{manual} documents, as described in
478 section \ref{classes}, ``Document Classes.''
479 \item[(2)]
480 Not the same as a paragraph of text; nobody seems to use this.
481 \end{description}
482
483
484 \subsection{Common Environments \label{latex-environments}}
485
486 \LaTeX{} provides a variety of environments even without the
487 additional markup provided by the Python-specific document classes
488 introduced in the next section. The following environments are
489 provided as part of standard \LaTeX{} and are being used in the
490 standard Python documentation; descriptions will be added here as
491 time allows.
492
493\begin{verbatim}
494abstract
495alltt
496description
497displaymath
498document
499enumerate
500figure
501flushleft
502itemize
503list
504math
505quotation
506quote
507sloppypar
508verbatim
509\end{verbatim}
510
511
512\section{Document Classes \label{classes}}
513
514 Two \LaTeX{} document classes are defined specifically for use with
515 the Python documentation. The \code{manual} class is for large
516 documents which are sectioned into chapters, and the \code{howto}
517 class is for smaller documents.
518
519 The \code{manual} documents are larger and are used for most of the
520 standard documents. This document class is based on the standard
521 \LaTeX{} \code{report} class and is formatted very much like a long
522 technical report. The \citetitle[../ref/ref.html]{Python Reference
523 Manual} is a good example of a \code{manual} document, and the
524 \citetitle[../lib/lib.html]{Python Library Reference} is a large
525 example.
526
527 The \code{howto} documents are shorter, and don't have the large
528 structure of the \code{manual} documents. This class is based on
529 the standard \LaTeX{} \code{article} class and is formatted somewhat
530 like the Linux Documentation Project's ``HOWTO'' series as done
531 originally using the LinuxDoc software. The original intent for the
532 document class was that it serve a similar role as the LDP's HOWTO
533 series, but the applicability of the class turns out to be somewhat
534 broader. This class is used for ``how-to'' documents (this
535 document is an example) and for shorter reference manuals for small,
536 fairly cohesive module libraries. Examples of the later use include
537\citetitle[http://starship.python.net/crew/fdrake/manuals/krb5py/krb5py.html]{Using
538 Kerberos from Python}, which contains reference material for an
539 extension package. These documents are roughly equivalent to a
540 single chapter from a larger work.
541
542
543\section{Special Markup Constructs \label{special-constructs}}
544
545 The Python document classes define a lot of new environments and
546 macros. This section contains the reference material for these
547 facilities. Documentation for ``standard'' \LaTeX{} constructs is
548 not included here, though they are used in the Python documentation.
549
550 \subsection{Markup for the Preamble \label{preamble-info}}
551
552 \begin{macrodesc}{release}{\p{ver}}
553 Set the version number for the software described in the
554 document.
555 \end{macrodesc}
556
557 \begin{macrodesc}{setshortversion}{\p{sver}}
558 Specify the ``short'' version number of the documented software
559 to be \var{sver}.
560 \end{macrodesc}
561
562 \subsection{Meta-information Markup \label{meta-info}}
563
564 \begin{macrodesc}{sectionauthor}{\p{author}\p{email}}
565 Identifies the author of the current section. \var{author}
566 should be the author's name such that it can be used for
567 presentation (though it isn't), and \var{email} should be the
568 author's email address. The domain name portion of
569 the address should be lower case.
570
571 No presentation is generated from this markup, but it is used to
572 help keep track of contributions.
573 \end{macrodesc}
574
575 \subsection{Information Units \label{info-units}}
576
577 XXX Explain terminology, or come up with something more ``lay.''
578
579 There are a number of environments used to describe specific
580 features provided by modules. Each environment requires
581 parameters needed to provide basic information about what is being
582 described, and the environment content should be the description.
583 Most of these environments make entries in the general index (if
584 one is being produced for the document); if no index entry is
585 desired, non-indexing variants are available for many of these
586 environments. The environments have names of the form
587 \code{\var{feature}desc}, and the non-indexing variants are named
588 \code{\var{feature}descni}. The available variants are explicitly
589 included in the list below.
590
591 For each of these environments, the first parameter, \var{name},
592 provides the name by which the feature is accessed.
593
594 Environments which describe features of objects within a module,
595 such as object methods or data attributes, allow an optional
596 \var{type name} parameter. When the feature is an attribute of
597 class instances, \var{type name} only needs to be given if the
598 class was not the most recently described class in the module; the
599 \var{name} value from the most recent \env{classdesc} is implied.
600 For features of built-in or extension types, the \var{type name}
601 value should always be provided. Another special case includes
602 methods and members of general ``protocols,'' such as the
603 formatter and writer protocols described for the
604 \module{formatter} module: these may be documented without any
605 specific implementation classes, and will always require the
606 \var{type name} parameter to be provided.
607
608 \begin{envdesc}{cfuncdesc}{\p{type}\p{name}\p{args}}
609 Environment used to described a C function. The \var{type}
610 should be specified as a \keyword{typedef} name, \code{struct
611 \var{tag}}, or the name of a primitive type. If it is a pointer
612 type, the trailing asterisk should not be preceded by a space.
613 \var{name} should be the name of the function (or function-like
614 pre-processor macro), and \var{args} should give the types and
615 names of the parameters. The names need to be given so they may
616 be used in the description.
617 \end{envdesc}
618
619 \begin{envdesc}{cmemberdesc}{\p{container}\p{type}\p{name}}
620 Description for a structure member. \var{container} should be
621 the \keyword{typedef} name, if there is one, otherwise if should
622 be \samp{struct \var{tag}}. The type of the member should given
623 as \var{type}, and the name should be given as \var{name}. The
624 text of the description should include the range of values
625 allowed, how the value should be interpreted, and whether the
626 value can be changed. References to structure members in text
627 should use the \macro{member} macro.
628 \end{envdesc}
629
630 \begin{envdesc}{csimplemacrodesc}{\p{name}}
631 Documentation for a ``simple'' macro. Simple macros are macros
632 which are used for code expansion, but which do not take
633 arguments so cannot be described as functions. This is not to
634 be used for simple constant definitions. Examples of its use
635 in the Python documentation include
636 \csimplemacro{PyObject_HEAD} and
637 \csimplemacro{Py_BEGIN_ALLOW_THREADS}.
638 \end{envdesc}
639
640 \begin{envdesc}{ctypedesc}{\op{tag}\p{name}}
641 Environment used to described a C type. The \var{name}
642 parameter should be the \keyword{typedef} name. If the type is
643 defined as a \keyword{struct} without a \keyword{typedef},
644 \var{name} should have the form \code{struct \var{tag}}.
645 \var{name} will be added to the index unless \var{tag} is
646 provided, in which case \var{tag} will be used instead.
647 \var{tag} should not be used for a \keyword{typedef} name.
648 \end{envdesc}
649
650 \begin{envdesc}{cvardesc}{\p{type}\p{name}}
651 Description of a global C variable. \var{type} should be the
652 \keyword{typedef} name, \code{struct \var{tag}}, or the name of
653 a primitive type. If variable has a pointer type, the trailing
654 asterisk should \emph{not} be preceded by a space.
655 \end{envdesc}
656
657 \begin{envdesc}{datadesc}{\p{name}}
658 This environment is used to document global data in a module,
659 including both variables and values used as ``defined
660 constants.'' Class and object attributes are not documented
661 using this environment.
662 \end{envdesc}
663 \begin{envdesc}{datadescni}{\p{name}}
664 Like \env{datadesc}, but without creating any index entries.
665 \end{envdesc}
666
667 \begin{envdesc}{excclassdesc}{\p{name}\p{constructor parameters}}
668 Describe an exception defined by a class. \var{constructor
669 parameters} should not include the \var{self} parameter or
670 the parentheses used in the call syntax. To describe an
671 exception class without describing the parameters to its
672 constructor, use the \env{excdesc} environment.
673 \end{envdesc}
674
675 \begin{envdesc}{excdesc}{\p{name}}
676 Describe an exception. In the case of class exceptions, the
677 constructor parameters are not described; use \env{excclassdesc}
678 to describe an exception class and its constructor.
679 \end{envdesc}
680
681 \begin{envdesc}{funcdesc}{\p{name}\p{parameters}}
682 Describe a module-level function. \var{parameters} should
683 not include the parentheses used in the call syntax. Object
684 methods are not documented using this environment. Bound object
685 methods placed in the module namespace as part of the public
686 interface of the module are documented using this, as they are
687 equivalent to normal functions for most purposes.
688
689 The description should include information about the parameters
690 required and how they are used (especially whether mutable
691 objects passed as parameters are modified), side effects, and
692 possible exceptions. A small example may be provided.
693 \end{envdesc}
694 \begin{envdesc}{funcdescni}{\p{name}\p{parameters}}
695 Like \env{funcdesc}, but without creating any index entries.
696 \end{envdesc}
697
698 \begin{envdesc}{classdesc}{\p{name}\p{constructor parameters}}
699 Describe a class and its constructor. \var{constructor
700 parameters} should not include the \var{self} parameter or
701 the parentheses used in the call syntax.
702 \end{envdesc}
703
704 \begin{envdesc}{classdesc*}{\p{name}}
705 Describe a class without describing the constructor. This can
706 be used to describe classes that are merely containers for
707 attributes or which should never be instantiated or subclassed
708 by user code.
709 \end{envdesc}
710
711 \begin{envdesc}{memberdesc}{\op{type name}\p{name}}
712 Describe an object data attribute. The description should
713 include information about the type of the data to be expected
714 and whether it may be changed directly.
715 \end{envdesc}
716 \begin{envdesc}{memberdescni}{\op{type name}\p{name}}
717 Like \env{memberdesc}, but without creating any index entries.
718 \end{envdesc}
719
720 \begin{envdesc}{methoddesc}{\op{type name}\p{name}\p{parameters}}
721 Describe an object method. \var{parameters} should not include
722 the \var{self} parameter or the parentheses used in the call
723 syntax. The description should include similar information to
724 that described for \env{funcdesc}.
725 \end{envdesc}
726 \begin{envdesc}{methoddescni}{\op{type name}\p{name}\p{parameters}}
727 Like \env{methoddesc}, but without creating any index entries.
728 \end{envdesc}
729
730
731 \subsection{Showing Code Examples \label{showing-examples}}
732
733 Examples of Python source code or interactive sessions are
734 represented as \env{verbatim} environments. This environment
735 is a standard part of \LaTeX{}. It is important to only use
736 spaces for indentation in code examples since \TeX{} drops tabs
737 instead of converting them to spaces.
738
739 Representing an interactive session requires including the prompts
740 and output along with the Python code. No special markup is
741 required for interactive sessions. After the last line of input
742 or output presented, there should not be an ``unused'' primary
743 prompt; this is an example of what \emph{not} to do:
744
745\begin{verbatim}
746>>> 1 + 1
7472
748>>>
749\end{verbatim}
750
751 Within the \env{verbatim} environment, characters special to
752 \LaTeX{} do not need to be specially marked in any way. The entire
753 example will be presented in a monospaced font; no attempt at
754 ``pretty-printing'' is made, as the environment must work for
755 non-Python code and non-code displays. There should be no blank
756 lines at the top or bottom of any \env{verbatim} display.
757
758 Longer displays of verbatim text may be included by storing the
759 example text in an external file containing only plain text. The
760 file may be included using the standard \macro{verbatiminput}
761 macro; this macro takes a single argument naming the file
762 containing the text. For example, to include the Python source
763 file \file{example.py}, use:
764
765\begin{verbatim}
766\verbatiminput{example.py}
767\end{verbatim}
768
769 Use of \macro{verbatiminput} allows easier use of special editing
770 modes for the included file. The file should be placed in the
771 same directory as the \LaTeX{} files for the document.
772
773 The Python Documentation Special Interest Group has discussed a
774 number of approaches to creating pretty-printed code displays and
775 interactive sessions; see the Doc-SIG area on the Python Web site
776 for more information on this topic.
777
778
779 \subsection{Inline Markup \label{inline-markup}}
780
781 The macros described in this section are used to mark just about
782 anything interesting in the document text. They may be used in
783 headings (though anything involving hyperlinks should be avoided
784 there) as well as in the body text.
785
786 \begin{macrodesc}{bfcode}{\p{text}}
787 Like \macro{code}, but also makes the font bold-face.
788 \end{macrodesc}
789
790 \begin{macrodesc}{cdata}{\p{name}}
791 The name of a C-language variable.
792 \end{macrodesc}
793
794 \begin{macrodesc}{cfunction}{\p{name}}
795 The name of a C-language function. \var{name} should include the
796 function name and the trailing parentheses.
797 \end{macrodesc}
798
799 \begin{macrodesc}{character}{\p{char}}
800 A character when discussing the character rather than a one-byte
801 string value. The character will be typeset as with \macro{samp}.
802 \end{macrodesc}
803
804 \begin{macrodesc}{citetitle}{\op{url}\p{title}}
805 A title for a referenced publication. If \var{url} is specified,
806 the title will be made into a hyperlink when formatted as HTML.
807 \end{macrodesc}
808
809 \begin{macrodesc}{class}{\p{name}}
810 A class name; a dotted name may be used.
811 \end{macrodesc}
812
813 \begin{macrodesc}{code}{\p{text}}
814 A short code fragment or literal constant value. Typically, it
815 should not include any spaces since no quotation marks are
816 added.
817 \end{macrodesc}
818
819 \begin{macrodesc}{constant}{\p{name}}
820 The name of a ``defined'' constant. This may be a C-language
821 \code{\#define} or a Python variable that is not intended to be
822 changed.
823 \end{macrodesc}
824
825 \begin{macrodesc}{csimplemacro}{\p{name}}
826 The name of a ``simple'' macro. Simple macros are macros
827 which are used for code expansion, but which do not take
828 arguments so cannot be described as functions. This is not to
829 be used for simple constant definitions. Examples of its use
830 in the Python documentation include
831 \csimplemacro{PyObject_HEAD} and
832 \csimplemacro{Py_BEGIN_ALLOW_THREADS}.
833 \end{macrodesc}
834
835 \begin{macrodesc}{ctype}{\p{name}}
836 The name of a C \keyword{typedef} or structure. For structures
837 defined without a \keyword{typedef}, use \code{\e ctype\{struct
838 struct_tag\}} to make it clear that the \keyword{struct} is
839 required.
840 \end{macrodesc}
841
842 \begin{macrodesc}{deprecated}{\p{version}\p{what to do}}
843 Declare whatever is being described as being deprecated starting
844 with release \var{version}. The text given as \var{what to do}
845 should recommend something to use instead. It should be
846 complete sentences. The entire deprecation notice will be
847 presented as a separate paragraph; it should either precede or
848 succeed the description of the deprecated feature.
849 \end{macrodesc}
850
851 \begin{macrodesc}{dfn}{\p{term}}
852 Mark the defining instance of \var{term} in the text. (No index
853 entries are generated.)
854 \end{macrodesc}
855
856 \begin{macrodesc}{e}{}
857 Produces a backslash. This is convenient in \macro{code},
858 \macro{file}, and similar macros, and the \env{alltt}
859 environment, and is only defined there. To
860 create a backslash in ordinary text (such as the contents of the
861 \macro{citetitle} macro), use the standard \macro{textbackslash}
862 macro.
863 \end{macrodesc}
864
865 \begin{macrodesc}{email}{\p{address}}
866 An email address. Note that this is \emph{not} hyperlinked in
867 any of the possible output formats. The domain name portion of
868 the address should be lower case.
869 \end{macrodesc}
870
871 \begin{macrodesc}{emph}{\p{text}}
872 Emphasized text; this will be presented in an italic font.
873 \end{macrodesc}
874
875 \begin{macrodesc}{envvar}{\p{name}}
876 An environment variable. Index entries are generated.
877 \end{macrodesc}
878
879 \begin{macrodesc}{exception}{\p{name}}
880 The name of an exception. A dotted name may be used.
881 \end{macrodesc}
882
883 \begin{macrodesc}{file}{\p{file or dir}}
884 The name of a file or directory. In the PDF and PostScript
885 outputs, single quotes and a font change are used to indicate
886 the file name, but no quotes are used in the HTML output.
887 \warning{The \macro{file} macro cannot be used in the
888 content of a section title due to processing limitations.}
889 \end{macrodesc}
890
891 \begin{macrodesc}{filenq}{\p{file or dir}}
892 Like \macro{file}, but single quotes are never used. This can
893 be used in conjunction with tables if a column will only contain
894 file or directory names.
895 \warning{The \macro{filenq} macro cannot be used in the
896 content of a section title due to processing limitations.}
897 \end{macrodesc}
898
899 \begin{macrodesc}{function}{\p{name}}
900 The name of a Python function; dotted names may be used.
901 \end{macrodesc}
902
903 \begin{macrodesc}{infinity}{}
904 The symbol for mathematical infinity: \infinity. Some Web
905 browsers are not able to render the HTML representation of this
906 symbol properly, but support is growing.
907 \end{macrodesc}
908
909 \begin{macrodesc}{kbd}{\p{key sequence}}
910 Mark a sequence of keystrokes. What form \var{key sequence}
911 takes may depend on platform- or application-specific
912 conventions. When there are no relevant conventions, the names
913 of modifier keys should be spelled out, to improve accessibility
914 for new users and non-native speakers. For example, an
915 \program{xemacs} key sequence may be marked like
916 \code{\e kbd\{C-x C-f\}}, but without reference to a specific
917 application or platform, the same sequence should be marked as
918 \code{\e kbd\{Control-x Control-f\}}.
919 \end{macrodesc}
920
921 \begin{macrodesc}{keyword}{\p{name}}
922 The name of a keyword in a programming language.
923 \end{macrodesc}
924
925 \begin{macrodesc}{mailheader}{\p{name}}
926 The name of an \rfc{822}-style mail header. This markup does
927 not imply that the header is being used in an email message, but
928 can be used to refer to any header of the same ``style.'' This
929 is also used for headers defined by the various MIME
930 specifications. The header name should be entered in the same
931 way it would normally be found in practice, with the
932 camel-casing conventions being preferred where there is more
933 than one common usage. The colon which follows the name of the
934 header should not be included.
935 For example: \code{\e mailheader\{Content-Type\}}.
936 \end{macrodesc}
937
938 \begin{macrodesc}{makevar}{\p{name}}
939 The name of a \program{make} variable.
940 \end{macrodesc}
941
942 \begin{macrodesc}{manpage}{\p{name}\p{section}}
943 A reference to a \UNIX{} manual page.
944 \end{macrodesc}
945
946 \begin{macrodesc}{member}{\p{name}}
947 The name of a data attribute of an object.
948 \end{macrodesc}
949
950 \begin{macrodesc}{method}{\p{name}}
951 The name of a method of an object. \var{name} should include the
952 method name and the trailing parentheses. A dotted name may be
953 used.
954 \end{macrodesc}
955
956 \begin{macrodesc}{mimetype}{\p{name}}
957 The name of a MIME type, or a component of a MIME type (the
958 major or minor portion, taken alone).
959 \end{macrodesc}
960
961 \begin{macrodesc}{module}{\p{name}}
962 The name of a module; a dotted name may be used. This should
963 also be used for package names.
964 \end{macrodesc}
965
966 \begin{macrodesc}{newsgroup}{\p{name}}
967 The name of a Usenet newsgroup.
968 \end{macrodesc}
969
970 \begin{macrodesc}{note}{\p{text}}
971 An especially important bit of information about an API that a
972 user should be aware of when using whatever bit of API the
973 note pertains to. This should be the last thing in the
974 paragraph as the end of the note is not visually marked in
975 any way. The content of \var{text} should be written in
976 complete sentences and include all appropriate punctuation.
977 \end{macrodesc}
978
979 \begin{macrodesc}{pep}{\p{number}}
980 A reference to a Python Enhancement Proposal. This generates
981 appropriate index entries. The text \samp{PEP \var{number}} is
982 generated; in the HTML output, this text is a hyperlink to an
983 online copy of the specified PEP.
984 \end{macrodesc}
985
986 \begin{macrodesc}{plusminus}{}
987 The symbol for indicating a value that may take a positive or
988 negative value of a specified magnitude, typically represented
989 by a plus sign placed over a minus sign. For example:
990 \code{\e plusminus 3\%{}}.
991 \end{macrodesc}
992
993 \begin{macrodesc}{program}{\p{name}}
994 The name of an executable program. This may differ from the
995 file name for the executable for some platforms. In particular,
996 the \file{.exe} (or other) extension should be omitted for
997 Windows programs.
998 \end{macrodesc}
999
1000 \begin{macrodesc}{programopt}{\p{option}}
1001 A command-line option to an executable program. Use this only
1002 for ``short'' options, and include the leading hyphen.
1003 \end{macrodesc}
1004
1005 \begin{macrodesc}{longprogramopt}{\p{option}}
1006 A long command-line option to an executable program. This
1007 should only be used for long option names which will be prefixed
1008 by two hyphens; the hyphens should not be provided as part of
1009 \var{option}.
1010 \end{macrodesc}
1011
1012 \begin{macrodesc}{refmodule}{\op{key}\p{name}}
1013 Like \macro{module}, but create a hyperlink to the documentation
1014 for the named module. Note that the corresponding
1015 \macro{declaremodule} must be in the same document. If the
1016 \macro{declaremodule} defines a module key different from the
1017 module name, it must also be provided as \var{key} to the
1018 \macro{refmodule} macro.
1019 \end{macrodesc}
1020
1021 \begin{macrodesc}{regexp}{\p{string}}
1022 Mark a regular expression.
1023 \end{macrodesc}
1024
1025 \begin{macrodesc}{rfc}{\p{number}}
1026 A reference to an Internet Request for Comments. This generates
1027 appropriate index entries. The text \samp{RFC \var{number}} is
1028 generated; in the HTML output, this text is a hyperlink to an
1029 online copy of the specified RFC.
1030 \end{macrodesc}
1031
1032 \begin{macrodesc}{samp}{\p{text}}
1033 A short code sample, but possibly longer than would be given
1034 using \macro{code}. Since quotation marks are added, spaces are
1035 acceptable.
1036 \end{macrodesc}
1037
1038 \begin{macrodesc}{shortversion}{}
1039 The ``short'' version number of the documented software, as
1040 specified using the \macro{setshortversion} macro in the
1041 preamble. For Python, the short version number for a release is
1042 the first three characters of the \code{sys.version} value. For
1043 example, versions 2.0b1 and 2.0.1 both have a short version of
1044 2.0. This may not apply for all packages; if
1045 \macro{setshortversion} is not used, this produces an empty
1046 expansion. See also the \macro{version} macro.
1047 \end{macrodesc}
1048
1049 \begin{macrodesc}{strong}{\p{text}}
1050 Strongly emphasized text; this will be presented using a bold
1051 font.
1052 \end{macrodesc}
1053
1054 \begin{macrodesc}{ulink}{\p{text}\p{url}}
1055 A hypertext link with a target specified by a URL, but for which
1056 the link text should not be the title of the resource. For
1057 resources being referenced by name, use the \macro{citetitle}
1058 macro. Not all formatted versions support arbitrary hypertext
1059 links. Note that many characters are special to \LaTeX{} and
1060 this macro does not always do the right thing. In particular,
1061 the tilde character (\character{\~}) is mis-handled; encoding it
1062 as a hex-sequence does work, use \samp{\%7e} in place of the
1063 tilde character.
1064 \end{macrodesc}
1065
1066 \begin{macrodesc}{url}{\p{url}}
1067 A URL (or URN). The URL will be presented as text. In the HTML
1068 and PDF formatted versions, the URL will also be a hyperlink.
1069 This can be used when referring to external resources without
1070 specific titles; references to resources which have titles
1071 should be marked using the \macro{citetitle} macro. See the
1072 comments about special characters in the description of the
1073 \macro{ulink} macro for special considerations.
1074 \end{macrodesc}
1075
1076 \begin{macrodesc}{var}{\p{name}}
1077 The name of a variable or formal parameter in running text.
1078 \end{macrodesc}
1079
1080 \begin{macrodesc}{version}{}
1081 The version number of the described software, as specified using
1082 \macro{release} in the preamble. See also the
1083 \macro{shortversion} macro.
1084 \end{macrodesc}
1085
1086 \begin{macrodesc}{warning}{\p{text}}
1087 An important bit of information about an API that a user should
1088 be very aware of when using whatever bit of API the warning
1089 pertains to. This should be the last thing in the paragraph as
1090 the end of the warning is not visually marked in any way. The
1091 content of \var{text} should be written in complete sentences
1092 and include all appropriate punctuation. This differs from
1093 \macro{note} in that it is recommended over \macro{note} for
1094 information regarding security.
1095 \end{macrodesc}
1096
1097 The following two macros are used to describe information that's
1098 associated with changes from one release to another. For features
1099 which are described by a single paragraph, these are typically
1100 added as separate source lines at the end of the paragraph. When
1101 adding these to features described by multiple paragraphs, they
1102 are usually collected in a single separate paragraph after the
1103 description. When both \macro{versionadded} and
1104 \macro{versionchanged} are used, \macro{versionadded} should come
1105 first; the versions should be listed in chronological order. Both
1106 of these should come before availability statements. The location
1107 should be selected so the explanation makes sense and may vary as
1108 needed.
1109
1110 \begin{macrodesc}{versionadded}{\op{explanation}\p{version}}
1111 The version of Python which added the described feature to the
1112 library or C API. \var{explanation} should be a \emph{brief}
1113 explanation of the change consisting of a capitalized sentence
1114 fragment; a period will be appended by the formatting process.
1115 When this applies to an entire module, it should be placed at
1116 the top of the module section before any prose.
1117 \end{macrodesc}
1118
1119 \begin{macrodesc}{versionchanged}{\op{explanation}\p{version}}
1120 The version of Python in which the named feature was changed in
1121 some way (new parameters, changed side effects, etc.).
1122 \var{explanation} should be a \emph{brief} explanation of the
1123 change consisting of a capitalized sentence fragment; a
1124 period will be appended by the formatting process. This should
1125 not generally be applied to modules.
1126 \end{macrodesc}
1127
1128
1129 \subsection{Miscellaneous Text Markup \label{misc-text-markup}}
1130
1131 In addition to the inline markup, some additional ``block'' markup
1132 is defined to make it easier to bring attention to various bits of
1133 text. The markup described here serves this purpose, and is
1134 intended to be used when marking one or more paragraphs or other
1135 block constructs (such as \env{verbatim} environments).
1136
1137 \begin{envdesc}{notice}{\op{type}}
1138 Label some paragraphs as being worthy of additional attention from
1139 the reader. What sort of attention is warranted can be indicated
1140 by specifying the \var{type} of the notice. The only values
1141 defined for \var{type} are \code{note} and \code{warning}; these
1142 are equivalent in intent to the inline markup of the same name.
1143 If \var{type} is omitted, \code{note} is used. Additional values
1144 may be defined in the future.
1145 \end{envdesc}
1146
1147
1148 \subsection{Module-specific Markup \label{module-markup}}
1149
1150 The markup described in this section is used to provide information
1151 about a module being documented. Each module should be documented
1152 in its own \macro{section}. A typical use of this markup
1153 appears at the top of that section and might look like this:
1154
1155\begin{verbatim}
1156\section{\module{spam} ---
1157 Access to the SPAM facility}
1158
1159\declaremodule{extension}{spam}
1160 \platform{Unix}
1161\modulesynopsis{Access to the SPAM facility of \UNIX.}
1162\moduleauthor{Jane Doe}{jane.doe@frobnitz.org}
1163\end{verbatim}
1164
1165 Python packages\index{packages} --- collections of modules that can
1166 be described as a unit --- are documented using the same markup as
1167 modules. The name for a module in a package should be typed in
1168 ``fully qualified'' form (it should include the package name).
1169 For example, a module ``foo'' in package ``bar'' should be marked as
1170 \code{\e module\{bar.foo\}}, and the beginning of the reference
1171 section would appear as:
1172
1173\begin{verbatim}
1174\section{\module{bar.foo} ---
1175 Module from the \module{bar} package}
1176
1177\declaremodule{extension}{bar.foo}
1178\modulesynopsis{Nifty module from the \module{bar} package.}
1179\moduleauthor{Jane Doe}{jane.doe@frobnitz.org}
1180\end{verbatim}
1181
1182 Note that the name of a package is also marked using
1183 \macro{module}.
1184
1185 \begin{macrodesc}{declaremodule}{\op{key}\p{type}\p{name}}
1186 Requires two parameters: module type (\samp{standard},
1187 \samp{builtin}, \samp{extension}, or \samp{}), and the module
1188 name. An optional parameter should be given as the basis for the
1189 module's ``key'' used for linking to or referencing the section.
1190 The ``key'' should only be given if the module's name contains any
1191 underscores, and should be the name with the underscores stripped.
1192 Note that the \var{type} parameter must be one of the values
1193 listed above or an error will be printed. For modules which are
1194 contained in packages, the fully-qualified name should be given as
1195 \var{name} parameter. This should be the first thing after the
1196 \macro{section} used to introduce the module.
1197 \end{macrodesc}
1198
1199 \begin{macrodesc}{platform}{\p{specifier}}
1200 Specifies the portability of the module. \var{specifier} is a
1201 comma-separated list of keys that specify what platforms the
1202 module is available on. The keys are short identifiers;
1203 examples that are in use include \samp{IRIX}, \samp{Mac},
1204 \samp{Windows}, and \samp{Unix}. It is important to use a key
1205 which has already been used when applicable. This is used to
1206 provide annotations in the Module Index and the HTML and GNU info
1207 output.
1208 \end{macrodesc}
1209
1210 \begin{macrodesc}{modulesynopsis}{\p{text}}
1211 The \var{text} is a short, ``one line'' description of the
1212 module that can be used as part of the chapter introduction.
1213 This is must be placed after \macro{declaremodule}.
1214 The synopsis is used in building the contents of the table
1215 inserted as the \macro{localmoduletable}. No text is
1216 produced at the point of the markup.
1217 \end{macrodesc}
1218
1219 \begin{macrodesc}{moduleauthor}{\p{name}\p{email}}
1220 This macro is used to encode information about who authored a
1221 module. This is currently not used to generate output, but can be
1222 used to help determine the origin of the module.
1223 \end{macrodesc}
1224
1225
1226 \subsection{Library-level Markup \label{library-markup}}
1227
1228 This markup is used when describing a selection of modules. For
1229 example, the \citetitle[../mac/mac.html]{Macintosh Library
1230 Modules} document uses this to help provide an overview of the
1231 modules in the collection, and many chapters in the
1232 \citetitle[../lib/lib.html]{Python Library Reference} use it for
1233 the same purpose.
1234
1235 \begin{macrodesc}{localmoduletable}{}
1236 If a \file{.syn} file exists for the current
1237 chapter (or for the entire document in \code{howto} documents), a
1238 \env{synopsistable} is created with the contents loaded from the
1239 \file{.syn} file.
1240 \end{macrodesc}
1241
1242
1243 \subsection{Table Markup \label{table-markup}}
1244
1245 There are three general-purpose table environments defined which
1246 should be used whenever possible. These environments are defined
1247 to provide tables of specific widths and some convenience for
1248 formatting. These environments are not meant to be general
1249 replacements for the standard \LaTeX{} table environments, but can
1250 be used for an advantage when the documents are processed using
1251 the tools for Python documentation processing. In particular, the
1252 generated HTML looks good! There is also an advantage for the
1253 eventual conversion of the documentation to XML (see section
1254 \ref{futures}, ``Future Directions'').
1255
1256 Each environment is named \env{table\var{cols}}, where \var{cols}
1257 is the number of columns in the table specified in lower-case
1258 Roman numerals. Within each of these environments, an additional
1259 macro, \macro{line\var{cols}}, is defined, where \var{cols}
1260 matches the \var{cols} value of the corresponding table
1261 environment. These are supported for \var{cols} values of
1262 \code{ii}, \code{iii}, and \code{iv}. These environments are all
1263 built on top of the \env{tabular} environment. Variants based on
1264 the \env{longtable} environment are also provided.
1265
1266 Note that all tables in the standard Python documentation use
1267 vertical lines between columns, and this must be specified in the
1268 markup for each table. A general border around the outside of the
1269 table is not used, but would be the responsibility of the
1270 processor; the document markup should not include an exterior
1271 border.
1272
1273 The \env{longtable}-based variants of the table environments are
1274 formatted with extra space before and after, so should only be
1275 used on tables which are long enough that splitting over multiple
1276 pages is reasonable; tables with fewer than twenty rows should
1277 never by marked using the long flavors of the table environments.
1278 The header row is repeated across the top of each part of the
1279 table.
1280
1281 \begin{envdesc}{tableii}{\p{colspec}\p{col1font}\p{heading1}\p{heading2}}
1282 Create a two-column table using the \LaTeX{} column specifier
1283 \var{colspec}. The column specifier should indicate vertical
1284 bars between columns as appropriate for the specific table, but
1285 should not specify vertical bars on the outside of the table
1286 (that is considered a stylesheet issue). The \var{col1font}
1287 parameter is used as a stylistic treatment of the first column
1288 of the table: the first column is presented as
1289 \code{\e\var{col1font}\{column1\}}. To avoid treating the first
1290 column specially, \var{col1font} may be \samp{textrm}. The
1291 column headings are taken from the values \var{heading1} and
1292 \var{heading2}.
1293 \end{envdesc}
1294
1295 \begin{envdesc}{longtableii}{\unspecified}
1296 Like \env{tableii}, but produces a table which may be broken
1297 across page boundaries. The parameters are the same as for
1298 \env{tableii}.
1299 \end{envdesc}
1300
1301 \begin{macrodesc}{lineii}{\p{column1}\p{column2}}
1302 Create a single table row within a \env{tableii} or
1303 \env{longtableii} environment.
1304 The text for the first column will be generated by applying the
1305 macro named by the \var{col1font} value when the \env{tableii}
1306 was opened.
1307 \end{macrodesc}
1308
1309 \begin{envdesc}{tableiii}{\p{colspec}\p{col1font}\p{heading1}\p{heading2}\p{heading3}}
1310 Like the \env{tableii} environment, but with a third column.
1311 The heading for the third column is given by \var{heading3}.
1312 \end{envdesc}
1313
1314 \begin{envdesc}{longtableiii}{\unspecified}
1315 Like \env{tableiii}, but produces a table which may be broken
1316 across page boundaries. The parameters are the same as for
1317 \env{tableiii}.
1318 \end{envdesc}
1319
1320 \begin{macrodesc}{lineiii}{\p{column1}\p{column2}\p{column3}}
1321 Like the \macro{lineii} macro, but with a third column. The
1322 text for the third column is given by \var{column3}.
1323 \end{macrodesc}
1324
1325 \begin{envdesc}{tableiv}{\p{colspec}\p{col1font}\p{heading1}\p{heading2}\p{heading3}\p{heading4}}
1326 Like the \env{tableiii} environment, but with a fourth column.
1327 The heading for the fourth column is given by \var{heading4}.
1328 \end{envdesc}
1329
1330 \begin{envdesc}{longtableiv}{\unspecified}
1331 Like \env{tableiv}, but produces a table which may be broken
1332 across page boundaries. The parameters are the same as for
1333 \env{tableiv}.
1334 \end{envdesc}
1335
1336 \begin{macrodesc}{lineiv}{\p{column1}\p{column2}\p{column3}\p{column4}}
1337 Like the \macro{lineiii} macro, but with a fourth column. The
1338 text for the fourth column is given by \var{column4}.
1339 \end{macrodesc}
1340
1341 \begin{envdesc}{tablev}{\p{colspec}\p{col1font}\p{heading1}\p{heading2}\p{heading3}\p{heading4}\p{heading5}}
1342 Like the \env{tableiv} environment, but with a fifth column.
1343 The heading for the fifth column is given by \var{heading5}.
1344 \end{envdesc}
1345
1346 \begin{envdesc}{longtablev}{\unspecified}
1347 Like \env{tablev}, but produces a table which may be broken
1348 across page boundaries. The parameters are the same as for
1349 \env{tablev}.
1350 \end{envdesc}
1351
1352 \begin{macrodesc}{linev}{\p{column1}\p{column2}\p{column3}\p{column4}\p{column5}}
1353 Like the \macro{lineiv} macro, but with a fifth column. The
1354 text for the fifth column is given by \var{column5}.
1355 \end{macrodesc}
1356
1357
1358 An additional table-like environment is \env{synopsistable}. The
1359 table generated by this environment contains two columns, and each
1360 row is defined by an alternate definition of
1361 \macro{modulesynopsis}. This environment is not normally used by
1362 authors, but is created by the \macro{localmoduletable} macro.
1363
1364 Here is a small example of a table given in the documentation for
1365 the \module{warnings} module; markup inside the table cells is
1366 minimal so the markup for the table itself is readily discernable.
1367 Here is the markup for the table:
1368
1369\begin{verbatim}
1370\begin{tableii}{l|l}{exception}{Class}{Description}
1371 \lineii{Warning}
1372 {This is the base class of all warning category classes. It
1373 is a subclass of \exception{Exception}.}
1374 \lineii{UserWarning}
1375 {The default category for \function{warn()}.}
1376 \lineii{DeprecationWarning}
1377 {Base category for warnings about deprecated features.}
1378 \lineii{SyntaxWarning}
1379 {Base category for warnings about dubious syntactic
1380 features.}
1381 \lineii{RuntimeWarning}
1382 {Base category for warnings about dubious runtime features.}
1383 \lineii{FutureWarning}
1384 {Base category for warnings about constructs that will change
1385 semantically in the future.}
1386\end{tableii}
1387\end{verbatim}
1388
1389 Here is the resulting table:
1390
1391\begin{tableii}{l|l}{exception}{Class}{Description}
1392 \lineii{Warning}
1393 {This is the base class of all warning category classes. It
1394 is a subclass of \exception{Exception}.}
1395 \lineii{UserWarning}
1396 {The default category for \function{warn()}.}
1397 \lineii{DeprecationWarning}
1398 {Base category for warnings about deprecated features.}
1399 \lineii{SyntaxWarning}
1400 {Base category for warnings about dubious syntactic
1401 features.}
1402 \lineii{RuntimeWarning}
1403 {Base category for warnings about dubious runtime features.}
1404\end{tableii}
1405
1406 Note that the class names are implicitly marked using the
1407 \macro{exception} macro, since that is given as the \var{col1font}
1408 value for the \env{tableii} environment. To create a table using
1409 different markup for the first column, use \code{textrm} for the
1410 \var{col1font} value and mark each entry individually.
1411
1412 To add a horizontal line between vertical sections of a table, use
1413 the standard \macro{hline} macro between the rows which should be
1414 separated:
1415
1416\begin{verbatim}
1417\begin{tableii}{l|l}{constant}{Language}{Audience}
1418 \lineii{APL}{Masochists.}
1419 \lineii{BASIC}{First-time programmers on PC hardware.}
1420 \lineii{C}{\UNIX{} \&\ Linux kernel developers.}
1421 \hline
1422 \lineii{Python}{Everyone!}
1423\end{tableii}
1424\end{verbatim}
1425
1426 Note that not all presentation formats are capable of displaying a
1427 horizontal rule in this position. This is how the table looks in
1428 the format you're reading now:
1429
1430\begin{tableii}{l|l}{constant}{Language}{Audience}
1431 \lineii{APL}{Masochists.}
1432 \lineii{C}{\UNIX{} \&\ Linux kernel developers.}
1433 \lineii{JavaScript}{Web developers.}
1434 \hline
1435 \lineii{Python}{Everyone!}
1436\end{tableii}
1437
1438
1439 \subsection{Reference List Markup \label{references}}
1440
1441 Many sections include a list of references to module documentation
1442 or external documents. These lists are created using the
1443 \env{seealso} or \env{seealso*} environments. These environments
1444 define some additional macros to support creating reference
1445 entries in a reasonable manner.
1446
1447 The \env{seealso} environment is typically placed in a section
1448 just before any sub-sections. This is done to ensure that
1449 reference links related to the section are not hidden in a
1450 subsection in the hypertext renditions of the documentation. For
1451 the HTML output, it is shown as a ``side bar,'' boxed off from the
1452 main flow of the text. The \env{seealso*} environment is
1453 different in that it should be used when a list of references is
1454 being presented as part of the primary content; it is not
1455 specially set off from the text.
1456
1457 \begin{envdesc}{seealso}{}
1458 This environment creates a ``See also:'' heading and defines the
1459 markup used to describe individual references.
1460 \end{envdesc}
1461
1462 \begin{envdesc}{seealso*}{}
1463 This environment is used to create a list of references which
1464 form part of the main content. It is not given a special
1465 header and is not set off from the main flow of the text. It
1466 provides the same additional markup used to describe individual
1467 references.
1468 \end{envdesc}
1469
1470 For each of the following macros, \var{why} should be one or more
1471 complete sentences, starting with a capital letter (unless it
1472 starts with an identifier, which should not be modified), and
1473 ending with the appropriate punctuation.
1474
1475 These macros are only defined within the content of the
1476 \env{seealso} and \env{seealso*} environments.
1477
1478 \begin{macrodesc}{seelink}{\p{url}\p{linktext}\p{why}}
1479 References to specific on-line resources should be given using
1480 the \macro{seelink} macro if they don't have a meaningful title
1481 but there is some short description of what's at the end of the
1482 link. Online documents which have identifiable titles should be
1483 referenced using the \macro{seetitle} macro, using the optional
1484 parameter to that macro to provide the URL.
1485 \end{macrodesc}
1486
1487 \begin{macrodesc}{seemodule}{\op{key}\p{name}\p{why}}
1488 Refer to another module. \var{why} should be a brief
1489 explanation of why the reference may be interesting. The module
1490 name is given in \var{name}, with the link key given in
1491 \var{key} if necessary. In the HTML and PDF conversions, the
1492 module name will be a hyperlink to the referred-to module.
1493 \note{The module must be documented in the same
1494 document (the corresponding \macro{declaremodule} is required).}
1495 \end{macrodesc}
1496
1497 \begin{macrodesc}{seepep}{\p{number}\p{title}\p{why}}
1498 Refer to an Python Enhancement Proposal (PEP). \var{number}
1499 should be the official number assigned by the PEP Editor,
1500 \var{title} should be the human-readable title of the PEP as
1501 found in the official copy of the document, and \var{why} should
1502 explain what's interesting about the PEP. This should be used
1503 to refer the reader to PEPs which specify interfaces or language
1504 features relevant to the material in the annotated section of the
1505 documentation.
1506 \end{macrodesc}
1507
1508 \begin{macrodesc}{seerfc}{\p{number}\p{title}\p{why}}
1509 Refer to an IETF Request for Comments (RFC). Otherwise very
1510 similar to \macro{seepep}. This should be used
1511 to refer the reader to PEPs which specify protocols or data
1512 formats relevant to the material in the annotated section of the
1513 documentation.
1514 \end{macrodesc}
1515
1516 \begin{macrodesc}{seetext}{\p{text}}
1517 Add arbitrary text \var{text} to the ``See also:'' list. This
1518 can be used to refer to off-line materials or on-line materials
1519 using the \macro{url} macro. This should consist of one or more
1520 complete sentences.
1521 \end{macrodesc}
1522
1523 \begin{macrodesc}{seetitle}{\op{url}\p{title}\p{why}}
1524 Add a reference to an external document named \var{title}. If
1525 \var{url} is given, the title is made a hyperlink in the HTML
1526 version of the documentation, and displayed below the title in
1527 the typeset versions of the documentation.
1528 \end{macrodesc}
1529
1530 \begin{macrodesc}{seeurl}{\p{url}\p{why}}
1531 References to specific on-line resources should be given using
1532 the \macro{seeurl} macro if they don't have a meaningful title.
1533 Online documents which have identifiable titles should be
1534 referenced using the \macro{seetitle} macro, using the optional
1535 parameter to that macro to provide the URL.
1536 \end{macrodesc}
1537
1538
1539 \subsection{Index-generating Markup \label{indexing}}
1540
1541 Effective index generation for technical documents can be very
1542 difficult, especially for someone familiar with the topic but not
1543 the creation of indexes. Much of the difficulty arises in the
1544 area of terminology: including the terms an expert would use for a
1545 concept is not sufficient. Coming up with the terms that a novice
1546 would look up is fairly difficult for an author who, typically, is
1547 an expert in the area she is writing on.
1548
1549 The truly difficult aspects of index generation are not areas with
1550 which the documentation tools can help. However, ease
1551 of producing the index once content decisions are made is within
1552 the scope of the tools. Markup is provided which the processing
1553 software is able to use to generate a variety of kinds of index
1554 entry with minimal effort. Additionally, many of the environments
1555 described in section \ref{info-units}, ``Information Units,'' will
1556 generate appropriate entries into the general and module indexes.
1557
1558 The following macro can be used to control the generation of index
1559 data, and should be used in the document preamble:
1560
1561 \begin{macrodesc}{makemodindex}{}
1562 This should be used in the document preamble if a ``Module
1563 Index'' is desired for a document containing reference material
1564 on many modules. This causes a data file
1565 \code{lib\var{jobname}.idx} to be created from the
1566 \macro{declaremodule} macros. This file can be processed by the
1567 \program{makeindex} program to generate a file which can be
1568 \macro{input} into the document at the desired location of the
1569 module index.
1570 \end{macrodesc}
1571
1572 There are a number of macros that are useful for adding index
1573 entries for particular concepts, many of which are specific to
1574 programming languages or even Python.
1575
1576 \begin{macrodesc}{bifuncindex}{\p{name}}
1577 Add an index entry referring to a built-in function named
1578 \var{name}; parentheses should not be included after
1579 \var{name}.
1580 \end{macrodesc}
1581
1582 \begin{macrodesc}{exindex}{\p{exception}}
1583 Add a reference to an exception named \var{exception}. The
1584 exception should be class-based.
1585 \end{macrodesc}
1586
1587 \begin{macrodesc}{kwindex}{\p{keyword}}
1588 Add a reference to a language keyword (not a keyword parameter
1589 in a function or method call).
1590 \end{macrodesc}
1591
1592 \begin{macrodesc}{obindex}{\p{object type}}
1593 Add an index entry for a built-in object type.
1594 \end{macrodesc}
1595
1596 \begin{macrodesc}{opindex}{\p{operator}}
1597 Add a reference to an operator, such as \samp{+}.
1598 \end{macrodesc}
1599
1600 \begin{macrodesc}{refmodindex}{\op{key}\p{module}}
1601 Add an index entry for module \var{module}; if \var{module}
1602 contains an underscore, the optional parameter \var{key} should
1603 be provided as the same string with underscores removed. An
1604 index entry ``\var{module} (module)'' will be generated. This
1605 is intended for use with non-standard modules implemented in
1606 Python.
1607 \end{macrodesc}
1608
1609 \begin{macrodesc}{refexmodindex}{\op{key}\p{module}}
1610 As for \macro{refmodindex}, but the index entry will be
1611 ``\var{module} (extension module).'' This is intended for use
1612 with non-standard modules not implemented in Python.
1613 \end{macrodesc}
1614
1615 \begin{macrodesc}{refbimodindex}{\op{key}\p{module}}
1616 As for \macro{refmodindex}, but the index entry will be
1617 ``\var{module} (built-in module).'' This is intended for use
1618 with standard modules not implemented in Python.
1619 \end{macrodesc}
1620
1621 \begin{macrodesc}{refstmodindex}{\op{key}\p{module}}
1622 As for \macro{refmodindex}, but the index entry will be
1623 ``\var{module} (standard module).'' This is intended for use
1624 with standard modules implemented in Python.
1625 \end{macrodesc}
1626
1627 \begin{macrodesc}{stindex}{\p{statement}}
1628 Add an index entry for a statement type, such as \keyword{print}
1629 or \keyword{try}/\keyword{finally}.
1630
1631 XXX Need better examples of difference from \macro{kwindex}.
1632 \end{macrodesc}
1633
1634
1635 Additional macros are provided which are useful for conveniently
1636 creating general index entries which should appear at many places
1637 in the index by rotating a list of words. These are simple macros
1638 that simply use \macro{index} to build some number of index
1639 entries. Index entries build using these macros contain both
1640 primary and secondary text.
1641
1642 \begin{macrodesc}{indexii}{\p{word1}\p{word2}}
1643 Build two index entries. This is exactly equivalent to using
1644 \code{\e index\{\var{word1}!\var{word2}\}} and
1645 \code{\e index\{\var{word2}!\var{word1}\}}.
1646 \end{macrodesc}
1647
1648 \begin{macrodesc}{indexiii}{\p{word1}\p{word2}\p{word3}}
1649 Build three index entries. This is exactly equivalent to using
1650 \code{\e index\{\var{word1}!\var{word2} \var{word3}\}},
1651 \code{\e index\{\var{word2}!\var{word3}, \var{word1}\}}, and
1652 \code{\e index\{\var{word3}!\var{word1} \var{word2}\}}.
1653 \end{macrodesc}
1654
1655 \begin{macrodesc}{indexiv}{\p{word1}\p{word2}\p{word3}\p{word4}}
1656 Build four index entries. This is exactly equivalent to using
1657 \code{\e index\{\var{word1}!\var{word2} \var{word3} \var{word4}\}},
1658 \code{\e index\{\var{word2}!\var{word3} \var{word4}, \var{word1}\}},
1659 \code{\e index\{\var{word3}!\var{word4}, \var{word1} \var{word2}\}},
1660 and
1661 \code{\e index\{\var{word4}!\var{word1} \var{word2} \var{word3}\}}.
1662 \end{macrodesc}
1663
1664 \subsection{Grammar Production Displays \label{grammar-displays}}
1665
1666 Special markup is available for displaying the productions of a
1667 formal grammar. The markup is simple and does not attempt to
1668 model all aspects of BNF (or any derived forms), but provides
1669 enough to allow context-free grammars to be displayed in a way
1670 that causes uses of a symbol to be rendered as hyperlinks to the
1671 definition of the symbol. There is one environment and a pair of
1672 macros:
1673
1674 \begin{envdesc}{productionlist}{\op{language}}
1675 This environment is used to enclose a group of productions. The
1676 two macros are only defined within this environment. If a
1677 document describes more than one language, the optional parameter
1678 \var{language} should be used to distinguish productions between
1679 languages. The value of the parameter should be a short name
1680 that can be used as part of a filename; colons or other
1681 characters that can't be used in filename across platforms
1682 should be included.
1683 \end{envdesc}
1684
1685 \begin{macrodesc}{production}{\p{name}\p{definition}}
1686 A production rule in the grammar. The rule defines the symbol
1687 \var{name} to be \var{definition}. \var{name} should not
1688 contain any markup, and the use of hyphens in a document which
1689 supports more than one grammar is undefined. \var{definition}
1690 may contain \macro{token} macros and any additional content
1691 needed to describe the grammatical model of \var{symbol}. Only
1692 one \macro{production} may be used to define a symbol ---
1693 multiple definitions are not allowed.
1694 \end{macrodesc}
1695
1696 \begin{macrodesc}{token}{\p{name}}
1697 The name of a symbol defined by a \macro{production} macro, used
1698 in the \var{definition} of a symbol. Where possible, this will
1699 be rendered as a hyperlink to the definition of the symbol
1700 \var{name}.
1701 \end{macrodesc}
1702
1703 Note that the entire grammar does not need to be defined in a
1704 single \env{productionlist} environment; any number of
1705 groupings may be used to describe the grammar. Every use of the
1706 \macro{token} must correspond to a \macro{production}.
1707
1708 The following is an example taken from the
1709 \citetitle[../ref/identifiers.html]{Python Reference Manual}:
1710
1711\begin{verbatim}
1712\begin{productionlist}
1713 \production{identifier}
1714 {(\token{letter}|"_") (\token{letter} | \token{digit} | "_")*}
1715 \production{letter}
1716 {\token{lowercase} | \token{uppercase}}
1717 \production{lowercase}
1718 {"a"..."z"}
1719 \production{uppercase}
1720 {"A"..."Z"}
1721 \production{digit}
1722 {"0"..."9"}
1723\end{productionlist}
1724\end{verbatim}
1725
1726
1727\subsection{Graphical Interface Components \label{gui-markup}}
1728
1729 The components of graphical interfaces will be assigned markup, but
1730 most of the specifics have not been determined.
1731
1732 \begin{macrodesc}{guilabel}{\p{label}}
1733 Labels presented as part of an interactive user interface should
1734 be marked using \macro{guilabel}. This includes labels from
1735 text-based interfaces such as those created using \code{curses} or
1736 other text-based libraries. Any label used in the interface
1737 should be marked with this macro, including button labels, window
1738 titles, field names, menu and menu selection names, and even
1739 values in selection lists.
1740 \end{macrodesc}
1741
1742 \begin{macrodesc}{menuselection}{\p{menupath}}
1743 Menu selections should be marked using a combination of
1744 \macro{menuselection} and \macro{sub}. This macro is used to mark
1745 a complete sequence of menu selections, including selecting
1746 submenus and choosing a specific operation, or any subsequence of
1747 such a sequence. The names of individual selections should be
1748 separated by occurrences of \macro{sub}.
1749
1750 For example, to mark the selection ``\menuselection{Start \sub
1751 Programs}'', use this markup:
1752
1753\begin{verbatim}
1754\menuselection{Start \sub Programs}
1755\end{verbatim}
1756
1757 When including a selection that includes some trailing indicator,
1758 such as the ellipsis some operating systems use to indicate that
1759 the command opens a dialog, the indicator should be omitted from
1760 the selection name.
1761
1762 Individual selection names within the \macro{menuselection} should
1763 not be marked using \macro{guilabel} since that's implied by using
1764 \macro{menuselection}.
1765 \end{macrodesc}
1766
1767 \begin{macrodesc}{sub}{}
1768 Separator for menu selections that include multiple levels. This
1769 macro is only defined within the context of the
1770 \macro{menuselection} macro.
1771 \end{macrodesc}
1772
1773
1774\section{Processing Tools \label{tools}}
1775
1776 \subsection{External Tools \label{tools-external}}
1777
1778 Many tools are needed to be able to process the Python
1779 documentation if all supported formats are required. This
1780 section lists the tools used and when each is required. Consult
1781 the \file{Doc/README} file to see if there are specific version
1782 requirements for any of these.
1783
1784 \begin{description}
1785 \item[\program{dvips}]
1786 This program is a typical part of \TeX{} installations. It is
1787 used to generate PostScript from the ``device independent''
1788 \file{.dvi} files. It is needed for the conversion to
1789 PostScript.
1790
1791 \item[\program{emacs}]
1792 Emacs is the kitchen sink of programmers' editors, and a damn
1793 fine kitchen sink it is. It also comes with some of the
1794 processing needed to support the proper menu structures for
1795 Texinfo documents when an info conversion is desired. This is
1796 needed for the info conversion. Using \program{xemacs}
1797 instead of FSF \program{emacs} may lead to instability in the
1798 conversion, but that's because nobody seems to maintain the
1799 Emacs Texinfo code in a portable manner.
1800
1801 \item[\program{latex}]
1802 \LaTeX{} is a large and extensible macro package by Leslie
1803 Lamport, based on \TeX, a world-class typesetter by Donald
1804 Knuth. It is used for the conversion to PostScript, and is
1805 needed for the HTML conversion as well (\LaTeX2HTML requires
1806 one of the intermediate files it creates).
1807
1808 \item[\program{latex2html}]
1809 Probably the longest Perl script anyone ever attempted to
1810 maintain. This converts \LaTeX{} documents to HTML documents,
1811 and does a pretty reasonable job. It is required for the
1812 conversions to HTML and GNU info.
1813
1814 \item[\program{lynx}]
1815 This is a text-mode Web browser which includes an
1816 HTML-to-plain text conversion. This is used to convert
1817 \code{howto} documents to text.
1818
1819 \item[\program{make}]
1820 Just about any version should work for the standard documents,
1821 but GNU \program{make} is required for the experimental
1822 processes in \file{Doc/tools/sgmlconv/}, at least while
1823 they're experimental. This is not required for running the
1824 \program{mkhowto} script.
1825
1826 \item[\program{makeindex}]
1827 This is a standard program for converting \LaTeX{} index data
1828 to a formatted index; it should be included with all \LaTeX{}
1829 installations. It is needed for the PDF and PostScript
1830 conversions.
1831
1832 \item[\program{makeinfo}]
1833 GNU \program{makeinfo} is used to convert Texinfo documents to
1834 GNU info files. Since Texinfo is used as an intermediate
1835 format in the info conversion, this program is needed in that
1836 conversion.
1837
1838 \item[\program{pdflatex}]
1839 pdf\TeX{} is a relatively new variant of \TeX, and is used to
1840 generate the PDF version of the manuals. It is typically
1841 installed as part of most of the large \TeX{} distributions.
1842 \program{pdflatex} is pdf\TeX{} using the \LaTeX{} format.
1843
1844 \item[\program{perl}]
1845 Perl is required for \LaTeX2HTML{} and one of the scripts used
1846 to post-process \LaTeX2HTML output, as well as the
1847 HTML-to-Texinfo conversion. This is required for
1848 the HTML and GNU info conversions.
1849
1850 \item[\program{python}]
1851 Python is used for many of the scripts in the
1852 \file{Doc/tools/} directory; it is required for all
1853 conversions. This shouldn't be a problem if you're interested
1854 in writing documentation for Python!
1855 \end{description}
1856
1857
1858 \subsection{Internal Tools \label{tools-internal}}
1859
1860 This section describes the various scripts that are used to
1861 implement various stages of document processing or to orchestrate
1862 entire build sequences. Most of these tools are only useful
1863 in the context of building the standard documentation, but some
1864 are more general.
1865
1866 \begin{description}
1867 \item[\program{mkhowto}]
1868 This is the primary script used to format third-party
1869 documents. It contains all the logic needed to ``get it
1870 right.'' The proper way to use this script is to make a
1871 symbolic link to it or run it in place; the actual script file
1872 must be stored as part of the documentation source tree,
1873 though it may be used to format documents outside the tree.
1874 Use \program{mkhowto} \longprogramopt{help} for a list of
1875 command line options.
1876
1877 \program{mkhowto} can be used for both \code{howto} and
1878 \code{manual} class documents. It is usually a good idea to
1879 always use the latest version of this tool rather than a
1880 version from an older source release of Python. It can be
1881 used to generate DVI, HTML, PDF, PostScript, and plain text
1882 documents. The GNU info and iSilo formats will be supported
1883 by this script in some future version.
1884
1885 Use the \longprogramopt{help} option on this script's command
1886 line to get a summary of options for this script.
1887
1888 XXX Need more here.
1889 \end{description}
1890
1891
1892 \subsection{Working on Cygwin \label{cygwin}}
1893
1894 Installing the required tools under Cygwin under Cygwin can be a
1895 little tedious. Most of the required packages can be installed
1896 using Cygwin's graphical installer, while netpbm and \LaTeX2HTML
1897 must be installed from source.
1898
1899 Start with a reasonably modern version of Cygwin. If you haven't
1900 upgraded for a few years, now would be a good time.
1901
1902 Using the Cygwin installer, make sure your Cygwin installation
1903 includes Perl, Python, and the \TeX{} packages. Perl and Python
1904 are located under the \menuselection{Interpreters} heading. The
1905 \TeX{} packages are located under the \menuselection{Text}
1906 heading, and are named \code{tetex-*}. To ensure that all
1907 required packages are available, install every \code{tetex}
1908 package, except \code{tetex-x11}. (There may be a more minimal
1909 set, but I've not spent time trying to minimize the installation.)
1910
1911 The netpbm package is used by \LaTeX2HTML, and \emph{must} be
1912 installed before \LaTeX2HTML can be successfully installed, even
1913 though its features will not be used for most Python
1914 documentation. References to download locations are located in
1915 the \ulink{netpbm README}{http://netpbm.sourceforge.net/README}.
1916 Install from the latest stable source distribution according to
1917 the instructions. (Note that binary packages of netpbm are
1918 sometimes available, but these may not work correctly with
1919 \LaTeX2HTML.)
1920
1921 \LaTeX2HTML can be installed from the source archive, but only
1922 after munging one of the files in the distribution. Download the
1923 source archive from the \LaTeX2HTML website
1924 \url{http://www.latex2html.org/} (or one of the many alternate
1925 sites) and unpack it to a build directory. In the top level of
1926 this build directory there will be a file named \file{L2hos.pm}.
1927 Open \file{L2hos.pm} in an editor, and near the bottom of the file
1928 replace the text \code{\$\textasciicircum{}O} with the text
1929 \code{'unix'}. Proceed using this command to build and install
1930 the software:
1931
1932\begin{verbatim}
1933% ./configure && make install
1934\end{verbatim}
1935
1936 You should now be able to build at least the DVI, HTML, PDF, and
1937 PostScript versions of the formatted documentation.
1938
1939
1940\section{Including Graphics \label{graphics}}
1941
1942 The standard documentation included with Python makes no use of
1943 diagrams or images; this is intentional. The outside tools used to
1944 format the documentation have not always been suited to working with
1945 graphics. As the tools have evolved and been improved by their
1946 maintainers, support for graphics has improved.
1947
1948 The internal tools, starting with the \program{mkhowto} script, do
1949 not provide any direct support for graphics. However,
1950 \program{mkhowto} will not interfere with graphics support in the
1951 external tools.
1952
1953 Experience using graphics together with these tools and the
1954 \code{howto} and \code{manual} document classes is not extensive,
1955 but has been known to work. The basic approach is this:
1956
1957 \begin{enumerate}
1958 \item Create the image or graphic using your favorite
1959 application.
1960
1961 \item Convert the image to a format supported by the conversion to
1962 your desired output format. If you want to generate HTML or
1963 PostScript, you can convert the image or graphic to
1964 encapsulated PostScript (a \file{.eps} file); \LaTeX2HTML
1965 can convert that to a \file{.gif} file; it may be possible
1966 to provide a \file{.gif} file directly. If you want to
1967 generate PDF, you need to provide an ``encapsulated'' PDF
1968 file. This can be generated from encapsulated PostScript
1969 using the \program{epstopdf} tool provided with the te\TeX{}
1970 distribution on Linux and \UNIX.
1971
1972 \item In your document, add this line to ``import'' the general
1973 graphics support package \code{graphicx}:
1974
1975\begin{verbatim}
1976\usepackage{graphicx}
1977\end{verbatim}
1978
1979 \item Where you want to include your graphic or image, include
1980 markup similar to this:
1981
1982\begin{verbatim}
1983\begin{figure}
1984 \centering
1985 \includegraphics[width=5in]{myimage}
1986 \caption{Description of my image}
1987\end{figure}
1988\end{verbatim}
1989
1990 In particular, note for the \macro{includegraphics} macro
1991 that no file extension is provided. If you're only
1992 interested in one target format, you can include the
1993 extension of the appropriate input file, but to allow
1994 support for multiple formats, omitting the extension makes
1995 life easier.
1996
1997 \item Run \program{mkhowto} normally.
1998 \end{enumerate}
1999
2000 If you're working on systems which support some sort of
2001 \program{make} facility, you can use that to ensure the intermediate
2002 graphic formats are kept up to date. This example shows a
2003 \file{Makefile} used to format a document containing a diagram
2004 created using the \program{dia} application:
2005
2006\begin{verbatim}
2007default: pdf
2008all: html pdf ps
2009
2010html: mydoc/mydoc.html
2011pdf: mydoc.pdf
2012ps: mydoc.ps
2013
2014mydoc/mydoc.html: mydoc.tex mygraphic.eps
2015 mkhowto --html $<
2016
2017mydoc.pdf: mydoc.tex mygraphic.pdf
2018 mkhowto --pdf $<
2019
2020mydoc.ps: mydoc.tex mygraphic.eps
2021 mkhowto --postscript $<
2022
2023.SUFFIXES: .dia .eps .pdf
2024
2025.dia.eps:
2026 dia --nosplash --export $@ $<
2027
2028.eps.pdf:
2029 epstopdf $<
2030\end{verbatim} % $ <-- bow to font-lock
2031
2032
2033\section{Future Directions \label{futures}}
2034
2035 The history of the Python documentation is full of changes, most of
2036 which have been fairly small and evolutionary. There has been a
2037 great deal of discussion about making large changes in the markup
2038 languages and tools used to process the documentation. This section
2039 deals with the nature of the changes and what appears to be the most
2040 likely path of future development.
2041
2042 \subsection{Structured Documentation \label{structured}}
2043
2044 Most of the small changes to the \LaTeX{} markup have been made
2045 with an eye to divorcing the markup from the presentation, making
2046 both a bit more maintainable. Over the course of 1998, a large
2047 number of changes were made with exactly this in mind; previously,
2048 changes had been made but in a less systematic manner and with
2049 more concern for not needing to update the existing content. The
2050 result has been a highly structured and semantically loaded markup
2051 language implemented in \LaTeX. With almost no basic \TeX{} or
2052 \LaTeX{} markup in use, however, the markup syntax is about the
2053 only evidence of \LaTeX{} in the actual document sources.
2054
2055 One side effect of this is that while we've been able to use
2056 standard ``engines'' for manipulating the documents, such as
2057 \LaTeX{} and \LaTeX2HTML, most of the actual transformations have
2058 been created specifically for Python. The \LaTeX{} document
2059 classes and \LaTeX2HTML support are both complete implementations
2060 of the specific markup designed for these documents.
2061
2062 Combining highly customized markup with the somewhat esoteric
2063 systems used to process the documents leads us to ask some
2064 questions: Can we do this more easily? and, Can we do this
2065 better? After a great deal of discussion with the community, we
2066 have determined that actively pursuing modern structured
2067 documentation systems is worth some investment of time.
2068
2069 There appear to be two real contenders in this arena: the Standard
2070 General Markup Language (SGML), and the Extensible Markup Language
2071 (XML). Both of these standards have advantages and disadvantages,
2072 and many advantages are shared.
2073
2074 SGML offers advantages which may appeal most to authors,
2075 especially those using ordinary text editors. There are also
2076 additional abilities to define content models. A number of
2077 high-quality tools with demonstrated maturity are available, but
2078 most are not free; for those which are, portability issues remain
2079 a problem.
2080
2081 The advantages of XML include the availability of a large number
2082 of evolving tools. Unfortunately, many of the associated
2083 standards are still evolving, and the tools will have to follow
2084 along. This means that developing a robust tool set that uses
2085 more than the basic XML 1.0 recommendation is not possible in the
2086 short term. The promised availability of a wide variety of
2087 high-quality tools which support some of the most important
2088 related standards is not immediate. Many tools are likely to be
2089 free, and the portability issues of those which are, are not
2090 expected to be significant.
2091
2092 It turns out that converting to an XML or SGML system holds
2093 promise for translators as well; how much can be done to ease the
2094 burden on translators remains to be seen, and may have some impact
2095 on the schema and specific technologies used.
2096
2097 XXX Eventual migration to XML.
2098
2099 The documentation will be moved to XML in the future, and tools
2100 are being written which will convert the documentation from the
2101 current format to something close to a finished version, to the
2102 extent that the desired information is already present in the
2103 documentation. Some XSLT stylesheets have been started for
2104 presenting a preliminary XML version as HTML, but the results are
2105 fairly rough.
2106
2107 The timeframe for the conversion is not clear since there doesn't
2108 seem to be much time available to work on this, but the apparent
2109 benefits are growing more substantial at a moderately rapid pace.
2110
2111
2112 \subsection{Discussion Forums \label{discussion}}
2113
2114 Discussion of the future of the Python documentation and related
2115 topics takes place in the Documentation Special Interest Group, or
2116 ``Doc-SIG.'' Information on the group, including mailing list
2117 archives and subscription information, is available at
2118 \url{http://www.python.org/sigs/doc-sig/}. The SIG is open to all
2119 interested parties.
2120
2121 Comments and bug reports on the standard documents should be sent
2122 to \email{docs@python.org}. This may include comments
2123 about formatting, content, grammatical and spelling errors, or
2124 this document. You can also send comments on this document
2125 directly to the author at \email{fdrake@acm.org}.
2126
2127\input{doc.ind}
2128
2129\end{document}
Note: See TracBrowser for help on using the repository browser.