4 \title{Documenting Python
}
8 % Now override the stuff that includes author information;
9 % Guido did *not* write this one!
11 \author{Fred L. Drake, Jr.
}
13 Corporation for National Research Initiatives (CNRI) \\
14 1895 Preston White Drive, Reston, Va
20191, USA \\
15 E-mail:
\email{fdrake@acm.org
}
25 The Python language documentation has a substantial body of
26 documentation, much of it contributed by various authors. The markup
27 used for the Python documentation is based on
\LaTeX{} and requires a
28 significant set of macros written specifically for documenting Python.
29 This
document describes the macros introduced to support Python
30 documentation and how they should be used to support a wide range of
33 This
document describes the
document classes and special markup used
34 in the Python documentation. Authors may use this guide, in
35 conjunction with the template files provided with the
36 distribution, to create or maintain whole documents or sections.
42 \section{Introduction
}
44 Python's documentation has long been considered to be good for a
45 free programming language. There are a number of reasons for this,
46 the most important being the early commitment of Python's creator,
47 Guido van Rossum, to providing documentation on the language and its
48 libraries, and the continuing involvement of the user community in
49 providing assistance for creating and maintaining documentation.
51 The involvement of the community takes many forms, from authoring to
52 bug reports to just plain complaining when the documentation could
53 be more complete or easier to use. All of these forms of input from
54 the community have proved useful during the time I've been involved
55 in maintaining the documentation.
57 This
document is aimed at authors and potential authors of
58 documentation for Python. More specifically, it is for people
59 contributing to the standard documentation and developing additional
60 documents using the same tools as the standard documents. This
61 guide will be less useful for authors using the Python documentation
62 tools for topics other than Python, and less useful still for
63 authors not using the tools at all.
65 The material in this guide is intended to assist authors using the
66 Python documentation tools. It includes information on the source
67 distribution of the standard documentation, a discussion of the
68 document types, reference material on the markup defined in the
69 document classes, a list of the external tools needed for processing
70 documents, and reference material on the tools provided with the
71 documentation resources. At the end, there is also a section
72 discussing future directions for the Python documentation and where
73 to turn for more information.
75 \section{Directory Structure
}
77 The source distribution for the standard Python documentation
78 contains a large number of directories. While third-party documents
79 do not need to be placed into this structure or need to be placed
80 within a similar structure, it can be helpful to know where to look
81 for examples and tools when developing new documents using the
82 Python documentation tools. This section describes this directory
85 The documentation sources are usually placed within the Python
86 source distribution as the top-level directory
\file{Doc/
}, but
87 are not dependent on the Python source distribution in any way.
89 The
\file{Doc/
} directory contains a few files and several
90 subdirectories. The files are mostly self-explanatory, including a
91 \file{README
} and a
\file{Makefile
}. The directories fall into
95 \term{Document Sources
}
96 The
\LaTeX{} sources for each
document are placed in a
97 separate directory. These directories are given short,
98 three-character names:
100 \begin{tableii
}{p
{.75in
}|p
{3in
}}{filenq
}{Directory
}{Document Title
}
101 \lineii{api/
}{\emph{The Python/C API
}}
102 \lineii{doc/
}{\emph{Documenting Python
}}
103 \lineii{ext/
}{\emph{Extending and Embedding the Python Interpreter
}}
104 \lineii{lib/
}{\emph{Python Library Reference
}}
105 \lineii{mac/
}{\emph{Macintosh Module Reference
}}
106 \lineii{ref/
}{\emph{Python Reference Manual
}}
107 \lineii{tut/
}{\emph{Python Tutorial
}}
110 \term{Format-Specific Output
}
111 Most output formats have a directory which contains a
112 \file{Makefile
} which controls the generation of that format
113 and provides storage for the formatted documents. The only
114 variations within this category are the Portable Document
115 Format (PDF) and PostScript versions are placed in the
116 directories
\file{paper-a4/
} and
\file{paper-letter/
} (this
117 causes all the temporary files created by
\LaTeX{} to be kept
118 in the same place for each paper size, where they can be more
121 \begin{tableii
}{p
{.75in
}|p
{3in
}}{filenq
}{Directory
}{Output Formats
}
122 \lineii{html/
}{HTML output
}
123 \lineii{info/
}{GNU info output
}
124 \lineii{paper-a4/
}{PDF and PostScript, A4 paper
}
125 \lineii{paper-letter/
}{PDF and PostScript, US-Letter paper
}
128 \term{Supplemental Files
}
129 Some additional directories are used to store supplemental
130 files used for the various processes. Directories are
131 included for the shared
\LaTeX{} document classes, the
132 \LaTeX2HTML support, template files for various
document
133 components, and the scripts used to perform various steps in
134 the formatting processes.
136 \begin{tableii
}{p
{.75in
}|p
{3in
}}{filenq
}{Directory
}{Contents
}
137 \lineii{perl/
}{Support for
\LaTeX2HTML processing
}
138 \lineii{templates/
}{Example files for source documents
}
139 \lineii{texinputs/
}{Style implementation for
\LaTeX}
140 \lineii{tools/
}{Custom processing scripts
}
146 \section{\LaTeX{} Primer
\label{latex-primer
}}
148 This section is a brief introduction to
\LaTeX{} concepts and
149 syntax, to provide authors enough information to author documents
150 productively without having to become ``
\TeX{}nicians.''
152 Perhaps the most important concept to keep in mind while marking up
153 Python documentation is the while
\TeX{} is unstructured,
\LaTeX{} was
154 designed as a layer on top of
\TeX{} which specifically supports
155 structured markup. The Python-specific markup is intended to extend
156 the structure provided by standard
\LaTeX{} document classes to
157 support additional information specific to Python.
159 \LaTeX{} documents contain two parts: the preamble and the body.
160 The preamble is used to specify certain metadata about the
document
161 itself, such as the title, the list of authors, the date, and the
162 \emph{class
} the
document belongs to. Additional information used
163 to control index generation and the use of bibliographic databases
164 can also be placed in the preamble. For most authors, the preamble
165 can be most easily created by copying it from an existing
document
166 and modifying a few key pieces of information.
168 The
\dfn{class
} of a
document is used to place a
document within a
169 broad category of documents and set some fundamental formatting
170 properties. For Python documentation, two classes are used: the
171 \code{manual
} class and the
\code{howto
} class. These classes also
172 define the additional markup used to
document Python concepts and
173 structures. Specific information about these classes is provided in
174 section
\ref{classes
}, ``Document Classes,'' below. The first thing
175 in the preamble is the declaration of the
document's class.
177 After the class declaration, a number of
\emph{macros
} are used to
178 provide further information about the
document and setup any
179 additional markup that is needed. No output is generated from the
180 preamble; it is an error to include free text in the preamble
181 because it would cause output.
183 The
document body follows the preamble. This contains all the
184 printed components of the
document marked up structurally.
186 XXX This section will discuss what the markup looks like, and
187 explain the difference between an environment and a macro.
190 \section{Document Classes
\label{classes
}}
192 Two
\LaTeX{} document classes are defined specifically for use with
193 the Python documentation. The
\code{manual
} class is for large
194 documents which are sectioned into chapters, and the
\code{howto
}
195 class is for smaller documents.
197 The
\code{manual
} documents are larger and are used for most of the
198 standard documents. This
document class is based on the standard
199 \LaTeX{} \code{report} class and is formatted very much like a long
200 technical
report. The
\emph{Python Reference Manual
} is a good
201 example of a
\code{manual
} document, and the
\emph{Python Library
202 Reference
} is a large example.
204 The
\code{howto
} documents are shorter, and don't have the large
205 structure of the
\code{manual
} documents. This class is based on
206 the standard
\LaTeX{} \code{article
} class and is formatted somewhat
207 like the Linux Documentation Project's ``HOWTO'' series as done
208 originally using the LinuxDoc software. The original intent for the
209 document class was that it serve a similar role as the LDP's HOWTO
210 series, but the applicability of the class turns out to be somewhat
211 more broad. This class is used for ``how-to'' documents (this
212 document is an example) and for shorter reference manuals for small,
213 fairly cohesive module libraries. Examples of the later use include
214 the standard
\emph{Macintosh Library Modules
} and
\emph{Using
215 Kerberos from Python
}, which contains reference material for an
216 extension package. These documents are roughly equivalent to a
217 single chapter from a larger work.
220 \section{Special Markup Constructs
}
222 The Python
document classes define a lot of new environments and
223 macros. This section contains the reference material for these
226 \subsection{Information Units
\label{info-units
}}
228 XXX Explain terminology, or come up with something more ``lay.''
230 There are a number of environments used to describe specific
231 features provided by modules. Each environment requires
232 parameters needed to provide basic information about what is being
233 described, and the environment content should be the description.
234 Most of these environments make entries in the general index (if
235 one is being produced for the
document); if no index entry is
236 desired, non-indexing variants are available for many of these
237 environments. The environments have names of the form
238 \code{\var{feature
}desc
}, and the non-indexing variants are named
239 \code{\var{feature
}descni
}. The available variants are explicitly
240 included in the list below.
242 For each of these environments, the first parameter,
\var{name
},
243 provides the name by which the feature is accessed.
245 Environments which describe features of objects within a module,
246 such as object methods or data attributes, allow an optional
247 \var{type name
} parameter. When the feature is an attribute of
248 class instances,
\var{type name
} only needs to be given if the
249 class was not the most recently described class in the module; the
250 \var{name
} value from the most recent
\env{classdesc
} is implied.
251 For features of built-in or extension types, the
\var{type name
}
252 value should always be provided. Another special case includes
253 methods and members of general ``protocols,'' such as the
254 formatter and writer protocols described for the
255 \module{formatter
} module: these may be documented without any
256 specific implementation classes, and will always require the
257 \var{type name
} parameter to be provided.
259 \begin{envdesc
}{datadesc
}{\p{name
}}
260 This environment is used to
document global data in a module,
261 including both variables and values used as ``defined
262 constants.'' Class and object attributes are not documented
263 using this environment.
265 \begin{envdesc
}{datadescni
}{\p{name
}}
266 Like
\env{datadesc
}, but without creating any index entries.
269 \begin{envdesc
}{excdesc
}{\p{name
}}
270 Describe an exception. This may be either a string exception or
274 \begin{envdesc
}{funcdesc
}{\p{name
}\p{parameters
}}
275 Describe a module-level function.
\var{parameters
} should
276 not include the parentheses used in the call syntax. Object
277 methods are not documented using this environment. Bound object
278 methods placed in the module namespace as part of the public
279 interface of the module are documented using this, as they are
280 equivalent to normal functions for most purposes.
282 The description should include information about the parameters
283 required and how they are used (especially whether mutable
284 objects passed as parameters are modified), side effects, and
285 possible exceptions. A small example may be provided.
287 \begin{envdesc
}{funcdescni
}{\p{name
}\p{parameters
}}
288 Like
\env{funcdesc
}, but without creating any index entries.
291 \begin{envdesc
}{classdesc
}{\p{name
}\p{constructor parameters
}}
292 Describe a class and its constructor.
\var{constructor
293 parameters
} should not include the
\var{self
} parameter or
294 the parentheses used in the call syntax.
297 \begin{envdesc
}{memberdesc
}{\op{type name
}\p{name
}}
298 Describe an object data attribute. The description should
299 include information about the type of the data to be expected
300 and whether it may be changed directly.
302 \begin{envdesc
}{memberdescni
}{\op{type name
}\p{name
}}
303 Like
\env{memberdesc
}, but without creating any index entries.
306 \begin{envdesc
}{methoddesc
}{\op{type name
}\p{name
}\p{parameters
}}
307 Describe an object method.
\var{parameters
} should not include
308 the
\var{self
} parameter or the parentheses used in the call
309 syntax. The description should include similar information to
310 that described for
\env{funcdesc
}.
312 \begin{envdesc
}{methoddescni
}{\op{type name
}\p{name
}\p{parameters
}}
313 Like
\env{methoddesc
}, but without creating any index entries.
317 \subsection{Showing Code Examples
}
319 Examples of Python source code or interactive sessions are
320 represented as
\env{verbatim
} environments. This environment
321 is a standard part of
\LaTeX{}. It is important to only use
322 spaces for indentation in code examples since
\TeX{} drops tabs
323 instead of converting them to spaces.
325 Representing an interactive session requires including the prompts
326 and output along with the Python code. No special markup is
327 required for interactive sessions.
329 Within the
\env{verbatim
} environment, characters special to
330 \LaTeX{} do not need to be specially marked in any way. The entire
331 example will be presented in a monospaced font; no attempt at
332 ``pretty-printing'' is made, as the environment must work for
333 non-Python code and non-code displays.
335 The Python Documentation Special Interest Group has discussed a
336 number of approaches to creating pretty-printed code displays and
337 interactive sessions; see the Doc-SIG area on the Python Web site
338 for more information on this topic.
341 \subsection{Inline Markup
}
343 The macros described in this section are used to mark just about
344 anything interesting in the
document text. They may be used in
345 headings (though anything involving hyperlinks should be avoided
346 there) as well as in the body text.
348 \begin{macrodesc
}{bfcode
}{\p{text
}}
349 Like
\macro{code
}, but also makes the font bold-face.
352 \begin{macrodesc
}{cdata
}{\p{name
}}
353 The name of a C-language variable.
356 \begin{macrodesc
}{cfunction
}{\p{name
}}
357 The name of a C-language function.
\var{name
} should include the
358 function name and the trailing parentheses.
361 \begin{macrodesc
}{character
}{\p{char
}}
362 A character when discussing the character rather than a one-byte
363 string value. The character will be typeset as with
\macro{samp
}.
366 \begin{macrodesc
}{class
}{\p{name
}}
367 A class name; a dotted name may be used.
370 \begin{macrodesc
}{code
}{\p{text
}}
371 A short code fragment or literal constant value. Typically, it
372 should not include any spaces since no quotation marks are
376 \begin{macrodesc
}{constant
}{\p{name
}}
377 The name of a ``defined'' constant. This may be a C-language
378 \code{\#define
} or a Python variable that is not intended to be
382 \begin{macrodesc
}{ctype
}{\p{name
}}
383 The name of a C
\keyword{typedef
} or structure. For structures
384 defined without a
\keyword{typedef
}, use
\code{\e ctype\
{struct
385 struct_tag\
}} to make it clear that the
\keyword{struct
} is
389 \begin{macrodesc
}{deprecated
}{\p{version
}\p{what to do
}}
390 Declare whatever is being described as being deprecated starting
391 with release
\var{version
}. The text given as
\var{what to do
}
392 should recommend something to use instead.
395 \begin{macrodesc
}{dfn
}{\p{term
}}
396 Mark the defining instance of
\var{term
} in the text. (No index
397 entries are generated.)
400 \begin{macrodesc
}{e
}{}
401 Produces a backslash. This is convenient in
\macro{code
} and
405 \begin{macrodesc
}{email
}{\p{address
}}
406 An email address. Note that this is
\emph{not
} hyperlinked in
407 any of the possible output formats.
410 \begin{macrodesc
}{emph
}{\p{text
}}
411 Emphasized text; this will be presented in an italic font.
414 \begin{macrodesc
}{envvar
}{\p{name
}}
415 An environment variable. Index entries are generated.
418 \begin{macrodesc
}{exception
}{\p{name
}}
419 The name of an exception. A dotted name may be used.
422 \begin{macrodesc
}{file
}{\p{file or dir
}}
423 The name of a file or directory. In the PDF and PostScript
424 outputs, single quotes and a font change are used to indicate
425 the file name, but no quotes are used in the HTML output.
428 \begin{macrodesc
}{filenq
}{\p{file or dir
}}
429 Like
\macro{file
}, but single quotes are never used. This can
430 be used in conjunction with tables if a column will only contain
431 file or directory names.
434 \begin{macrodesc
}{function
}{\p{name
}}
435 The name of a Python function; dotted names may be used.
438 \begin{macrodesc
}{kbd
}{\p{key sequence
}}
439 Mark a sequence of keystrokes. What form
\var{key sequence
}
440 takes may depend on platform- or application-specific
441 conventions. For example, an
\program{xemacs
} key sequence
442 may be marked like
\code{\e kbd\
{C-x C-f\
}}.
445 \begin{macrodesc
}{keyword
}{\p{name
}}
446 The name of a keyword in a programming language.
449 \begin{macrodesc
}{makevar
}{\p{name
}}
450 The name of a
\program{make
} variable.
453 \begin{macrodesc
}{manpage
}{\p{name
}\p{section
}}
454 A reference to a
\UNIX{} manual page.
457 \begin{macrodesc
}{member
}{\p{name
}}
458 The name of a data attribute of an object.
461 \begin{macrodesc
}{method
}{\p{name
}}
462 The name of a method of an object.
\var{name
} should include the
463 method name and the trailing parentheses. A dotted name may be
467 \begin{macrodesc
}{mimetype
}{\p{name
}}
468 The name of a MIME type.
471 \begin{macrodesc
}{module
}{\p{name
}}
472 The name of a module; a dotted name may be used.
475 \begin{macrodesc
}{newsgroup
}{\p{name
}}
476 The name of a USENET newsgroup.
479 \begin{macrodesc
}{program
}{\p{name
}}
480 The name of an executable program. This may differ from the
481 file name for the executable for some platforms. In particular,
482 the
\file{.exe
} (or other) extension should be omitted for DOS
483 and Windows programs.
486 \begin{macrodesc
}{refmodule
}{\op{key
}\p{name
}}
487 Like
\macro{module
}, but create a hyperlink to the documentation
488 for the named module. Note that the corresponding
489 \macro{declaremodule
} must be in the same
document. If the
490 \macro{declaremodule
} defines a module key different from the
491 module name, it must also be provided as
\var{key
} to the
492 \macro{refmodule
} macro.
495 \begin{macrodesc
}{regexp
}{\p{string
}}
496 Mark a regular expression.
499 \begin{macrodesc
}{rfc
}{\p{number
}}
500 A reference to an Internet Request for Comments. This generates
501 appropriate index entries. The text
\samp{RFC
\var{number
}} is
502 generated; in the HTML output, this text is a hyperlink to an
503 online copy of the specified RFC.
506 \begin{macrodesc
}{samp
}{\p{text
}}
507 A short code sample, but possibly longer than would be given
508 using
\macro{code
}. Since quotation marks are added, spaces are
512 \begin{macrodesc
}{strong
}{\p{text
}}
513 Strongly emphasized text; this will be presented using a bold
517 \begin{macrodesc
}{url
}{\p{url
}}
518 A URL (or URN). The URL will be presented as text. In the HTML
519 and PDF formatted versions, the URL will also be a hyperlink.
520 This can be used when referring to external resources. Note
521 that many characters are special to
\LaTeX{} and this macro
522 does not always do the right thing. In particular, the tilde
523 character (
\character{\~
}) is mis-handled; encoding it as a
524 hex-sequence does work, use
\samp{\%
7e
} in place of the tilde
528 \begin{macrodesc
}{var
}{\p{name
}}
529 The name of a variable or formal parameter in running text.
532 \begin{macrodesc
}{version
}{}
533 The version number for the documentation, as specified using
534 \macro{release
} in the preamble.
538 \subsection{Module-specific Markup
}
540 The markup described in this section is used to provide information
541 about a module being documented. A typical use of this markup
542 appears at the top of the section used to
document a module. A
543 typical example might look like this:
546 \section{\module{spam
} ---
547 Access to the SPAM facility
}
549 \declaremodule{extension
}{spam
}
551 \modulesynopsis{Access to the SPAM facility of
\UNIX{}.
}
552 \moduleauthor{Jane Doe
}{jane.doe@frobnitz.org
}
555 \begin{macrodesc
}{declaremodule
}{\op{key
}\p{type
}\p{name
}}
556 Requires two parameters: module type (
\samp{standard
},
557 \samp{builtin
},
\samp{extension
}, or
\samp{}), and the module
558 name. An optional parameter should be given as the basis for the
559 module's ``key'' used for linking to or referencing the section.
560 The ``key'' should only be given if the module's name contains any
561 underscores, and should be the name with the underscores stripped.
562 Note that the
\var{type
} parameter must be one of the values
563 listed above or an error will be printed. For modules which are
564 contained in packages, the fully-qualified name should be given as
565 \var{name
} parameter. This should be the first thing after the
566 \macro{section
} used to introduce the module.
569 \begin{macrodesc
}{platform
}{\p{specifier
}}
570 Specifies the portability of the module.
\var{specifier
} is a
571 comma-separated list of keys that specify what platforms the
572 module is available on. The keys are short identifiers;
573 examples that are in use include
\samp{IRIX
},
\samp{Mac
},
574 \samp{Windows
}, and
\samp{Unix
}. It is important to use a key
575 which has already been used when applicable. This is used to
576 provide annotations in the Module Index and the HTML and GNU info
580 \begin{macrodesc
}{modulesynopsis
}{\p{text
}}
581 The
\var{text
} is a short, ``one line'' description of the
582 module that can be used as part of the chapter introduction.
583 This is must be placed after
\macro{declaremodule
}.
584 The synopsis is used in building the contents of the table
585 inserted as the
\macro{localmoduletable
}. No text is
586 produced at the point of the markup.
589 \begin{macrodesc
}{moduleauthor
}{\p{name
}\p{email
}}
590 This macro is used to encode information about who authored a
591 module. This is currently not used to generate output, but can be
592 used to help determine the origin of the module.
596 \subsection{Library-level Markup
}
598 This markup is used when describing a selection of modules. For
599 example, the
\emph{Macintosh Library Modules
} document uses this
600 to help provide an overview of the modules in the collection, and
601 many chapters in the
\emph{Python Library Reference
} use it for
604 \begin{macrodesc
}{localmoduletable
}{}
605 If a
\file{.syn
} file exists for the current
606 chapter (or for the entire
document in
\code{howto
} documents), a
607 \env{synopsistable
} is created with the contents loaded from the
612 \subsection{Table Markup
}
614 There are three general-purpose table environments defined which
615 should be used whenever possible. These environments are defined
616 to provide tables of specific widths and some convenience for
617 formatting. These environments are not meant to be general
618 replacements for the standard
\LaTeX{} table environments, but can
619 be used for an advantage when the documents are processed using
620 the tools for Python documentation processing. In particular, the
621 generated HTML looks good! There is also an advantage for the
622 eventual conversion of the documentation to SGML (see section
623 \ref{futures
}, ``Future Directions'').
625 Each environment is named
\env{table
\var{cols
}}, where
\var{cols
}
626 is the number of columns in the table specified in lower-case
627 Roman numerals. Within each of these environments, an additional
628 macro,
\macro{line
\var{cols
}}, is defined, where
\var{cols
}
629 matches the
\var{cols
} value of the corresponding table
630 environment. These are supported for
\var{cols
} values of
631 \code{ii
},
\code{iii
}, and
\code{iv
}. These environments are all
632 built on top of the
\env{tabular
} environment.
634 \begin{envdesc
}{tableii
}{\p{colspec
}\p{col1font
}\p{heading1
}\p{heading2
}}
635 Create a two-column table using the
\LaTeX{} column specifier
636 \var{colspec
}. The column specifier should indicate vertical
637 bars between columns as appropriate for the specific table, but
638 should not specify vertical bars on the outside of the table
639 (that is considered a stylesheet issue). The
\var{col1font
}
640 parameter is used as a stylistic treatment of the first column
641 of the table: the first column is presented as
642 \code{\e\var{col1font
}\
{column1\
}}. To avoid treating the first
643 column specially,
\var{col1font
} may be
\samp{textrm
}. The
644 column headings are taken from the values
\var{heading1
} and
648 \begin{macrodesc
}{lineii
}{\p{column1
}\p{column2
}}
649 Create a single table row within a
\env{tableii
} environment.
650 The text for the first column will be generated by applying the
651 macro named by the
\var{col1font
} value when the
\env{tableii
}
655 \begin{envdesc
}{tableiii
}{\p{colspec
}\p{col1font
}\p{heading1
}\p{heading2
}\p{heading3
}}
656 Like the
\env{tableii
} environment, but with a third column.
657 The heading for the third column is given by
\var{heading3
}.
660 \begin{macrodesc
}{lineiii
}{\p{column1
}\p{column2
}\p{column3
}}
661 Like the
\macro{lineii
} macro, but with a third column. The
662 text for the third column is given by
\var{column3
}.
665 \begin{envdesc
}{tableiv
}{\p{colspec
}\p{col1font
}\p{heading1
}\p{heading2
}\p{heading3
}\p{heading4
}}
666 Like the
\env{tableiii
} environment, but with a fourth column.
667 The heading for the fourth column is given by
\var{heading4
}.
670 \begin{macrodesc
}{lineiv
}{\p{column1
}\p{column2
}\p{column3
}\p{column4
}}
671 Like the
\macro{lineiii
} macro, but with a fourth column. The
672 text for the fourth column is given by
\var{column4
}.
676 An additional table-like environment is
\env{synopsistable
}. The
677 table generated by this environment contains two columns, and each
678 row is defined by an alternate definition of
679 \macro{modulesynopsis
}. This environment is not normally use by
680 the user, but is created by the
\macro{localmoduletable
} macro.
683 \subsection{Reference List Markup
\label{references
}}
685 Many sections include a list of references to module documentation
686 or external documents. These lists are created using the
687 \env{seealso
} environment. This environment defines some
688 additional macros to support creating reference entries in a
691 \begin{envdesc
}{seealso
}{}
692 This environment creates a ``See also:'' heading and defines the
693 markup used to describe individual references.
696 \begin{macrodesc
}{seemodule
}{\op{key
}\p{name
}\p{why
}}
697 Refer to another module.
\var{why
} should be a brief
698 explanation of why the reference may be interesting. The module
699 name is given in
\var{name
}, with the link key given in
700 \var{key
} if necessary. In the HTML and PDF conversions, the
701 module name will be a hyperlink to the referred-to module.
702 \strong{Note:
} The module must be documented in the same
703 document (the corresponding
\macro{declaremodule
} is required).
706 \begin{macrodesc
}{seetext
}{\p{text
}}
707 Add arbitrary text
\var{text
} to the ``See also:'' list. This
708 can be used to refer to off-line materials or on-line materials
709 using the
\macro{url
} macro.
713 \subsection{Index-generating Markup
\label{indexing
}}
715 Effective index generation for technical documents can be very
716 difficult, especially for someone familliar with the topic but not
717 the creation of indexes. Much of the difficulty arises in the
718 area of terminology: including the terms an expert would use for a
719 concept is not sufficient. Coming up with the terms that a novice
720 would look up is fairly difficult for an author who, typically, is
721 an expert in the area she is writing on.
723 The truly difficult aspects of index generation are not areas with
724 which the documentation tools can help. However, ease
725 of producing the index once content decisions are make is within
726 the scope of the tools. Markup is provided which the processing
727 software is able to use to generate a variety of kinds of index
728 entry with minimal effort. Additionally, many of the environments
729 described in section
\ref{info-units
}, ``Information Units,'' will
730 generate appropriate entries into the general and module indexes.
732 The following macro can be used to control the generation of index
733 data, and should be used in the
document preamble:
735 \begin{macrodesc
}{makemodindex
}{}
736 This should be used in the
document preamble if a ``Module
737 Index'' is desired for a
document containing reference material
738 on many modules. This causes a data file
739 \code{lib
\var{jobname
}.idx
} to be created from the
740 \macro{declaremodule
} macros. This file can be processed by the
741 \program{makeindex
} program to generate a file which can be
742 \macro{input
} into the
document at the desired location of the
746 There are a number of macros that are useful for adding index
747 entries for particular concepts, many of which are specific to
748 programming languages or even Python.
750 \begin{macrodesc
}{bifuncindex
}{\p{name
}}
751 Add an index entry referring to a built-in function named
752 \var{name
}; parentheses should not be included after
756 \begin{macrodesc
}{exindex
}{\p{exception
}}
757 Add a reference to an exception named
\var{exception
}. The
758 exception may be either string- or class-based.
761 \begin{macrodesc
}{kwindex
}{\p{keyword
}}
762 Add a reference to a language keyword (not a keyword parameter
763 in a function or method call).
766 \begin{macrodesc
}{obindex
}{\p{object type
}}
767 Add an index entry for a built-in object type.
770 \begin{macrodesc
}{opindex
}{\p{operator
}}
771 Add a reference to an operator, such as
\samp{+
}.
774 \begin{macrodesc
}{refmodindex
}{\op{key
}\p{module
}}
775 Add an index entry for module
\var{module
}; if
\var{module
}
776 contains an underscore, the optional parameter
\var{key
} should
777 be provided as the same string with underscores removed. An
778 index entry ``
\var{module
} (module)'' will be generated. This
779 is intended for use with non-standard modules implemented in
783 \begin{macrodesc
}{refexmodindex
}{\op{key
}\p{module
}}
784 As for
\macro{refmodindex
}, but the index entry will be
785 ``
\var{module
} (extension module).'' This is intended for use
786 with non-standard modules not implemented in Python.
789 \begin{macrodesc
}{refbimodindex
}{\op{key
}\p{module
}}
790 As for
\macro{refmodindex
}, but the index entry will be
791 ``
\var{module
} (built-in module).'' This is intended for use
792 with standard modules not implemented in Python.
795 \begin{macrodesc
}{refstmodindex
}{\op{key
}\p{module
}}
796 As for
\macro{refmodindex
}, but the index entry will be
797 ``
\var{module
} (standard module).'' This is intended for use
798 with standard modules implemented in Python.
801 \begin{macrodesc
}{stindex
}{\p{statement
}}
802 Add an index entry for a statement type, such as
\keyword{print
}
803 or
\keyword{try
}/
\keyword{finally
}.
805 XXX Need better examples of difference from
\macro{kwindex
}.
809 Additional macros are provided which are useful for conveniently
810 creating general index entries which should appear at many places
811 in the index by rotating a list of words. These are simple macros
812 that simply use
\macro{index
} to build some number of index
813 entries. Index entries build using these macros contain both
814 primary and secondary text.
816 \begin{macrodesc
}{indexii
}{\p{word1
}\p{word2
}}
817 Build two index entries. This is exactly equivalent to using
818 \code{\e index\
{\var{word1
}!
\var{word2
}\
}} and
819 \code{\e index\
{\var{word2
}!
\var{word1
}\
}}.
822 \begin{macrodesc
}{indexiii
}{\p{word1
}\p{word2
}\p{word3
}}
823 Build three index entries. This is exactly equivalent to using
824 \code{\e index\
{\var{word1
}!
\var{word2
} \var{word3
}\
}},
825 \code{\e index\
{\var{word2
}!
\var{word3
},
\var{word1
}\
}}, and
826 \code{\e index\
{\var{word3
}!
\var{word1
} \var{word2
}\
}}.
829 \begin{macrodesc
}{indexiv
}{\p{word1
}\p{word2
}\p{word3
}\p{word4
}}
830 Build four index entries. This is exactly equivalent to using
831 \code{\e index\
{\var{word1
}!
\var{word2
} \var{word3
} \var{word4
}\
}},
832 \code{\e index\
{\var{word2
}!
\var{word3
} \var{word4
},
\var{word1
}\
}},
833 \code{\e index\
{\var{word3
}!
\var{word4
},
\var{word1
} \var{word2
}\
}},
835 \code{\e index\
{\var{word4
}!
\var{word1
} \var{word2
} \var{word3
}\
}}.
839 \section{Special Names
}
841 Many special names are used in the Python documentation, including
842 the names of operating systems, programming languages, standards
843 bodies, and the like. Many of these were assigned
\LaTeX{} macros
844 at some point in the distant past, and these macros lived on long
845 past their usefulness. In the current markup, these entities are
846 not assigned any special markup, but the preferred spellings are
847 given here to aid authors in maintaining the consistency of
848 presentation in the Python documentation.
852 The name assigned to a particular group of standards. This is
856 The name of our favorite programming language is always
861 \section{Processing Tools
}
863 \subsection{External Tools
}
865 Many tools are needed to be able to process the Python
866 documentation if all supported formats are required. This
867 section lists the tools used and when each is required. Consult
868 the
\file{Doc/README
} file to see if there are specific version
869 requirements for any of these.
872 \item[\program{dvips}]
873 This program is a typical part of
\TeX{} installations. It is
874 used to generate PostScript from the ``device independent''
875 \file{.dvi
} files. It is needed for the conversion to
878 \item[\program{emacs
}]
879 Emacs is the kitchen sink of programmers' editors, and a damn
880 fine kitchen sink it is. It also comes with some of the
881 processing needed to support the proper menu structures for
882 Texinfo documents when an info conversion is desired. This is
883 needed for the info conversion. Using
\program{xemacs
}
884 instead of FSF
\program{emacs
} may lead to instability in the
885 conversion, but that's because nobody seems to maintain the
886 Emacs Texinfo code in a portable manner.
888 \item[\program{latex
}]
889 This is a world-class typesetter by Donald Knuth. It is used
890 for the conversion to PostScript, and is needed for the HTML
891 conversion as well (
\LaTeX2HTML requires one of the
892 intermediate files it creates).
894 \item[\program{latex2html
}]
895 Probably the longest Perl script anyone ever attempted to
896 maintain. This converts
\LaTeX{} documents to HTML documents,
897 and does a pretty reasonable job. It is required for the
898 conversions to HTML and GNU info.
900 \item[\program{lynx
}]
901 This is a text-mode Web browser which includes an
902 HTML-to-plain text conversion. This is used to convert
903 \code{howto
} documents to text.
905 \item[\program{make
}]
906 Just about any version should work for the standard documents,
907 but GNU
\program{make
} is required for the experimental
908 processes in
\file{Doc/tools/sgmlconv/
}, at least while
909 they're experimental.
911 \item[\program{makeindex
}]
912 This is a standard program for converting
\LaTeX{} index data
913 to a formatted index; it should be included with all
\LaTeX{}
914 installations. It is needed for the PDF and PostScript
917 \item[\program{makeinfo
}]
918 GNU
\program{makeinfo
} is used to convert Texinfo documents to
919 GNU info files. Since Texinfo is used as an intermediate
920 format in the info conversion, this program is needed in that
923 \item[\program{pdflatex
}]
924 pdf
\TeX{} is a relatively new variant of
\TeX, and is used to
925 generate the PDF version of the manuals. It is typically
926 installed as part of most of the large
\TeX{} distributions.
927 \program{pdflatex
} is pdf
\TeX{} using the
\LaTeX{} format.
929 \item[\program{perl
}]
930 Perl is required for
\LaTeX2HTML{} and one of the scripts used
931 to post-process
\LaTeX2HTML output, as well as the
932 HTML-to-Texinfo conversion. This is required for
933 the HTML and GNU info conversions.
935 \item[\program{python
}]
936 Python is used for many of the scripts in the
937 \file{Doc/tools/
} directory; it is required for all
938 conversions. This shouldn't be a problem if you're interested
939 in writing documentation for Python!
943 \subsection{Internal Tools
}
945 This section describes the various scripts that are used to
946 implement various stages of
document processing or to orchestrate
947 entire build sequences. Most of these tools are only useful
948 in the context of building the standard documentation, but some
952 \item[\program{mkhowto
}]
953 This is the primary script used to format third-party
954 documents. It contains all the logic needed to ``get it
955 right.'' The proper way to use this script is to make a
956 symbolic link to it or run it in place; the actual script file
957 must be stored as part of the documentation source tree,
958 though it may be used to format documents outside the
959 tree. Use
\program{mkhowto -
}\program{-help
} for a list of
960 command line options.
962 \program{mkhowto
} can be used for both
\code{howto
} and
963 \code{manual
} class documents. (For the later, be sure to get
964 the latest version from the Python CVS repository rather than
965 the version distributed in the
\file{latex-
1.5.2.tgz
} source
972 \section{Future Directions
\label{futures
}}
974 The history of the Python documentation is full of changes, most of
975 which have been fairly small and evolutionary. There has been a
976 great deal of discussion about making large changes in the markup
977 languages and tools used to process the documentation. This section
978 deals with the nature of the changes and what appears to be the most
979 likely path of future development.
981 \subsection{Structured Documentation
\label{structured
}}
983 Most of the small changes to the
\LaTeX{} markup have been made
984 with an eye to divorcing the markup from the presentation, making
985 both a bit more maintainable. Over the course of
1998, a large
986 number of changes were made with exactly this in mind; previously,
987 changes had been made but in a less systematic manner and with
988 more concern for not needing to update the existing content. The
989 result has been a highly structured and semantically loaded markup
990 language implemented in
\LaTeX. With almost no basic
\TeX{} or
991 \LaTeX{} markup in use, however, the markup syntax is about the
992 only evidence of
\LaTeX{} in the actual
document sources.
994 One side effect of this is that while we've been able to use
995 standard ``engines'' for manipulating the documents, such as
996 \LaTeX{} and
\LaTeX2HTML, most of the actual transformations have
997 been created specifically for Python. The
\LaTeX{} document
998 classes and
\LaTeX2HTML support are both complete implementations
999 of the specific markup designed for these documents.
1001 Combining highly customized markup with the somewhat esoteric
1002 systems used to process the documents leads us to ask some
1003 questions: Can we do this more easily? and, Can we do this
1004 better? After a great deal of discussion with the community, we
1005 have determined that actively pursuing modern structured
1006 documentation systems is worth some investment of time.
1008 There appear to be two real contenders in this arena: the Standard
1009 General Markup Language (SGML), and the Extensible Markup Language
1010 (XML). Both of these standards have advantages and disadvantages,
1011 and many advantages are shared.
1013 SGML offers advantages which may appeal most to authors,
1014 especially those using ordinary text editors. There are also
1015 additional abilities to define content models. A number of
1016 high-quality tools with demonstrated maturity is available, but
1017 most are not free; for those which are, portability issues remain
1020 The advantages of XML include the availability of a large number
1021 of evolving tools. Unfortunately, many of the associated
1022 standards are still evolving, and the tools will have to follow
1023 along. This means that developing a robust tool set that uses
1024 more than the basic XML
1.0 recommendation is not possible in the
1025 short term. The promised availability of a wide variety of
1026 high-quality tools which support some of the most important
1027 related standards is not immediate. Many tools are likely to be
1030 XXX Eventual migration to SGML/XML.
1032 \subsection{Discussion Forums
\label{discussion
}}
1034 Discussion of the future of the Python documentation and related
1035 topics takes place in the Documentation Special Interest Group, or
1036 ``Doc-SIG.'' Information on the group, including mailing list
1037 archives and subscription information, is available at
1038 \url{http://www.python.org/sigs/doc-sig/
}. The SIG is open to all
1041 Comments and bug reports on the standard documents should be sent
1042 to
\email{python-docs@python.org
}. This may include comments
1043 about formatting, content, grammatical and spelling errors, or
1044 this
document. You can also send comments on this
document
1045 directly to the author at
\email{fdrake@acm.org
}.