blob: f7b90fa135e811c6b9d1ac2a2c01c092b5d545aa [file] [log] [blame]
Fred Drakeacffaee1999-03-16 16:09:13 +00001\documentclass{howto}
2\usepackage{ltxmarkup}
3
4\title{Documenting Python}
5
6\input{boilerplate}
7
8% Now override the stuff that includes author information:
9
10\author{Fred L. Drake, Jr.}
11\authoraddress{
12 Corporation for National Research Initiatives (CNRI) \\
13 1895 Preston White Drive, Reston, Va 20191, USA \\
14 E-mail: \email{fdrake@acm.org}
15}
16\date{\today}
17
18
19\begin{document}
20
21\maketitle
22
23\begin{abstract}
24\noindent
25The Python language documentation has a substantial body of
26documentation, much of it contributed by various authors. The markup
27used for the Python documentation is based on \LaTeX{} and requires a
28significant set of macros written specifically for documenting Python.
29Maintaining the documentation requires substantial effort, in part
30because selecting the correct markup to use is not always easy.
31
32This document describes the document classes and special markup used
33in the Python documentation. Authors may use this guide, in
34conjunction with the template files provided with the
35distribution, to create or maintain whole documents or sections.
36\end{abstract}
37
38\tableofcontents
39
40
41\section{Introduction}
42
43 Python's documentation has long been considered to be good for a
44 free programming language. There are a number of reasons for this,
45 the most important being the early commitment of Python's creator,
46 Guido van Rossum, to providing documentation on the language and its
47 libraries, and the continuing involvement of the user community in
48 providing assistance for creating and maintaining documentation.
49
50 The involvement of the community takes many forms, from authoring to
Fred Drake7a737df1999-04-23 14:41:44 +000051 bug reports to just plain complaining when the documentation could
52 be more complete or easier to use. All of these forms of input from
53 the community have proved useful during the time I've been involved
54 in maintaining the documentation.
Fred Drakeacffaee1999-03-16 16:09:13 +000055
Fred Drake2c4e0091999-03-29 14:55:55 +000056 This document is aimed at authors and potential authors of
Fred Drake7a737df1999-04-23 14:41:44 +000057 documentation for Python. More specifically, it is for people
58 contributing to the standard documentation and developing additional
59 documents using the same tools as the standard documents. This
60 guide will be less useful for authors using the Python documentation
61 tools for topics other than Python, and less useful still for
62 authors not using the tools at all.
Fred Drakeacffaee1999-03-16 16:09:13 +000063
Fred Drake2c4e0091999-03-29 14:55:55 +000064 The material in this guide is intended to assist authors using the
65 Python documentation tools. It includes information on the source
66 distribution of the standard documentation, a discussion of the
Fred Drake7a737df1999-04-23 14:41:44 +000067 document types, reference material on the markup defined in the
68 document classes, a list of the external tools needed for processing
Fred Drake2c4e0091999-03-29 14:55:55 +000069 documents, and reference material on the tools provided with the
70 documentation resources. At the end, there is also a section
Fred Drake7a737df1999-04-23 14:41:44 +000071 discussing future directions for the Python documentation and where
72 to turn for more information.
Fred Drakeacffaee1999-03-16 16:09:13 +000073
74\section{Directory Structure}
75
76 The source distribution for the standard Python documentation
77 contains a large number of directories. While third-party documents
78 do not need to be placed into this structure or need to be placed
79 within a similar structure, it can be helpful to know where to look
80 for examples and tools when developing new documents using the
81 Python documentation tools. This section describes this directory
82 structure.
83
84 The documentation sources are usually placed within the Python
Fred Drake7a737df1999-04-23 14:41:44 +000085 source distribution as the top-level directory \file{Doc/}, but
86 are not dependent on the Python source distribution in any way.
Fred Drakeacffaee1999-03-16 16:09:13 +000087
88 The \file{Doc/} directory contains a few files and several
89 subdirectories. The files are mostly self-explanatory, including a
90 \file{README} and a \file{Makefile}. The directories fall into
91 three categories:
92
93 \begin{definitions}
94 \term{Document Sources}
95 The \LaTeX{} sources for each document are placed in a
96 separate directory. These directories are given short,
97 three-character names.
98
99 \term{Format-Specific Output}
Fred Drake2c4e0091999-03-29 14:55:55 +0000100 Most output formats have a directory which contains a
Fred Drakeacffaee1999-03-16 16:09:13 +0000101 \file{Makefile} which controls the generation of that format
102 and provides storage for the formatted documents. The only
Fred Drake2c4e0091999-03-29 14:55:55 +0000103 variations within this category are the Portable Document
104 Format (PDF) and PostScript versions are placed in the
Fred Drake7a737df1999-04-23 14:41:44 +0000105 directories \file{paper-a4/} and \file{paper-letter/} (this
106 causes all the temporary files created by \LaTeX{} to be kept
107 in the same place for each paper size, where they can be more
108 easily ignored).
Fred Drakeacffaee1999-03-16 16:09:13 +0000109
110 \term{Supplemental Files}
111 Some additional directories are used to store supplemental
112 files used for the various processes. Directories are
113 included for the shared \LaTeX{} document classes, the
114 \LaTeX2HTML support, template files for various document
115 components, and the scripts used to perform various steps in
116 the formatting processes.
117 \end{definitions}
118
Fred Drake2c4e0091999-03-29 14:55:55 +0000119
Fred Drakeadade921999-04-22 13:05:27 +0000120\section{\LaTeX{} Primer \label{latex-primer}}
Fred Drake2c4e0091999-03-29 14:55:55 +0000121
Fred Drakeadade921999-04-22 13:05:27 +0000122 This section is a brief introduction to \LaTeX{} concepts and
123 syntax, to provide authors enough information to author documents
124 productively without having to become ``\TeX{}nicians.''
125
126 \LaTeX{} documents contain two parts: the preamble and the body.
127 The preamble is used to specify certain metadata about the document
128 itself, such as the title, the list of authors, the date, and the
129 \emph{class} the document belongs to. Additional information used
130 to control index generation and the use of bibliographic databases
Fred Drake7a737df1999-04-23 14:41:44 +0000131 can also be placed in the preamble. For most authors, the preamble
Fred Drakeadade921999-04-22 13:05:27 +0000132 can be most easily created by copying it from an existing document
133 and modifying a few key pieces of information.
134
135 The \dfn{class} of a document is used to place a document within a
136 broad category of documents and set some fundamental formatting
137 properties. For Python documentation, two classes are used: the
138 \code{manual} class and the \code{howto} class. These classes also
139 define the additional markup used to document Python concepts and
140 structures. Specific information about these classes is provided in
Fred Drake7a737df1999-04-23 14:41:44 +0000141 section \ref{classes}, ``Document Classes,'' below. The first thing
Fred Drakeadade921999-04-22 13:05:27 +0000142 in the preamble is the declaration of the document's class.
143
144 After the class declaration, a number of \emph{macros} are used to
145 provide further information about the document and setup any
Fred Drake7a737df1999-04-23 14:41:44 +0000146 additional markup that is needed. No output is generated from the
147 preamble; it is an error to include free text in the preamble
148 because it would cause output.
Fred Drakeadade921999-04-22 13:05:27 +0000149
150 The document body follows the preamble. This contains all the
151 printed components of the document marked up structurally.
152
153 XXX This section will discuss what the markup looks like, and
154 explain the difference between an environment and a macro.
Fred Drake2c4e0091999-03-29 14:55:55 +0000155
156
Fred Drakeadade921999-04-22 13:05:27 +0000157\section{Document Classes \label{classes}}
Fred Drakeacffaee1999-03-16 16:09:13 +0000158
159 Two \LaTeX{} document classes are defined specifically for use with
160 the Python documentation. The \code{manual} class is for large
161 documents which are sectioned into chapters, and the \code{howto}
162 class is for smaller documents.
163
164 The \code{manual} documents are larger and are used for most of the
165 standard documents. This document class is based on the standard
166 \LaTeX{} \code{report} class and is formatted very much like a long
Fred Drakeadade921999-04-22 13:05:27 +0000167 technical report. The \emph{Python Reference Manual} is a good
Fred Drake7a737df1999-04-23 14:41:44 +0000168 example of a \code{manual} document, and the \emph{Python Library
169 Reference} is a large example.
Fred Drakeacffaee1999-03-16 16:09:13 +0000170
171 The \code{howto} documents are shorter, and don't have the large
172 structure of the \code{manual} documents. This class is based on
173 the standard \LaTeX{} \code{article} class and is formatted somewhat
174 like the Linux Documentation Project's ``HOWTO'' series as done
175 originally using the LinuxDoc software. The original intent for the
176 document class was that it serve a similar role as the LDP's HOWTO
177 series, but the applicability of the class turns out to be somewhat
178 more broad. This class is used for ``how-to'' documents (this
179 document is an example) and for shorter reference manuals for small,
180 fairly cohesive module libraries. Examples of the later use include
181 the standard \emph{Macintosh Library Modules} and \emph{Using
182 Kerberos from Python}, which contains reference material for an
183 extension package. These documents are roughly equivalent to a
184 single chapter from a larger work.
185
186
Fred Drake7a737df1999-04-23 14:41:44 +0000187\section{Special Markup Constructs}
Fred Drakeacffaee1999-03-16 16:09:13 +0000188
Fred Drake2c4e0091999-03-29 14:55:55 +0000189 The Python document classes define a lot of new environments and
190 macros. This section contains the reference material for these
191 facilities.
192
Fred Drakeacffaee1999-03-16 16:09:13 +0000193 \subsection{Information Units \label{info-units}}
194
Fred Drakeadade921999-04-22 13:05:27 +0000195 XXX Check Maler's book for proper terminology.
Fred Drakeacffaee1999-03-16 16:09:13 +0000196
Fred Drakeadade921999-04-22 13:05:27 +0000197 There are a number of environments used to describe specific
198 features provided by modules. Each environment requires
199 parameters needed to provide basic information about what is being
200 described, and the environment content should be the description.
201 Most of these environments make entries in the general index (if
202 one is being produced for the document); if no index entry is
203 desired, non-indexing variants are available for many of these
204 environments. The environments have names of the form
205 \code{\var{feature}desc}, and the non-indexing variants are named
206 \code{\var{feature}descni}. The available variants are explicitly
207 included in the list below.
208
209 For each of these environments, the first parameter, \var{name},
210 provides the name by which the feature is accessed.
211
212 Environments which describe features of objects within a module,
213 such as object methods or data attributes, allow an optional
214 \var{type name} parameter. When the feature is an attribute of
215 class instances, \var{type name} only needs to be given if the
216 class was not the most recently described class in the module; the
217 \var{name} value from the most recent \env{classdesc} is implied.
218 For features of built-in or extension types, the \var{type name}
Fred Drake7a737df1999-04-23 14:41:44 +0000219 value should always be provided. Another special case includes
220 methods and members of general ``protocols,'' such as the
221 formatter and writer protocols described for the
222 \module{formatter} module: these may be documented without any
223 specific implementation classes, and will always require the
224 \var{type name} parameter to be provided.
Fred Drakeadade921999-04-22 13:05:27 +0000225
226 \begin{envdesc}{datadesc}{\p{name}}
227 This environment is used to document global data in a module,
228 including both variables and values used as ``defined
229 constants.'' Class and object attributes are not documented
230 using this environment.
Fred Drakeacffaee1999-03-16 16:09:13 +0000231 \end{envdesc}
Fred Drake7a737df1999-04-23 14:41:44 +0000232 \begin{envdesc}{datadescni}{\p{name}}
Fred Drakeacffaee1999-03-16 16:09:13 +0000233 Like \env{datadesc}, but without creating any index entries.
234 \end{envdesc}
235
Fred Drakeadade921999-04-22 13:05:27 +0000236 \begin{envdesc}{excdesc}{\p{name}}
Fred Drakeacffaee1999-03-16 16:09:13 +0000237 Describe an exception. This may be either a string exception or
238 a class exception.
239 \end{envdesc}
240
Fred Drakeadade921999-04-22 13:05:27 +0000241 \begin{envdesc}{funcdesc}{\p{name}\p{parameters}}
242 Describe a module-level function. \var{parameters} should
243 not include the parentheses used in the call syntax. Object
244 methods are not documented using this environment. Bound object
245 methods placed in the module namespace as part of the public
246 interface of the module are documented using this, as they are
247 equivalent to normal functions for most purposes.
248
249 The description should include information about the parameters
250 required and how they are used (especially whether mutable
251 objects passed as parameters are modified), side effects, and
252 possible exceptions. A small example may be provided.
Fred Drakeacffaee1999-03-16 16:09:13 +0000253 \end{envdesc}
Fred Drakeadade921999-04-22 13:05:27 +0000254 \begin{envdesc}{funcdescni}{\p{name}\p{parameters}}
Fred Drakeacffaee1999-03-16 16:09:13 +0000255 Like \env{funcdesc}, but without creating any index entries.
256 \end{envdesc}
257
Fred Drakeadade921999-04-22 13:05:27 +0000258 \begin{envdesc}{classdesc}{\p{name}\p{constructor parameters}}
259 Describe a class and its constructor. \var{constructor
260 parameters} should not include the \var{self} parameter or
261 the parentheses used in the call syntax.
Fred Drakeacffaee1999-03-16 16:09:13 +0000262 \end{envdesc}
263
Fred Drakeadade921999-04-22 13:05:27 +0000264 \begin{envdesc}{memberdesc}{\op{type name}\p{name}}
265 Describe an object data attribute. The description should
266 include information about the type of the data to be expected
267 and whether it may be changed directly.
Fred Drakeacffaee1999-03-16 16:09:13 +0000268 \end{envdesc}
Fred Drakeadade921999-04-22 13:05:27 +0000269 \begin{envdesc}{memberdescni}{\op{type name}\p{name}}
Fred Drakeacffaee1999-03-16 16:09:13 +0000270 Like \env{memberdesc}, but without creating any index entries.
271 \end{envdesc}
272
Fred Drakeadade921999-04-22 13:05:27 +0000273 \begin{envdesc}{methoddesc}{\op{type name}\p{name}\p{parameters}}
274 Describe an object method. \var{parameters} should not include
275 the \var{self} parameter or the parentheses used in the call
276 syntax. The description should include similar information to
277 that described for \env{funcdesc}.
Fred Drakeacffaee1999-03-16 16:09:13 +0000278 \end{envdesc}
Fred Drakeadade921999-04-22 13:05:27 +0000279 \begin{envdesc}{methoddescni}{\op{type name}\p{name}\p{parameters}}
Fred Drakeacffaee1999-03-16 16:09:13 +0000280 Like \env{methoddesc}, but without creating any index entries.
281 \end{envdesc}
282
283
284 \subsection{Inline Markup}
285
286 This is where to explain \macro{code}, \macro{function},
287 \macro{email}, etc.
288
289
290 \subsection{Module-specific Markup}
291
292 The markup described in this section is used to provide information
293 about a module being documented. A typical use of this markup
294 appears at the top of the section used to document a module. A
295 typical example might look like this:
296
297\begin{verbatim}
298\section{\module{spam} ---
299 Access to the SPAM facility}
300
301\declaremodule{extension}{spam}
Fred Drake2c4e0091999-03-29 14:55:55 +0000302 \platform{Unix}
Fred Drakeadade921999-04-22 13:05:27 +0000303\modulesynopsis{Access to the SPAM facility of \UNIX{}.}
Fred Drake2c4e0091999-03-29 14:55:55 +0000304\moduleauthor{Jane Doe}{jane.doe@frobnitz.org}
Fred Drakeacffaee1999-03-16 16:09:13 +0000305\end{verbatim}
306
Fred Drakeadade921999-04-22 13:05:27 +0000307 \begin{macrodesc}{declaremodule}{\op{key}\p{type}\p{name}}
Fred Drakeacffaee1999-03-16 16:09:13 +0000308 Requires two parameters: module type (standard, builtin,
309 extension), and the module name. An optional parameter should be
310 given as the basis for the module's ``key'' used for linking to or
311 referencing the section. The ``key'' should only be given if the
Fred Drake2c4e0091999-03-29 14:55:55 +0000312 module's name contains any underscores, and should be the name
313 with the underscores stripped. This should be the first thing
314 after the \macro{section} used to introduce the module.
Fred Drakeacffaee1999-03-16 16:09:13 +0000315 \end{macrodesc}
316
Fred Drakeadade921999-04-22 13:05:27 +0000317 \begin{macrodesc}{platform}{\p{specifier}}
Fred Drakeacffaee1999-03-16 16:09:13 +0000318 Specifies the portability of the module. \var{specifier} is a
319 comma-separated list of keys that specify what platforms the
320 module is available on. The keys are short identifiers;
321 examples that are in use include \samp{IRIX}, \samp{Mac},
322 \samp{Windows}, and \samp{Unix}. It is important to use a key
Fred Drake7a737df1999-04-23 14:41:44 +0000323 which has already been used when applicable. This is used to
324 provide annotations in the Module Index and the HTML and GNU info
325 output.
Fred Drakeacffaee1999-03-16 16:09:13 +0000326 \end{macrodesc}
327
Fred Drakeadade921999-04-22 13:05:27 +0000328 \begin{macrodesc}{modulesynopsis}{\p{text}}
Fred Drakeacffaee1999-03-16 16:09:13 +0000329 The \var{text} is a short, ``one line'' description of the
330 module that can be used as part of the chapter introduction.
Fred Drakeadade921999-04-22 13:05:27 +0000331 This is must be placed after \macro{declaremodule}.
Fred Drakeacffaee1999-03-16 16:09:13 +0000332 The synopsis is used in building the contents of the table
333 inserted as the \macro{localmoduletable}. No text is
334 produced at the point of the markup.
335 \end{macrodesc}
336
Fred Drakeadade921999-04-22 13:05:27 +0000337 \begin{macrodesc}{moduleauthor}{\p{name}\p{email}}
Fred Drakeacffaee1999-03-16 16:09:13 +0000338 This macro is used to encode information about who authored a
339 module. This is currently not used to generate output, but can be
340 used to help determine the origin of the module.
341 \end{macrodesc}
342
343
344 \subsection{Library-level Markup}
345
346 This markup is used when describing a selection of modules. For
347 example, the \emph{Macintosh Library Modules} document uses this
348 to help provide an overview of the modules in the collection, and
349 many chapters in the \emph{Python Library Reference} use it for
350 the same purpose.
351
352 \begin{macrodesc}{localmoduletable}{}
Fred Drake2c4e0091999-03-29 14:55:55 +0000353 If a \file{.syn} file exists for the current
Fred Drakeacffaee1999-03-16 16:09:13 +0000354 chapter (or for the entire document in \code{howto} documents), a
355 \env{synopsistable} is created with the contents loaded from the
356 \file{.syn} file.
357 \end{macrodesc}
358
359
360 \subsection{Table Markup}
361
362 There are three general-purpose table environments defined which
363 should be used whenever possible. These environments are defined
364 to provide tables of specific widths and some convenience for
365 formatting. These environments are not meant to be general
366 replacements for the standard \LaTeX{} table environments, but can
367 be used for an advantage when the documents are processed using
368 the tools for Python documentation processing. In particular, the
369 generated HTML looks good! There is also an advantage for the
Fred Drake7a737df1999-04-23 14:41:44 +0000370 eventual conversion of the documentation to SGML (see section
Fred Drake2c4e0091999-03-29 14:55:55 +0000371 \ref{futures}, ``Future Directions'').
Fred Drakeacffaee1999-03-16 16:09:13 +0000372
373 Each environment is named \env{table\var{cols}}, where \var{cols}
374 is the number of columns in the table specified in lower-case
375 Roman numerals. Within each of these environments, an additional
376 macro, \macro{line\var{cols}}, is defined, where \var{cols}
377 matches the \var{cols} value of the corresponding table
Fred Drake2c4e0091999-03-29 14:55:55 +0000378 environment. These are supported for \var{cols} values of
379 \code{ii}, \code{iii}, and \code{iv}. These environments are all
380 built on top of the \env{tabular} environment.
Fred Drakeacffaee1999-03-16 16:09:13 +0000381
Fred Drakeadade921999-04-22 13:05:27 +0000382 \begin{envdesc}{tableii}{\p{colspec}\p{col1font}\p{heading1}\p{heading2}}
Fred Drakeacffaee1999-03-16 16:09:13 +0000383 Create a two-column table using the \LaTeX{} column specifier
384 \var{colspec}. The column specifier should indicate vertical
385 bars between columns as appropriate for the specific table, but
386 should not specify vertical bars on the outside of the table
387 (that is considered a stylesheet issue). The \var{col1font}
388 parameter is used as a stylistic treatment of the first column
389 of the table: the first column is presented as
390 \code{\e\var{col1font}\{column1\}}. To avoid treating the first
Fred Drakeadade921999-04-22 13:05:27 +0000391 column specially, \var{col1font} may be \samp{textrm}. The
Fred Drakeacffaee1999-03-16 16:09:13 +0000392 column headings are taken from the values \var{heading1} and
393 \var{heading2}.
394 \end{envdesc}
395
Fred Drakeadade921999-04-22 13:05:27 +0000396 \begin{macrodesc}{lineii}{\p{column1}\p{column2}}
Fred Drakeacffaee1999-03-16 16:09:13 +0000397 Create a single table row within a \env{tableii} environment.
398 The text for the first column will be generated by applying the
399 macro named by the \var{col1font} value when the \env{tableii}
400 was opened.
401 \end{macrodesc}
402
Fred Drakeadade921999-04-22 13:05:27 +0000403 \begin{envdesc}{tableiii}{\p{colspec}\p{col1font}\p{heading1}\p{heading2}\p{heading3}}
Fred Drakeacffaee1999-03-16 16:09:13 +0000404 Like the \env{tableii} environment, but with a third column.
405 The heading for the third column is given by \var{heading3}.
406 \end{envdesc}
407
Fred Drakeadade921999-04-22 13:05:27 +0000408 \begin{macrodesc}{lineiii}{\p{column1}\p{column2}\p{column3}}
Fred Drakeacffaee1999-03-16 16:09:13 +0000409 Like the \macro{lineii} macro, but with a third column. The
410 text for the third column is given by \var{column3}.
411 \end{macrodesc}
412
Fred Drakeadade921999-04-22 13:05:27 +0000413 \begin{envdesc}{tableiv}{\p{colspec}\p{col1font}\p{heading1}\p{heading2}\p{heading3}\p{heading4}}
Fred Drakeacffaee1999-03-16 16:09:13 +0000414 Like the \env{tableiii} environment, but with a fourth column.
415 The heading for the fourth column is given by \var{heading4}.
416 \end{envdesc}
417
Fred Drakeadade921999-04-22 13:05:27 +0000418 \begin{macrodesc}{lineiv}{\p{column1}\p{column2}\p{column3}\p{column4}}
Fred Drakeacffaee1999-03-16 16:09:13 +0000419 Like the \macro{lineiii} macro, but with a fourth column. The
420 text for the fourth column is given by \var{column4}.
421 \end{macrodesc}
422
423
424 An additional table-like environment is \env{synopsistable}. The
425 table generated by this environment contains two columns, and each
426 row is defined by an alternate definition of
427 \macro{modulesynopsis}. This environment is not normally use by
428 the user, but is created by the \macro{localmoduletable} macro.
429
430
431 \subsection{Reference List Markup \label{references}}
432
433 Many sections include a list of references to module documentation
434 or external documents. These lists are created using the
435 \env{seealso} environment. This environment defines some
436 additional macros to support creating reference entries in a
437 reasonable manner.
438
439 \begin{envdesc}{seealso}{}
440 This environment creates a ``See also:'' heading and defines the
441 markup used to describe individual references.
442 \end{envdesc}
443
Fred Drakeadade921999-04-22 13:05:27 +0000444 \begin{macrodesc}{seemodule}{\op{key}\p{name}\p{why}}
Fred Drakeacffaee1999-03-16 16:09:13 +0000445 Refer to another module. \var{why} should be a brief
446 explanation of why the reference may be interesting. The module
447 name is given in \var{name}, with the link key given in
448 \var{key} if necessary. In the HTML and PDF conversions, the
449 module name will be a hyperlink to the referred-to module.
Fred Drakeadade921999-04-22 13:05:27 +0000450 \strong{Note:} The module must be documented in the same
451 document (the corresponding \macro{declaremodule} is required).
Fred Drakeacffaee1999-03-16 16:09:13 +0000452 \end{macrodesc}
453
Fred Drakeadade921999-04-22 13:05:27 +0000454 \begin{macrodesc}{seetext}{\p{text}}
Fred Drakeacffaee1999-03-16 16:09:13 +0000455 Add arbitrary text \var{text} to the ``See also:'' list. This
456 can be used to refer to off-line materials or on-line materials
457 using the \macro{url} macro.
458 \end{macrodesc}
459
460
461 \subsection{Index-generating Markup \label{indexing}}
462
463 Effective index generation for technical documents can be very
464 difficult, especially for someone familliar with the topic but not
465 the creation of indexes. Much of the difficulty arises in the
466 area of terminology: including the terms an expert would use for a
467 concept is not sufficient. Coming up with the terms that a novice
Fred Drake2c4e0091999-03-29 14:55:55 +0000468 would look up is fairly difficult for an author who, typically, is
Fred Drakeacffaee1999-03-16 16:09:13 +0000469 an expert in the area she is writing on.
470
Fred Drake2c4e0091999-03-29 14:55:55 +0000471 The truly difficult aspects of index generation are not areas with
472 which the documentation tools can help. However, ease
Fred Drakeacffaee1999-03-16 16:09:13 +0000473 of producing the index once content decisions are make is within
474 the scope of the tools. Markup is provided which the processing
475 software is able to use to generate a variety of kinds of index
476 entry with minimal effort. Additionally, many of the environments
Fred Drake7a737df1999-04-23 14:41:44 +0000477 described in section \ref{info-units}, ``Information Units,'' will
Fred Drakeacffaee1999-03-16 16:09:13 +0000478 generate appropriate entries into the general and module indexes.
479
480 The following macro can be used to control the generation of index
Fred Drakeadade921999-04-22 13:05:27 +0000481 data, and should be used in the document preamble:
Fred Drakeacffaee1999-03-16 16:09:13 +0000482
483 \begin{macrodesc}{makemodindex}{}
Fred Drakeadade921999-04-22 13:05:27 +0000484 This should be used in the document preamble if a ``Module
Fred Drakeacffaee1999-03-16 16:09:13 +0000485 Index'' is desired for a document containing reference material
486 on many modules. This causes a data file
487 \code{lib\macro{jobname}.idx} to be created from the
488 \macro{declaremodule} macros. This file can be processed by the
489 \program{makeindex} program to generate a file which can be
490 \macro{input} into the document at the desired location of the
491 module index.
492 \end{macrodesc}
493
494 There are a number of macros that are useful for adding index
495 entries for particular concepts, many of which are specific to
496 programming languages or even Python.
497
Fred Drakeadade921999-04-22 13:05:27 +0000498 \begin{macrodesc}{bifuncindex}{\p{name}}
Fred Drake2c4e0091999-03-29 14:55:55 +0000499 Add a index entry referring to a built-in function named
500 \var{name}; parenthesis should not be included after
501 \var{name}.
Fred Drakeacffaee1999-03-16 16:09:13 +0000502 \end{macrodesc}
503
Fred Drakeadade921999-04-22 13:05:27 +0000504 \begin{macrodesc}{exindex}{\p{exception}}
Fred Drake2c4e0091999-03-29 14:55:55 +0000505 Add a reference to an exception named \var{exception}. The
506 exception may be either string- or class-based.
Fred Drakeacffaee1999-03-16 16:09:13 +0000507 \end{macrodesc}
508
Fred Drakeadade921999-04-22 13:05:27 +0000509 \begin{macrodesc}{kwindex}{\p{keyword}}
Fred Drake2c4e0091999-03-29 14:55:55 +0000510 Add a reference to a language keyword (not a keyword parameter
511 in a function or method call).
Fred Drakeacffaee1999-03-16 16:09:13 +0000512 \end{macrodesc}
513
Fred Drakeadade921999-04-22 13:05:27 +0000514 \begin{macrodesc}{obindex}{\p{object type}}
Fred Drake2c4e0091999-03-29 14:55:55 +0000515 Add an index entry for a built-in object type.
Fred Drakeacffaee1999-03-16 16:09:13 +0000516 \end{macrodesc}
517
Fred Drakeadade921999-04-22 13:05:27 +0000518 \begin{macrodesc}{opindex}{\p{operator}}
Fred Drake2c4e0091999-03-29 14:55:55 +0000519 Add a reference to an operator, such as \samp{+}.
Fred Drakeacffaee1999-03-16 16:09:13 +0000520 \end{macrodesc}
521
Fred Drakeadade921999-04-22 13:05:27 +0000522 \begin{macrodesc}{refmodindex}{\op{key}\p{module}}
Fred Drakeacffaee1999-03-16 16:09:13 +0000523 Add an index entry for module \var{module}; if \var{module}
524 contains an underscore, the optional parameter \var{key} should
525 be provided as the same string with underscores removed. An
526 index entry ``\var{module} (module)'' will be generated. This
527 is intended for use with non-standard modules implemented in
528 Python.
529 \end{macrodesc}
530
Fred Drakeadade921999-04-22 13:05:27 +0000531 \begin{macrodesc}{refexmodindex}{\op{key}\p{module}}
Fred Drakeacffaee1999-03-16 16:09:13 +0000532 As for \macro{refmodindex}, but the index entry will be
533 ``\var{module} (extension module).'' This is intended for use
534 with non-standard modules not implemented in Python.
535 \end{macrodesc}
536
Fred Drakeadade921999-04-22 13:05:27 +0000537 \begin{macrodesc}{refbimodindex}{\op{key}\p{module}}
Fred Drakeacffaee1999-03-16 16:09:13 +0000538 As for \macro{refmodindex}, but the index entry will be
539 ``\var{module} (built-in module).'' This is intended for use
540 with standard modules not implemented in Python.
541 \end{macrodesc}
542
Fred Drakeadade921999-04-22 13:05:27 +0000543 \begin{macrodesc}{refstmodindex}{\op{key}\p{module}}
Fred Drakeacffaee1999-03-16 16:09:13 +0000544 As for \macro{refmodindex}, but the index entry will be
545 ``\var{module} (standard module).'' This is intended for use
546 with standard modules implemented in Python.
547 \end{macrodesc}
548
Fred Drakeadade921999-04-22 13:05:27 +0000549 \begin{macrodesc}{stindex}{\p{statement}}
Fred Drake2c4e0091999-03-29 14:55:55 +0000550 Add an index entry for a statement type, such as \keyword{print}
Fred Drakeadade921999-04-22 13:05:27 +0000551 or \keyword{try}/\keyword{finally}.
552
553 XXX Need better examples of difference from \macro{kwindex}.
Fred Drakeacffaee1999-03-16 16:09:13 +0000554 \end{macrodesc}
555
556
557 Additional macros are provided which are useful for conveniently
558 creating general index entries which should appear at many places
559 in the index by rotating a list of words. These are simple macros
560 that simply use \macro{index} to build some number of index
561 entries. Index entries build using these macros contain both
562 primary and secondary text.
563
Fred Drakeadade921999-04-22 13:05:27 +0000564 \begin{macrodesc}{indexii}{\p{word1}\p{word2}}
Fred Drakeacffaee1999-03-16 16:09:13 +0000565 Build two index entries. This is exactly equivalent to using
566 \code{\e index\{\var{word1}!\var{word2}\}} and
567 \code{\e index\{\var{word2}!\var{word1}\}}.
568 \end{macrodesc}
569
Fred Drakeadade921999-04-22 13:05:27 +0000570 \begin{macrodesc}{indexiii}{\p{word1}\p{word2}\p{word3}}
Fred Drakeacffaee1999-03-16 16:09:13 +0000571 Build three index entries. This is exactly equivalent to using
572 \code{\e index\{\var{word1}!\var{word2} \var{word3}\}},
573 \code{\e index\{\var{word2}!\var{word3}, \var{word1}\}}, and
574 \code{\e index\{\var{word3}!\var{word1} \var{word2}\}}.
575 \end{macrodesc}
576
Fred Drakeadade921999-04-22 13:05:27 +0000577 \begin{macrodesc}{indexiv}{\p{word1}\p{word2}\p{word3}\p{word4}}
Fred Drakeacffaee1999-03-16 16:09:13 +0000578 Build four index entries. This is exactly equivalent to using
579 \code{\e index\{\var{word1}!\var{word2} \var{word3} \var{word4}\}},
580 \code{\e index\{\var{word2}!\var{word3} \var{word4}, \var{word1}\}},
581 \code{\e index\{\var{word3}!\var{word4}, \var{word1} \var{word2}\}},
582 and
583 \code{\e index\{\var{word4}!\var{word1} \var{word2} \var{word3}\}}.
584 \end{macrodesc}
585
586
587\section{Special Names}
588
589 Many special names are used in the Python documentation, including
590 the names of operating systems, programming languages, standards
591 bodies, and the like. Many of these were assigned \LaTeX{} macros
592 at some point in the distant past, and these macros lived on long
593 past their usefulness. In the current markup, these entities are
594 not assigned any special markup, but the preferred spellings are
595 given here to aid authors in maintaining the consistency of
596 presentation in the Python documentation.
597
598 \begin{description}
599 \item[POSIX]
600 The name assigned to a particular group of standards. This is
601 always uppercase.
602
603 \item[Python]
604 The name of our favorite programming language is always
605 capitalized.
606 \end{description}
607
608
609\section{Processing Tools}
610
611 \subsection{External Tools}
612
613 Many tools are needed to be able to process the Python
614 documentation if all supported formats are required. This
Fred Drakeadade921999-04-22 13:05:27 +0000615 section lists the tools used and when each is required. Consult
616 the \file{Doc/README} file to see if there are specific version
617 requirements for any of these.
Fred Drakeacffaee1999-03-16 16:09:13 +0000618
619 \begin{description}
620 \item[\program{dvips}]
621 This program is a typical part of \TeX{} installations. It is
622 used to generate PostScript from the ``device independent''
Fred Drake2c4e0091999-03-29 14:55:55 +0000623 \file{.dvi} files. It is needed for the conversion to
Fred Drakeacffaee1999-03-16 16:09:13 +0000624 PostScript.
625
626 \item[\program{emacs}]
627 Emacs is the kitchen sink of programmers' editors, and a damn
628 fine kitchen sink it is. It also comes with some of the
629 processing needed to support the proper menu structures for
630 Texinfo documents when an info conversion is desired. This is
Fred Drake2c4e0091999-03-29 14:55:55 +0000631 needed for the info conversion. Using \program{xemacs}
Fred Drakeacffaee1999-03-16 16:09:13 +0000632 instead of FSF \program{emacs} may lead to instability in the
633 conversion, but that's because nobody seems to maintain the
634 Emacs Texinfo code in a portable manner.
635
636 \item[\program{latex}]
637 This is a world-class typesetter by Donald Knuth. It is used
638 for the conversion to PostScript, and is needed for the HTML
639 conversion as well (\LaTeX2HTML requires one of the
640 intermediate files it creates).
641
642 \item[\program{latex2html}]
643 Probably the longest Perl script anyone ever attempted to
644 maintain. This converts \LaTeX{} documents to HTML documents,
645 and does a pretty reasonable job. It is required for the
646 conversions to HTML and GNU info.
647
648 \item[\program{lynx}]
649 This is a text-mode Web browser which includes an
650 HTML-to-plain text conversion. This is used to convert
651 \code{howto} documents to text.
652
653 \item[\program{make}]
654 Just about any version should work for the standard documents,
655 but GNU \program{make} is required for the experimental
656 processes in \file{Doc/tools/sgmlconv/}, at least while
657 they're experimental.
658
659 \item[\program{makeindex}]
660 This is a standard program for converting \LaTeX{} index data
661 to a formatted index; it should be included with all \LaTeX{}
662 installations. It is needed for the PDF and PostScript
663 conversions.
664
665 \item[\program{makeinfo}]
666 GNU \program{makeinfo} is used to convert Texinfo documents to
667 GNU info files. Since Texinfo is used as an intermediate
668 format in the info conversion, this program is needed in that
669 conversion.
670
671 \item[\program{pdflatex}]
672 pdf\TeX{} is a relatively new variant of \TeX, and is used to
673 generate the PDF version of the manuals. It is typically
674 installed as part of most of the large \TeX{} distributions.
Fred Drake7a737df1999-04-23 14:41:44 +0000675 \program{pdflatex} is pdf\TeX{} using the \LaTeX{} format.
Fred Drakeacffaee1999-03-16 16:09:13 +0000676
677 \item[\program{perl}]
678 Perl is required for \LaTeX2HTML{} and one of the scripts used
679 to post-process \LaTeX2HTML output, as well as the
Fred Drake2c4e0091999-03-29 14:55:55 +0000680 HTML-to-Texinfo conversion. This is required for
Fred Drakeacffaee1999-03-16 16:09:13 +0000681 the HTML and GNU info conversions.
682
683 \item[\program{python}]
684 Python is used for many of the scripts in the
685 \file{Doc/tools/} directory; it is required for all
686 conversions. This shouldn't be a problem if you're interested
687 in writing documentation for Python!
688 \end{description}
689
690
691 \subsection{Internal Tools}
692
693 This section describes the various scripts that are used to
694 implement various stages of document processing or to orchestrate
Fred Drake2c4e0091999-03-29 14:55:55 +0000695 entire build sequences. Most of these tools are only useful
Fred Drakeacffaee1999-03-16 16:09:13 +0000696 in the context of building the standard documentation, but some
697 are more general.
698
699 \begin{description}
700 \item[\program{mkhowto}]
701 \end{description}
702
703
704\section{Future Directions \label{futures}}
705
706 The history of the Python documentation is full of changes, most of
707 which have been fairly small and evolutionary. There has been a
708 great deal of discussion about making large changes in the markup
709 languages and tools used to process the documentation. This section
710 deals with the nature of the changes and what appears to be the most
711 likely path of future development.
712
713 \subsection{Structured Documentation \label{structured}}
714
715 Most of the small changes to the \LaTeX{} markup have been made
716 with an eye to divorcing the markup from the presentation, making
717 both a bit more maintainable. Over the course of 1998, a large
718 number of changes were made with exactly this in mind; previously,
719 changes had been made but in a less systematic manner and with
720 more concern for not needing to update the existing content. The
721 result has been a highly structured and semantically loaded markup
722 language implemented in \LaTeX. With almost no basic \TeX{} or
723 \LaTeX{} markup in use, however, the markup syntax is about the
724 only evidence of \LaTeX{} in the actual document sources.
725
726 One side effect of this is that while we've been able to use
727 standard ``engines'' for manipulating the documents, such as
728 \LaTeX{} and \LaTeX2HTML, most of the actual transformations have
Fred Drake7a737df1999-04-23 14:41:44 +0000729 been created specifically for Python. The \LaTeX{} document
730 classes and \LaTeX2HTML support are both complete implementations
731 of the specific markup designed for these documents.
Fred Drakeacffaee1999-03-16 16:09:13 +0000732
733 Combining highly customized markup with the somewhat esoteric
734 systems used to process the documents leads us to ask some
735 questions: Can we do this more easily? and, Can we do this
736 better? After a great deal of discussion with the community, we
737 have determined that actively pursuing modern structured
Fred Drake2c4e0091999-03-29 14:55:55 +0000738 documentation systems is worth some investment of time.
Fred Drakeacffaee1999-03-16 16:09:13 +0000739
740 There appear to be two real contenders in this arena: the Standard
741 General Markup Language (SGML), and the Extensible Markup Language
742 (XML). Both of these standards have advantages and disadvantages,
743 and many advantages are shared.
744
745 SGML offers advantages which may appeal most to authors,
746 especially those using ordinary text editors. There are also
747 additional abilities to define content models. A number of
748 high-quality tools with demonstrated maturity is available, but
749 most are not free; for those which are, portability issues remain
750 a problem.
751
752 The advantages of XML include the availability of a large number
753 of evolving tools. Unfortunately, many of the associated
754 standards are still evolving, and the tools will have to follow
755 along. This means that developing a robust tool set that uses
756 more than the basic XML 1.0 recommendation is not possible in the
757 short term. The promised availability of a wide variety of
758 high-quality tools which support some of the most important
759 related standards is not immediate. Many tools are likely to be
760 free.
761
Fred Drakeadade921999-04-22 13:05:27 +0000762 XXX Eventual migration to SGML/XML.
Fred Drakeacffaee1999-03-16 16:09:13 +0000763
764 \subsection{Discussion Forums \label{discussion}}
765
766 Discussion of the future of the Python documentation and related
Fred Drake7a737df1999-04-23 14:41:44 +0000767 topics takes place in the Documentation Special Interest Group, or
768 ``Doc-SIG.'' Information on the group, including mailing list
769 archives and subscription information, is available at
Fred Drakeacffaee1999-03-16 16:09:13 +0000770 \url{http://www.python.org/sigs/doc-sig/}. The SIG is open to all
771 interested parties.
772
773 Comments and bug reports on the standard documents should be sent
774 to \email{python-docs@python.org}. This may include comments
Fred Drakeadade921999-04-22 13:05:27 +0000775 about formatting, content, grammatical and spelling errors, or
776 this document.
Fred Drakeacffaee1999-03-16 16:09:13 +0000777
778\end{document}