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