blob: 9e727f7fbacc65fb7376bd5b49c49c1f8b1eb10d [file] [log] [blame]
Fred Drakeacffaee1999-03-16 16:09:13 +00001\documentclass{howto}
2\usepackage{ltxmarkup}
3
4\title{Documenting Python}
5
6\input{boilerplate}
7
Fred Drakec7c9a641999-04-28 18:24:02 +00008% Now override the stuff that includes author information;
9% Guido did *not* write this one!
Fred Drakeacffaee1999-03-16 16:09:13 +000010
11\author{Fred L. Drake, Jr.}
12\authoraddress{
Fred Drake633a8d92000-06-30 15:54:18 +000013 BeOpen PythonLabs \\
14 E-mail: \email{fdrake@beopen.com}
Fred Drakeacffaee1999-03-16 16:09:13 +000015}
Fred Drakeacffaee1999-03-16 16:09:13 +000016
17
18\begin{document}
19
20\maketitle
21
22\begin{abstract}
23\noindent
Fred Drake02997492000-09-21 05:26:43 +000024The Python language has a substantial body of
Fred Drakeacffaee1999-03-16 16:09:13 +000025documentation, much of it contributed by various authors. The markup
26used for the Python documentation is based on \LaTeX{} and requires a
27significant set of macros written specifically for documenting Python.
Fred Drake5eb992b1999-06-11 14:25:45 +000028This document describes the macros introduced to support Python
29documentation and how they should be used to support a wide range of
30output formats.
Fred Drakeacffaee1999-03-16 16:09:13 +000031
32This document describes the document classes and special markup used
33in the Python documentation. Authors may use this guide, in
34conjunction with the template files provided with the
35distribution, to create or maintain whole documents or sections.
36\end{abstract}
37
38\tableofcontents
39
40
41\section{Introduction}
42
43 Python's documentation has long been considered to be good for a
44 free programming language. There are a number of reasons for this,
45 the most important being the early commitment of Python's creator,
46 Guido van Rossum, to providing documentation on the language and its
47 libraries, and the continuing involvement of the user community in
48 providing assistance for creating and maintaining documentation.
49
50 The involvement of the community takes many forms, from authoring to
Fred Drake7a737df1999-04-23 14:41:44 +000051 bug reports to just plain complaining when the documentation could
52 be more complete or easier to use. All of these forms of input from
53 the community have proved useful during the time I've been involved
54 in maintaining the documentation.
Fred Drakeacffaee1999-03-16 16:09:13 +000055
Fred Drake2c4e0091999-03-29 14:55:55 +000056 This document is aimed at authors and potential authors of
Fred Drake7a737df1999-04-23 14:41:44 +000057 documentation for Python. More specifically, it is for people
58 contributing to the standard documentation and developing additional
59 documents using the same tools as the standard documents. This
60 guide will be less useful for authors using the Python documentation
61 tools for topics other than Python, and less useful still for
62 authors not using the tools at all.
Fred Drakeacffaee1999-03-16 16:09:13 +000063
Fred Drake2c4e0091999-03-29 14:55:55 +000064 The material in this guide is intended to assist authors using the
65 Python documentation tools. It includes information on the source
66 distribution of the standard documentation, a discussion of the
Fred Drake7a737df1999-04-23 14:41:44 +000067 document types, reference material on the markup defined in the
68 document classes, a list of the external tools needed for processing
Fred Drake2c4e0091999-03-29 14:55:55 +000069 documents, and reference material on the tools provided with the
70 documentation resources. At the end, there is also a section
Fred Drake7a737df1999-04-23 14:41:44 +000071 discussing future directions for the Python documentation and where
72 to turn for more information.
Fred Drakeacffaee1999-03-16 16:09:13 +000073
74\section{Directory Structure}
75
76 The source distribution for the standard Python documentation
77 contains a large number of directories. While third-party documents
78 do not need to be placed into this structure or need to be placed
79 within a similar structure, it can be helpful to know where to look
80 for examples and tools when developing new documents using the
81 Python documentation tools. This section describes this directory
82 structure.
83
84 The documentation sources are usually placed within the Python
Fred Drake7a737df1999-04-23 14:41:44 +000085 source distribution as the top-level directory \file{Doc/}, but
86 are not dependent on the Python source distribution in any way.
Fred Drakeacffaee1999-03-16 16:09:13 +000087
88 The \file{Doc/} directory contains a few files and several
89 subdirectories. The files are mostly self-explanatory, including a
90 \file{README} and a \file{Makefile}. The directories fall into
91 three categories:
92
93 \begin{definitions}
94 \term{Document Sources}
95 The \LaTeX{} sources for each document are placed in a
Fred Drake02997492000-09-21 05:26:43 +000096 separate directory. These directories are given short
97 names which vaguely indicate the document in each:
Fred Drake2f4bebd1999-04-28 16:43:11 +000098
99 \begin{tableii}{p{.75in}|p{3in}}{filenq}{Directory}{Document Title}
Fred Drake31edf4d2000-09-07 20:06:07 +0000100 \lineii{api/}
101 {\citetitle[../api/api.html]{The Python/C API}}
102 \lineii{dist/}
103 {\citetitle[../dist/dist.html]{Distributing Python Modules}}
104 \lineii{doc/}
105 {\citetitle[../doc/doc.html]{Documenting Python}}
106 \lineii{ext/}
107 {\citetitle[../ext/ext.html]{Extending and Embedding the Python Interpreter}}
108 \lineii{inst/}
109 {\citetitle[../inst/inst.html]{Installing Python Modules}}
110 \lineii{lib/}
111 {\citetitle[../lib/lib.html]{Python Library Reference}}
112 \lineii{mac/}
113 {\citetitle[../mac/mac.html]{Macintosh Module Reference}}
114 \lineii{ref/}
115 {\citetitle[../ref/ref.html]{Python Reference Manual}}
116 \lineii{tut/}
117 {\citetitle[../tut/tut.html]{Python Tutorial}}
Fred Drake2f4bebd1999-04-28 16:43:11 +0000118 \end{tableii}
Fred Drakeacffaee1999-03-16 16:09:13 +0000119
120 \term{Format-Specific Output}
Fred Drake2c4e0091999-03-29 14:55:55 +0000121 Most output formats have a directory which contains a
Fred Drakeacffaee1999-03-16 16:09:13 +0000122 \file{Makefile} which controls the generation of that format
123 and provides storage for the formatted documents. The only
Fred Drake2c4e0091999-03-29 14:55:55 +0000124 variations within this category are the Portable Document
125 Format (PDF) and PostScript versions are placed in the
Fred Drake7a737df1999-04-23 14:41:44 +0000126 directories \file{paper-a4/} and \file{paper-letter/} (this
127 causes all the temporary files created by \LaTeX{} to be kept
128 in the same place for each paper size, where they can be more
129 easily ignored).
Fred Drakeacffaee1999-03-16 16:09:13 +0000130
Fred Drake2f4bebd1999-04-28 16:43:11 +0000131 \begin{tableii}{p{.75in}|p{3in}}{filenq}{Directory}{Output Formats}
132 \lineii{html/}{HTML output}
133 \lineii{info/}{GNU info output}
134 \lineii{paper-a4/}{PDF and PostScript, A4 paper}
135 \lineii{paper-letter/}{PDF and PostScript, US-Letter paper}
136 \end{tableii}
137
Fred Drakeacffaee1999-03-16 16:09:13 +0000138 \term{Supplemental Files}
139 Some additional directories are used to store supplemental
140 files used for the various processes. Directories are
141 included for the shared \LaTeX{} document classes, the
142 \LaTeX2HTML support, template files for various document
143 components, and the scripts used to perform various steps in
144 the formatting processes.
Fred Drake2f4bebd1999-04-28 16:43:11 +0000145
146 \begin{tableii}{p{.75in}|p{3in}}{filenq}{Directory}{Contents}
147 \lineii{perl/}{Support for \LaTeX2HTML processing}
148 \lineii{templates/}{Example files for source documents}
149 \lineii{texinputs/}{Style implementation for \LaTeX}
150 \lineii{tools/}{Custom processing scripts}
151 \end{tableii}
152
Fred Drakeacffaee1999-03-16 16:09:13 +0000153 \end{definitions}
154
Fred Drake2c4e0091999-03-29 14:55:55 +0000155
Fred Drakeadade921999-04-22 13:05:27 +0000156\section{\LaTeX{} Primer \label{latex-primer}}
Fred Drake2c4e0091999-03-29 14:55:55 +0000157
Fred Drakeadade921999-04-22 13:05:27 +0000158 This section is a brief introduction to \LaTeX{} concepts and
159 syntax, to provide authors enough information to author documents
160 productively without having to become ``\TeX{}nicians.''
161
Fred Drake5eb992b1999-06-11 14:25:45 +0000162 Perhaps the most important concept to keep in mind while marking up
Fred Drake02997492000-09-21 05:26:43 +0000163 Python documentation is that while \TeX{} is unstructured, \LaTeX{} was
Fred Drake5eb992b1999-06-11 14:25:45 +0000164 designed as a layer on top of \TeX{} which specifically supports
165 structured markup. The Python-specific markup is intended to extend
166 the structure provided by standard \LaTeX{} document classes to
167 support additional information specific to Python.
168
Fred Drakeadade921999-04-22 13:05:27 +0000169 \LaTeX{} documents contain two parts: the preamble and the body.
170 The preamble is used to specify certain metadata about the document
171 itself, such as the title, the list of authors, the date, and the
172 \emph{class} the document belongs to. Additional information used
173 to control index generation and the use of bibliographic databases
Fred Drake7a737df1999-04-23 14:41:44 +0000174 can also be placed in the preamble. For most authors, the preamble
Fred Drakeadade921999-04-22 13:05:27 +0000175 can be most easily created by copying it from an existing document
176 and modifying a few key pieces of information.
177
178 The \dfn{class} of a document is used to place a document within a
179 broad category of documents and set some fundamental formatting
180 properties. For Python documentation, two classes are used: the
181 \code{manual} class and the \code{howto} class. These classes also
182 define the additional markup used to document Python concepts and
183 structures. Specific information about these classes is provided in
Fred Drake7a737df1999-04-23 14:41:44 +0000184 section \ref{classes}, ``Document Classes,'' below. The first thing
Fred Drakeadade921999-04-22 13:05:27 +0000185 in the preamble is the declaration of the document's class.
186
187 After the class declaration, a number of \emph{macros} are used to
188 provide further information about the document and setup any
Fred Drake7a737df1999-04-23 14:41:44 +0000189 additional markup that is needed. No output is generated from the
190 preamble; it is an error to include free text in the preamble
191 because it would cause output.
Fred Drakeadade921999-04-22 13:05:27 +0000192
193 The document body follows the preamble. This contains all the
Fred Drake63568aa2000-10-19 05:36:10 +0000194 printed components of the document marked up structurally. Generic
195 \LaTeX{} structures include hierarchical sections
Fred Drakeadade921999-04-22 13:05:27 +0000196
Fred Drake63568aa2000-10-19 05:36:10 +0000197 \subsection{Syntax}
198
199 There are only a things that an author of Python documentation
200 needs to know about \LaTeX{} syntax.
201
202 A \dfn{comment} is started by the ``percent'' character
203 (\character{\%}) and continues through the end of the line and all
204 leading whitespace on the following line. This is a little
205 different from any programming language I know of, so an example
206 is in order:
207
208\begin{verbatim}
209This is text.% comment
210 This is more text. % another comment
211Still more text.
212\end{verbatim}
213
214 The first non-comment character following the first comment is the
215 letter \character{T} on the second line; the leading whitespace on
216 that line is consumed as part of the first comment. This means
217 that there is no space between the first and second sentences, so
218 the period and letter \character{T} will be directly adjacent in
219 the typeset document.
220
221 Note also that though the first non-comment character after the
222 second comment is the letter \character{S}, there is whitespace
223 preceding the comment, so the two sentences are separated as
224 expected.
225
226 A \dfn{group} is an enclosure for a collection of text and
227 commands which encloses the formatting context and constrains the
228 scope of any changes to that context made by commands within the
229 group. Groups can be nested hierarchically. The formatting
230 context includes the font and the definition of additional macros
231 (or overrides of macros defined in outer groups). Syntactically,
232 groups are enclosed in braces:
233
234\begin{verbatim}
235{text in a group}
236\end{verbatim}
237
238 An alternate syntax for a group using brackets (\code{\{...\}}) is
239 used by macros and environment constructors which take optional
240 parameters; brackets do not normally hold syntactic significance.
241 A degenerate group, containing only one atomic bit of content,
242 does not need to have an explicit group, unless it is required to
243 avoid ambiguity. Since Python tends toward the explicit, groups
244 are also made explicit in the documentation markup.
245
246 Groups are used only sparingly in the Python documentation, except
247 for their use in marking parameters to macros and environments.
248
249 A \dfn{macro} is usually simple construct which is identified by
250 name and can take some number of parameters. In normal \LaTeX{}
251 usage, one of these can be optional. The markup is introduced
252 using the backslash character (\character{\e}), and the name is
253 given by alphabetic characters (no digits, hyphens, or
254 underscores). Required parameters should be marked as a group,
255 and optional parameters should be marked using the alternate
256 syntax for a group.
257
258 For example, a macro named ``foo'' which takes a single parameter
259 would appear like this:
260
261\begin{verbatim}
262\name{parameter}
263\end{verbatim}
264
265 A macro which takes an optional parameter would be typed like this
266 when the optional paramter is given:
267
268\begin{verbatim}
269\name[optional]
270\end{verbatim}
271
272 If both optional and required parameters are to be required, it
273 looks like this:
274
275\begin{verbatim}
276\name[optional]{required}
277\end{verbatim}
278
279 A macro name may be followed by a space or newline; a space
280 between the macro name and any parameters will be consumed, but
281 this usage is not practiced in the Python documentation. Such a
282 space is still consumed if there are no parameters to the marco,
283 in which case inserting an empty group (\code{\{\}}) or explicit
284 word space (\samp{\e\ }) immediately after the macro name helps to
285 avoid running the expansion of the macro into the following text.
286 Macros which take no parameters but which should not be followed
287 by a word space do not need special treatment if the following
288 character in the document source if not a name character (such as
289 puctuation).
290
291 Each line of this example shows an appropriate way to write text
292 which includes a macro which takes no parameters:
293
294\begin{verbatim}
295This \UNIX{} is followed by a space.
296This \UNIX\ is also followed by a space.
297\UNIX, followed by a comma, needs no additional markup.
298\end{verbatim}
299
300 An \dfn{environment} is ...
301
302 There are a number of less-used marks in \LaTeX{} are used to
303 enter non-\ASCII{} characters, especially those used in European
304 names. Some which are found in the Python documentation are:
305
306 XXX Table of Latin-1 characters that we've actually used in the
307 Python documentation, pointer to other, more complete
308 documentation elsewhere.
309
310
311 \subsection{Hierarchical Structure}
312
313 XXX Talk about the traditional sectional hierarchy and how it's
314 marked in \LaTeX.
Fred Drake2c4e0091999-03-29 14:55:55 +0000315
316
Fred Drakeadade921999-04-22 13:05:27 +0000317\section{Document Classes \label{classes}}
Fred Drakeacffaee1999-03-16 16:09:13 +0000318
319 Two \LaTeX{} document classes are defined specifically for use with
320 the Python documentation. The \code{manual} class is for large
321 documents which are sectioned into chapters, and the \code{howto}
322 class is for smaller documents.
323
324 The \code{manual} documents are larger and are used for most of the
325 standard documents. This document class is based on the standard
326 \LaTeX{} \code{report} class and is formatted very much like a long
Fred Drake698d5201999-11-10 15:54:57 +0000327 technical report. The \citetitle[../ref/ref.html]{Python Reference
328 Manual} is a good example of a \code{manual} document, and the
329 \citetitle[../lib/lib.html]{Python Library Reference} is a large
330 example.
Fred Drakeacffaee1999-03-16 16:09:13 +0000331
332 The \code{howto} documents are shorter, and don't have the large
333 structure of the \code{manual} documents. This class is based on
334 the standard \LaTeX{} \code{article} class and is formatted somewhat
335 like the Linux Documentation Project's ``HOWTO'' series as done
336 originally using the LinuxDoc software. The original intent for the
337 document class was that it serve a similar role as the LDP's HOWTO
338 series, but the applicability of the class turns out to be somewhat
Fred Drake02997492000-09-21 05:26:43 +0000339 broader. This class is used for ``how-to'' documents (this
Fred Drakeacffaee1999-03-16 16:09:13 +0000340 document is an example) and for shorter reference manuals for small,
341 fairly cohesive module libraries. Examples of the later use include
Fred Drake698d5201999-11-10 15:54:57 +0000342 the standard \citetitle[../mac/mac.html]{Macintosh Library Modules}
343 and
Fred Drake6a547c72000-09-15 22:11:24 +0000344\citetitle[http://starship.python.net/crew/fdrake/manuals/krb5py/krb5py.html]{Using
Fred Drakeacffaee1999-03-16 16:09:13 +0000345 Kerberos from Python}, which contains reference material for an
346 extension package. These documents are roughly equivalent to a
347 single chapter from a larger work.
348
349
Fred Drake7a737df1999-04-23 14:41:44 +0000350\section{Special Markup Constructs}
Fred Drakeacffaee1999-03-16 16:09:13 +0000351
Fred Drake2c4e0091999-03-29 14:55:55 +0000352 The Python document classes define a lot of new environments and
353 macros. This section contains the reference material for these
354 facilities.
355
Fred Drakeaf2b7142000-09-14 20:11:05 +0000356 \subsection{Markup for the Preamble \label{preamble-info}}
357
358 \begin{macrodesc}{release}{\p{ver}}
359 Set the version number for the software described in the
360 document.
361 \end{macrodesc}
362
363 \begin{macrodesc}{setshortversion}{\p{sver}}
364 Specify the ``short'' version number of the documented software
365 to be \var{sver}.
366 \end{macrodesc}
367
Fred Drakee15956b2000-04-03 04:51:13 +0000368 \subsection{Meta-information Markup \label{meta-info}}
369
370 \begin{macrodesc}{sectionauthor}{\p{author}\p{email}}
371 Identifies the author of the current section. \var{author}
372 should be the author's name such that it can be used for
373 presentation (though it isn't), and \var{email} should be the
374 author's email address. The domain name portion of
375 the address should be lower case.
376
377 No presentation is generated from this markup, but it is used to
378 help keep track of contributions.
379 \end{macrodesc}
380
Fred Drakeacffaee1999-03-16 16:09:13 +0000381 \subsection{Information Units \label{info-units}}
382
Fred Drake2f4bebd1999-04-28 16:43:11 +0000383 XXX Explain terminology, or come up with something more ``lay.''
Fred Drakeacffaee1999-03-16 16:09:13 +0000384
Fred Drakeadade921999-04-22 13:05:27 +0000385 There are a number of environments used to describe specific
386 features provided by modules. Each environment requires
387 parameters needed to provide basic information about what is being
388 described, and the environment content should be the description.
389 Most of these environments make entries in the general index (if
390 one is being produced for the document); if no index entry is
391 desired, non-indexing variants are available for many of these
392 environments. The environments have names of the form
393 \code{\var{feature}desc}, and the non-indexing variants are named
394 \code{\var{feature}descni}. The available variants are explicitly
395 included in the list below.
396
397 For each of these environments, the first parameter, \var{name},
398 provides the name by which the feature is accessed.
399
400 Environments which describe features of objects within a module,
401 such as object methods or data attributes, allow an optional
402 \var{type name} parameter. When the feature is an attribute of
403 class instances, \var{type name} only needs to be given if the
404 class was not the most recently described class in the module; the
405 \var{name} value from the most recent \env{classdesc} is implied.
406 For features of built-in or extension types, the \var{type name}
Fred Drake7a737df1999-04-23 14:41:44 +0000407 value should always be provided. Another special case includes
408 methods and members of general ``protocols,'' such as the
409 formatter and writer protocols described for the
410 \module{formatter} module: these may be documented without any
411 specific implementation classes, and will always require the
412 \var{type name} parameter to be provided.
Fred Drakeadade921999-04-22 13:05:27 +0000413
Fred Drake7be440d2000-09-16 21:23:25 +0000414 \begin{envdesc}{cfuncdesc}{\p{type}\p{name}\p{args}}
415 Environment used to described a C function. The \var{type}
416 should be specified as a \keyword{typedef} name, \code{struct
417 \var{tag}}, or the name of a primitive type. If it is a pointer
Fred Drake02997492000-09-21 05:26:43 +0000418 type, the trailing asterisk should not be preceded by a space.
Fred Drake7be440d2000-09-16 21:23:25 +0000419 \var{name} should be the name of the function (or function-like
420 pre-processor macro), and \var{args} should give the types and
421 names of the parameters. The names need to be given so they may
422 be used in the description.
423 \end{envdesc}
424
425 \begin{envdesc}{ctypedesc}{\op{tag}\p{name}}
426 Environment used to described a C type. The \var{name}
427 parameter should be the \keyword{typedef} name. If the type is
428 defined as a \keyword{struct} without a \keyword{typedef},
429 \var{name} should have the form \code{struct \var{tag}}.
430 \var{name} will be added to the index unless \var{tag} is
431 provided, in which case \var{tag} will be used instead.
432 \var{tag} should not be used for a \keyword{typedef} name.
433 \end{envdesc}
434
435 \begin{envdesc}{cvardesc}{\p{type}\p{name}}
436 Description of a global C variable. \var{type} should be the
437 \keyword{typedef} name, \code{struct \var{tag}}, or the name of
438 a primitive type. If variable has a pointer type, the trailing
Fred Drake02997492000-09-21 05:26:43 +0000439 asterisk should \emph{not} be preceded by a space.
Fred Drake7be440d2000-09-16 21:23:25 +0000440 \end{envdesc}
441
Fred Drakeadade921999-04-22 13:05:27 +0000442 \begin{envdesc}{datadesc}{\p{name}}
443 This environment is used to document global data in a module,
444 including both variables and values used as ``defined
445 constants.'' Class and object attributes are not documented
446 using this environment.
Fred Drakeacffaee1999-03-16 16:09:13 +0000447 \end{envdesc}
Fred Drake7a737df1999-04-23 14:41:44 +0000448 \begin{envdesc}{datadescni}{\p{name}}
Fred Drakeacffaee1999-03-16 16:09:13 +0000449 Like \env{datadesc}, but without creating any index entries.
450 \end{envdesc}
451
Fred Drakeadade921999-04-22 13:05:27 +0000452 \begin{envdesc}{excdesc}{\p{name}}
Fred Drakeacffaee1999-03-16 16:09:13 +0000453 Describe an exception. This may be either a string exception or
454 a class exception.
455 \end{envdesc}
456
Fred Drakeadade921999-04-22 13:05:27 +0000457 \begin{envdesc}{funcdesc}{\p{name}\p{parameters}}
458 Describe a module-level function. \var{parameters} should
459 not include the parentheses used in the call syntax. Object
460 methods are not documented using this environment. Bound object
461 methods placed in the module namespace as part of the public
462 interface of the module are documented using this, as they are
463 equivalent to normal functions for most purposes.
464
465 The description should include information about the parameters
466 required and how they are used (especially whether mutable
467 objects passed as parameters are modified), side effects, and
468 possible exceptions. A small example may be provided.
Fred Drakeacffaee1999-03-16 16:09:13 +0000469 \end{envdesc}
Fred Drakeadade921999-04-22 13:05:27 +0000470 \begin{envdesc}{funcdescni}{\p{name}\p{parameters}}
Fred Drakeacffaee1999-03-16 16:09:13 +0000471 Like \env{funcdesc}, but without creating any index entries.
472 \end{envdesc}
473
Fred Drakeadade921999-04-22 13:05:27 +0000474 \begin{envdesc}{classdesc}{\p{name}\p{constructor parameters}}
475 Describe a class and its constructor. \var{constructor
476 parameters} should not include the \var{self} parameter or
477 the parentheses used in the call syntax.
Fred Drakeacffaee1999-03-16 16:09:13 +0000478 \end{envdesc}
479
Fred Drakeadade921999-04-22 13:05:27 +0000480 \begin{envdesc}{memberdesc}{\op{type name}\p{name}}
481 Describe an object data attribute. The description should
482 include information about the type of the data to be expected
483 and whether it may be changed directly.
Fred Drakeacffaee1999-03-16 16:09:13 +0000484 \end{envdesc}
Fred Drakeadade921999-04-22 13:05:27 +0000485 \begin{envdesc}{memberdescni}{\op{type name}\p{name}}
Fred Drakeacffaee1999-03-16 16:09:13 +0000486 Like \env{memberdesc}, but without creating any index entries.
487 \end{envdesc}
488
Fred Drakeadade921999-04-22 13:05:27 +0000489 \begin{envdesc}{methoddesc}{\op{type name}\p{name}\p{parameters}}
490 Describe an object method. \var{parameters} should not include
491 the \var{self} parameter or the parentheses used in the call
492 syntax. The description should include similar information to
493 that described for \env{funcdesc}.
Fred Drakeacffaee1999-03-16 16:09:13 +0000494 \end{envdesc}
Fred Drakeadade921999-04-22 13:05:27 +0000495 \begin{envdesc}{methoddescni}{\op{type name}\p{name}\p{parameters}}
Fred Drakeacffaee1999-03-16 16:09:13 +0000496 Like \env{methoddesc}, but without creating any index entries.
497 \end{envdesc}
498
499
Fred Drake5eb992b1999-06-11 14:25:45 +0000500 \subsection{Showing Code Examples}
501
502 Examples of Python source code or interactive sessions are
503 represented as \env{verbatim} environments. This environment
504 is a standard part of \LaTeX{}. It is important to only use
505 spaces for indentation in code examples since \TeX{} drops tabs
506 instead of converting them to spaces.
507
508 Representing an interactive session requires including the prompts
509 and output along with the Python code. No special markup is
Fred Drake63568aa2000-10-19 05:36:10 +0000510 required for interactive sessions. After the last line of input
511 or output presented, there should not be an ``unused'' primary
512 prompt; this is an example of what \emph{not} to do:
513
514\begin{verbatim}
515>>> 1 + 1
5162
517>>>
518\end{verbatim}
Fred Drake5eb992b1999-06-11 14:25:45 +0000519
520 Within the \env{verbatim} environment, characters special to
521 \LaTeX{} do not need to be specially marked in any way. The entire
522 example will be presented in a monospaced font; no attempt at
523 ``pretty-printing'' is made, as the environment must work for
Fred Drake63568aa2000-10-19 05:36:10 +0000524 non-Python code and non-code displays. There should be no blank
525 lines at the top or bottom of any \env{verbatim} display.
Fred Drake5eb992b1999-06-11 14:25:45 +0000526
527 The Python Documentation Special Interest Group has discussed a
528 number of approaches to creating pretty-printed code displays and
529 interactive sessions; see the Doc-SIG area on the Python Web site
530 for more information on this topic.
531
532
Fred Drakeacffaee1999-03-16 16:09:13 +0000533 \subsection{Inline Markup}
534
Fred Drake87f768e1999-05-17 15:22:45 +0000535 The macros described in this section are used to mark just about
536 anything interesting in the document text. They may be used in
537 headings (though anything involving hyperlinks should be avoided
538 there) as well as in the body text.
Fred Drake2f4bebd1999-04-28 16:43:11 +0000539
540 \begin{macrodesc}{bfcode}{\p{text}}
541 Like \macro{code}, but also makes the font bold-face.
542 \end{macrodesc}
543
544 \begin{macrodesc}{cdata}{\p{name}}
545 The name of a C-language variable.
546 \end{macrodesc}
547
548 \begin{macrodesc}{cfunction}{\p{name}}
549 The name of a C-language function. \var{name} should include the
550 function name and the trailing parentheses.
551 \end{macrodesc}
552
553 \begin{macrodesc}{character}{\p{char}}
554 A character when discussing the character rather than a one-byte
555 string value. The character will be typeset as with \macro{samp}.
556 \end{macrodesc}
557
Fred Drake29a710f1999-11-10 22:51:18 +0000558 \begin{macrodesc}{citetitle}{\op{url}\p{title}}
559 A title for a referenced publication. If \var{url} is specified,
560 the title will be made into a hyperlink when formatted as HTML.
561 \end{macrodesc}
562
Fred Drake2f4bebd1999-04-28 16:43:11 +0000563 \begin{macrodesc}{class}{\p{name}}
564 A class name; a dotted name may be used.
565 \end{macrodesc}
566
567 \begin{macrodesc}{code}{\p{text}}
568 A short code fragment or literal constant value. Typically, it
569 should not include any spaces since no quotation marks are
570 added.
571 \end{macrodesc}
572
573 \begin{macrodesc}{constant}{\p{name}}
574 The name of a ``defined'' constant. This may be a C-language
575 \code{\#define} or a Python variable that is not intended to be
576 changed.
577 \end{macrodesc}
578
579 \begin{macrodesc}{ctype}{\p{name}}
580 The name of a C \keyword{typedef} or structure. For structures
581 defined without a \keyword{typedef}, use \code{\e ctype\{struct
582 struct_tag\}} to make it clear that the \keyword{struct} is
583 required.
584 \end{macrodesc}
585
586 \begin{macrodesc}{deprecated}{\p{version}\p{what to do}}
587 Declare whatever is being described as being deprecated starting
588 with release \var{version}. The text given as \var{what to do}
589 should recommend something to use instead.
590 \end{macrodesc}
591
592 \begin{macrodesc}{dfn}{\p{term}}
593 Mark the defining instance of \var{term} in the text. (No index
594 entries are generated.)
595 \end{macrodesc}
596
Fred Draked1fb7791999-05-17 16:33:54 +0000597 \begin{macrodesc}{e}{}
598 Produces a backslash. This is convenient in \macro{code} and
Fred Drake31edf4d2000-09-07 20:06:07 +0000599 similar macros, and is only defined there. To create a
Fred Drake2b853412000-04-11 19:08:30 +0000600 backslash in ordinary text (such as the contents of the
601 \macro{file} macro), use the standard \macro{textbackslash} macro.
Fred Draked1fb7791999-05-17 16:33:54 +0000602 \end{macrodesc}
603
Fred Drake2f4bebd1999-04-28 16:43:11 +0000604 \begin{macrodesc}{email}{\p{address}}
605 An email address. Note that this is \emph{not} hyperlinked in
Fred Drakee15956b2000-04-03 04:51:13 +0000606 any of the possible output formats. The domain name portion of
607 the address should be lower case.
Fred Drake2f4bebd1999-04-28 16:43:11 +0000608 \end{macrodesc}
609
610 \begin{macrodesc}{emph}{\p{text}}
611 Emphasized text; this will be presented in an italic font.
612 \end{macrodesc}
613
614 \begin{macrodesc}{envvar}{\p{name}}
615 An environment variable. Index entries are generated.
616 \end{macrodesc}
617
618 \begin{macrodesc}{exception}{\p{name}}
619 The name of an exception. A dotted name may be used.
620 \end{macrodesc}
621
622 \begin{macrodesc}{file}{\p{file or dir}}
623 The name of a file or directory. In the PDF and PostScript
624 outputs, single quotes and a font change are used to indicate
625 the file name, but no quotes are used in the HTML output.
Fred Drake31edf4d2000-09-07 20:06:07 +0000626 \strong{Warning:} The \macro{file} macro cannot be used in the
627 content of a section title due to processing limitations.
Fred Drake2f4bebd1999-04-28 16:43:11 +0000628 \end{macrodesc}
629
630 \begin{macrodesc}{filenq}{\p{file or dir}}
631 Like \macro{file}, but single quotes are never used. This can
632 be used in conjunction with tables if a column will only contain
633 file or directory names.
Fred Drake31edf4d2000-09-07 20:06:07 +0000634 \strong{Warning:} The \macro{filenq} macro cannot be used in the
635 content of a section title due to processing limitations.
Fred Drake2f4bebd1999-04-28 16:43:11 +0000636 \end{macrodesc}
637
638 \begin{macrodesc}{function}{\p{name}}
639 The name of a Python function; dotted names may be used.
640 \end{macrodesc}
641
642 \begin{macrodesc}{kbd}{\p{key sequence}}
643 Mark a sequence of keystrokes. What form \var{key sequence}
644 takes may depend on platform- or application-specific
645 conventions. For example, an \program{xemacs} key sequence
646 may be marked like \code{\e kbd\{C-x C-f\}}.
647 \end{macrodesc}
648
649 \begin{macrodesc}{keyword}{\p{name}}
650 The name of a keyword in a programming language.
651 \end{macrodesc}
652
653 \begin{macrodesc}{makevar}{\p{name}}
654 The name of a \program{make} variable.
655 \end{macrodesc}
656
657 \begin{macrodesc}{manpage}{\p{name}\p{section}}
658 A reference to a \UNIX{} manual page.
659 \end{macrodesc}
660
661 \begin{macrodesc}{member}{\p{name}}
662 The name of a data attribute of an object.
663 \end{macrodesc}
664
665 \begin{macrodesc}{method}{\p{name}}
666 The name of a method of an object. \var{name} should include the
667 method name and the trailing parentheses. A dotted name may be
668 used.
669 \end{macrodesc}
670
671 \begin{macrodesc}{mimetype}{\p{name}}
672 The name of a MIME type.
673 \end{macrodesc}
674
675 \begin{macrodesc}{module}{\p{name}}
Fred Drake2b853412000-04-11 19:08:30 +0000676 The name of a module; a dotted name may be used. This should
677 also be used for package names.
Fred Drake2f4bebd1999-04-28 16:43:11 +0000678 \end{macrodesc}
679
680 \begin{macrodesc}{newsgroup}{\p{name}}
681 The name of a USENET newsgroup.
682 \end{macrodesc}
683
Fred Drake2f4bebd1999-04-28 16:43:11 +0000684 \begin{macrodesc}{program}{\p{name}}
685 The name of an executable program. This may differ from the
686 file name for the executable for some platforms. In particular,
687 the \file{.exe} (or other) extension should be omitted for DOS
688 and Windows programs.
689 \end{macrodesc}
690
Fred Drake29a710f1999-11-10 22:51:18 +0000691 \begin{macrodesc}{programopt}{\p{option}}
Fred Drakece444982000-04-11 18:52:52 +0000692 A command-line option to an executable program. Use this only
693 for ``shot'' options, and include the leading hyphen.
694 \end{macrodesc}
695
696 \begin{macrodesc}{longprogramopt}{\p{option}}
697 A long command-line option to an executable program. This
698 should only be used for long option names which will be prefixed
699 by two hyphens; the hyphens should not be provided as part of
700 \var{option}.
Fred Drake29a710f1999-11-10 22:51:18 +0000701 \end{macrodesc}
702
Fred Drake08c5d0c2000-09-11 05:22:30 +0000703 \begin{macrodesc}{pep}{\p{number}}
704 A reference to a Python Enhancement Proposal. This generates
705 appropriate index entries. The text \samp{PEP \var{number}} is
706 generated; in the HTML output, this text is a hyperlink to an
707 online copy of the specified PEP.
708 \end{macrodesc}
709
Fred Drake2f4bebd1999-04-28 16:43:11 +0000710 \begin{macrodesc}{refmodule}{\op{key}\p{name}}
711 Like \macro{module}, but create a hyperlink to the documentation
712 for the named module. Note that the corresponding
713 \macro{declaremodule} must be in the same document. If the
714 \macro{declaremodule} defines a module key different from the
715 module name, it must also be provided as \var{key} to the
716 \macro{refmodule} macro.
717 \end{macrodesc}
718
719 \begin{macrodesc}{regexp}{\p{string}}
720 Mark a regular expression.
721 \end{macrodesc}
722
723 \begin{macrodesc}{rfc}{\p{number}}
724 A reference to an Internet Request for Comments. This generates
725 appropriate index entries. The text \samp{RFC \var{number}} is
726 generated; in the HTML output, this text is a hyperlink to an
727 online copy of the specified RFC.
728 \end{macrodesc}
729
730 \begin{macrodesc}{samp}{\p{text}}
731 A short code sample, but possibly longer than would be given
732 using \macro{code}. Since quotation marks are added, spaces are
733 acceptable.
734 \end{macrodesc}
735
Fred Drakeaf2b7142000-09-14 20:11:05 +0000736 \begin{macrodesc}{shortversion}{}
737 The ``short'' version number of the documented software, as
738 specified using the \macro{setshortversion} macro in the
739 preamble. For Python, the short version number for a release is
740 the first three characters of the \code{sys.version} value. For
741 example, versions 2.0b1 and 2.0.1 both have a short version of
742 2.0. This may not apply for all packages; if
743 \macro{setshortversion} is not used, this produces an empty
744 expansion. See also the \macro{version} macro.
745 \end{macrodesc}
746
Fred Drake2f4bebd1999-04-28 16:43:11 +0000747 \begin{macrodesc}{strong}{\p{text}}
748 Strongly emphasized text; this will be presented using a bold
749 font.
750 \end{macrodesc}
751
Fred Draked1fb7791999-05-17 16:33:54 +0000752 \begin{macrodesc}{url}{\p{url}}
753 A URL (or URN). The URL will be presented as text. In the HTML
754 and PDF formatted versions, the URL will also be a hyperlink.
755 This can be used when referring to external resources. Note
756 that many characters are special to \LaTeX{} and this macro
757 does not always do the right thing. In particular, the tilde
758 character (\character{\~}) is mis-handled; encoding it as a
759 hex-sequence does work, use \samp{\%7e} in place of the tilde
760 character.
761 \end{macrodesc}
762
Fred Drake2f4bebd1999-04-28 16:43:11 +0000763 \begin{macrodesc}{var}{\p{name}}
764 The name of a variable or formal parameter in running text.
765 \end{macrodesc}
766
767 \begin{macrodesc}{version}{}
Fred Drakeaf2b7142000-09-14 20:11:05 +0000768 The version number of the described software, as specified using
769 \macro{release} in the preamble. See also the
770 \macro{shortversion} macro.
Fred Drake2f4bebd1999-04-28 16:43:11 +0000771 \end{macrodesc}
Fred Drakeacffaee1999-03-16 16:09:13 +0000772
Fred Drakec26cc912000-05-02 17:43:44 +0000773 \begin{macrodesc}{versionadded}{\p{version}}
774 The version of Python which added the described feature to the
775 library or C API. This is typically added to the end of the
776 first paragraph of the description before any availability
777 notes. The location should be selected so the explanation makes
778 sense and may vary as needed.
779 \end{macrodesc}
780
781 \begin{macrodesc}{versionchanged}{\op{explanation}\p{version}}
782 The version of Python in which the named feature was changed in
783 some way (new parameters, changed side effects, etc.).
784 \var{explanation} should be a \emph{brief} explanation of the
Fred Drake63568aa2000-10-19 05:36:10 +0000785 change consisting of a capitalized sentence fragment; a
Fred Drakec26cc912000-05-02 17:43:44 +0000786 period will be appended by the formatting process.
787 This is typically added to the end of the first paragraph of the
788 description before any availability notes and after
789 \macro{versionadded}. The location should be selected so the
790 explanation makes sense and may vary as needed.
791 \end{macrodesc}
792
Fred Drakeacffaee1999-03-16 16:09:13 +0000793
794 \subsection{Module-specific Markup}
795
796 The markup described in this section is used to provide information
797 about a module being documented. A typical use of this markup
798 appears at the top of the section used to document a module. A
799 typical example might look like this:
800
801\begin{verbatim}
802\section{\module{spam} ---
803 Access to the SPAM facility}
804
805\declaremodule{extension}{spam}
Fred Drake2c4e0091999-03-29 14:55:55 +0000806 \platform{Unix}
Fred Drakeadade921999-04-22 13:05:27 +0000807\modulesynopsis{Access to the SPAM facility of \UNIX{}.}
Fred Drake2c4e0091999-03-29 14:55:55 +0000808\moduleauthor{Jane Doe}{jane.doe@frobnitz.org}
Fred Drakeacffaee1999-03-16 16:09:13 +0000809\end{verbatim}
810
Fred Drake7932ed02000-08-11 17:37:33 +0000811 Python packages\index{packages} --- collections of modules that can
812 be described as a unit --- are documented using the same markup as
813 modules. The name for a module in a package should be typed in
814 ``fully qualified'' form (i.e., it should include the package name).
815 For example, a module ``foo'' in package ``bar'' should be marked as
816 \samp{\e module\{bar.foo\}}, and the beginning of the reference
817 section would appear as:
818
819\begin{verbatim}
820\section{\module{bar.foo} ---
821 Module from the \module{bar} package}
822
823\declaremodule{extension}{bar.foo}
824\modulesynopsis{Nifty module from the \module{bar} package.}
825\moduleauthor{Jane Doe}{jane.doe@frobnitz.org}
826\end{verbatim}
827
828 Note that the name of a package is also marked using
829 \macro{module}.
830
Fred Drakeadade921999-04-22 13:05:27 +0000831 \begin{macrodesc}{declaremodule}{\op{key}\p{type}\p{name}}
Fred Drake87f768e1999-05-17 15:22:45 +0000832 Requires two parameters: module type (\samp{standard},
833 \samp{builtin}, \samp{extension}, or \samp{}), and the module
834 name. An optional parameter should be given as the basis for the
835 module's ``key'' used for linking to or referencing the section.
836 The ``key'' should only be given if the module's name contains any
837 underscores, and should be the name with the underscores stripped.
838 Note that the \var{type} parameter must be one of the values
839 listed above or an error will be printed. For modules which are
840 contained in packages, the fully-qualified name should be given as
841 \var{name} parameter. This should be the first thing after the
842 \macro{section} used to introduce the module.
Fred Drakeacffaee1999-03-16 16:09:13 +0000843 \end{macrodesc}
844
Fred Drakeadade921999-04-22 13:05:27 +0000845 \begin{macrodesc}{platform}{\p{specifier}}
Fred Drakeacffaee1999-03-16 16:09:13 +0000846 Specifies the portability of the module. \var{specifier} is a
847 comma-separated list of keys that specify what platforms the
848 module is available on. The keys are short identifiers;
849 examples that are in use include \samp{IRIX}, \samp{Mac},
850 \samp{Windows}, and \samp{Unix}. It is important to use a key
Fred Drake7a737df1999-04-23 14:41:44 +0000851 which has already been used when applicable. This is used to
852 provide annotations in the Module Index and the HTML and GNU info
853 output.
Fred Drakeacffaee1999-03-16 16:09:13 +0000854 \end{macrodesc}
855
Fred Drakeadade921999-04-22 13:05:27 +0000856 \begin{macrodesc}{modulesynopsis}{\p{text}}
Fred Drakeacffaee1999-03-16 16:09:13 +0000857 The \var{text} is a short, ``one line'' description of the
858 module that can be used as part of the chapter introduction.
Fred Drakeadade921999-04-22 13:05:27 +0000859 This is must be placed after \macro{declaremodule}.
Fred Drakeacffaee1999-03-16 16:09:13 +0000860 The synopsis is used in building the contents of the table
861 inserted as the \macro{localmoduletable}. No text is
862 produced at the point of the markup.
863 \end{macrodesc}
864
Fred Drakeadade921999-04-22 13:05:27 +0000865 \begin{macrodesc}{moduleauthor}{\p{name}\p{email}}
Fred Drakeacffaee1999-03-16 16:09:13 +0000866 This macro is used to encode information about who authored a
867 module. This is currently not used to generate output, but can be
868 used to help determine the origin of the module.
869 \end{macrodesc}
870
871
872 \subsection{Library-level Markup}
873
874 This markup is used when describing a selection of modules. For
Fred Drake698d5201999-11-10 15:54:57 +0000875 example, the \citetitle[../mac/mac.html]{Macintosh Library
876 Modules} document uses this to help provide an overview of the
877 modules in the collection, and many chapters in the
878 \citetitle[../lib/lib.html]{Python Library Reference} use it for
Fred Drakeacffaee1999-03-16 16:09:13 +0000879 the same purpose.
880
881 \begin{macrodesc}{localmoduletable}{}
Fred Drake2c4e0091999-03-29 14:55:55 +0000882 If a \file{.syn} file exists for the current
Fred Drakeacffaee1999-03-16 16:09:13 +0000883 chapter (or for the entire document in \code{howto} documents), a
884 \env{synopsistable} is created with the contents loaded from the
885 \file{.syn} file.
886 \end{macrodesc}
887
888
889 \subsection{Table Markup}
890
891 There are three general-purpose table environments defined which
892 should be used whenever possible. These environments are defined
893 to provide tables of specific widths and some convenience for
894 formatting. These environments are not meant to be general
895 replacements for the standard \LaTeX{} table environments, but can
896 be used for an advantage when the documents are processed using
897 the tools for Python documentation processing. In particular, the
898 generated HTML looks good! There is also an advantage for the
Fred Drake7a737df1999-04-23 14:41:44 +0000899 eventual conversion of the documentation to SGML (see section
Fred Drake2c4e0091999-03-29 14:55:55 +0000900 \ref{futures}, ``Future Directions'').
Fred Drakeacffaee1999-03-16 16:09:13 +0000901
902 Each environment is named \env{table\var{cols}}, where \var{cols}
903 is the number of columns in the table specified in lower-case
904 Roman numerals. Within each of these environments, an additional
905 macro, \macro{line\var{cols}}, is defined, where \var{cols}
906 matches the \var{cols} value of the corresponding table
Fred Drake2c4e0091999-03-29 14:55:55 +0000907 environment. These are supported for \var{cols} values of
908 \code{ii}, \code{iii}, and \code{iv}. These environments are all
Fred Drakeda72b932000-09-21 15:58:02 +0000909 built on top of the \env{tabular} environment. Variants based on
910 the \env{longtable} environment are also provided.
Fred Drakeacffaee1999-03-16 16:09:13 +0000911
Fred Drake2b853412000-04-11 19:08:30 +0000912 Note that all tables in the standard Python documentation use
913 vertical lines between columns, and this must be specified in the
914 markup for each table. A general border around the outside of the
915 table is not used, but would be the responsibility of the
Fred Drakeda72b932000-09-21 15:58:02 +0000916 processor; the document markup should not include an exterior
917 border.
918
919 The \env{longtable}-based variants of the table environments are
920 formatted with extra space before and after, so should only be
921 used on tables which are long enough that splitting over multiple
922 pages is reasonable; tables with fewer than twenty rows should
923 never by marked using the long flavors of the table environments.
924 The header row is repeated across the top of each part of the
925 table.
Fred Drake2b853412000-04-11 19:08:30 +0000926
Fred Drakeadade921999-04-22 13:05:27 +0000927 \begin{envdesc}{tableii}{\p{colspec}\p{col1font}\p{heading1}\p{heading2}}
Fred Drakeacffaee1999-03-16 16:09:13 +0000928 Create a two-column table using the \LaTeX{} column specifier
929 \var{colspec}. The column specifier should indicate vertical
930 bars between columns as appropriate for the specific table, but
931 should not specify vertical bars on the outside of the table
932 (that is considered a stylesheet issue). The \var{col1font}
933 parameter is used as a stylistic treatment of the first column
934 of the table: the first column is presented as
935 \code{\e\var{col1font}\{column1\}}. To avoid treating the first
Fred Drakeadade921999-04-22 13:05:27 +0000936 column specially, \var{col1font} may be \samp{textrm}. The
Fred Drakeacffaee1999-03-16 16:09:13 +0000937 column headings are taken from the values \var{heading1} and
938 \var{heading2}.
939 \end{envdesc}
940
Fred Drakeda72b932000-09-21 15:58:02 +0000941 \begin{envdesc}{longtableii}{\unspecified}
942 Like \env{tableii}, but produces a table which may be broken
943 across page boundaries. The parameters are the same as for
944 \env{tableii}.
945 \end{envdesc}
946
Fred Drakeadade921999-04-22 13:05:27 +0000947 \begin{macrodesc}{lineii}{\p{column1}\p{column2}}
Fred Drakeda72b932000-09-21 15:58:02 +0000948 Create a single table row within a \env{tableii} or
949 \env{longtableii} environment.
Fred Drakeacffaee1999-03-16 16:09:13 +0000950 The text for the first column will be generated by applying the
951 macro named by the \var{col1font} value when the \env{tableii}
952 was opened.
953 \end{macrodesc}
954
Fred Drakeadade921999-04-22 13:05:27 +0000955 \begin{envdesc}{tableiii}{\p{colspec}\p{col1font}\p{heading1}\p{heading2}\p{heading3}}
Fred Drakeacffaee1999-03-16 16:09:13 +0000956 Like the \env{tableii} environment, but with a third column.
957 The heading for the third column is given by \var{heading3}.
958 \end{envdesc}
959
Fred Drakeda72b932000-09-21 15:58:02 +0000960 \begin{envdesc}{longtableiii}{\unspecified}
961 Like \env{tableiii}, but produces a table which may be broken
962 across page boundaries. The parameters are the same as for
963 \env{tableiii}.
964 \end{envdesc}
965
Fred Drakeadade921999-04-22 13:05:27 +0000966 \begin{macrodesc}{lineiii}{\p{column1}\p{column2}\p{column3}}
Fred Drakeacffaee1999-03-16 16:09:13 +0000967 Like the \macro{lineii} macro, but with a third column. The
968 text for the third column is given by \var{column3}.
969 \end{macrodesc}
970
Fred Drakeadade921999-04-22 13:05:27 +0000971 \begin{envdesc}{tableiv}{\p{colspec}\p{col1font}\p{heading1}\p{heading2}\p{heading3}\p{heading4}}
Fred Drakeacffaee1999-03-16 16:09:13 +0000972 Like the \env{tableiii} environment, but with a fourth column.
973 The heading for the fourth column is given by \var{heading4}.
974 \end{envdesc}
975
Fred Drakeda72b932000-09-21 15:58:02 +0000976 \begin{envdesc}{longtableiv}{\unspecified}
977 Like \env{tableiv}, but produces a table which may be broken
978 across page boundaries. The parameters are the same as for
979 \env{tableiv}.
980 \end{envdesc}
981
Fred Drakeadade921999-04-22 13:05:27 +0000982 \begin{macrodesc}{lineiv}{\p{column1}\p{column2}\p{column3}\p{column4}}
Fred Drakeacffaee1999-03-16 16:09:13 +0000983 Like the \macro{lineiii} macro, but with a fourth column. The
984 text for the fourth column is given by \var{column4}.
985 \end{macrodesc}
986
987
988 An additional table-like environment is \env{synopsistable}. The
989 table generated by this environment contains two columns, and each
990 row is defined by an alternate definition of
Fred Drakee15956b2000-04-03 04:51:13 +0000991 \macro{modulesynopsis}. This environment is not normally used by
992 authors, but is created by the \macro{localmoduletable} macro.
Fred Drakeacffaee1999-03-16 16:09:13 +0000993
994
995 \subsection{Reference List Markup \label{references}}
996
997 Many sections include a list of references to module documentation
998 or external documents. These lists are created using the
999 \env{seealso} environment. This environment defines some
1000 additional macros to support creating reference entries in a
1001 reasonable manner.
1002
Fred Drake5802e482000-07-06 05:24:41 +00001003 The \env{seealso} environment is typically placed in a section
1004 just before any sub-sections. This is done to ensure that
1005 reference links related to the section are not hidden in a
1006 subsection in the hypertext renditions of the documentation.
1007
Fred Drakeacffaee1999-03-16 16:09:13 +00001008 \begin{envdesc}{seealso}{}
1009 This environment creates a ``See also:'' heading and defines the
1010 markup used to describe individual references.
1011 \end{envdesc}
1012
Fred Drake48449982000-09-12 17:52:33 +00001013 For each of the following macros, \var{why} should be one or more
1014 complete sentences, starting with a capital letter (unless it
1015 starts with an identifier, which should not be modified), and
1016 ending with the apropriate punctuation.
Fred Drake5802e482000-07-06 05:24:41 +00001017
Fred Drakeb7cf3782000-09-12 19:58:10 +00001018 These macros are only defined within the content of the
1019 \env{seealso} environment.
1020
Fred Drakeadade921999-04-22 13:05:27 +00001021 \begin{macrodesc}{seemodule}{\op{key}\p{name}\p{why}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001022 Refer to another module. \var{why} should be a brief
1023 explanation of why the reference may be interesting. The module
1024 name is given in \var{name}, with the link key given in
1025 \var{key} if necessary. In the HTML and PDF conversions, the
1026 module name will be a hyperlink to the referred-to module.
Fred Drakeadade921999-04-22 13:05:27 +00001027 \strong{Note:} The module must be documented in the same
1028 document (the corresponding \macro{declaremodule} is required).
Fred Drakeacffaee1999-03-16 16:09:13 +00001029 \end{macrodesc}
1030
Fred Drake08c5d0c2000-09-11 05:22:30 +00001031 \begin{macrodesc}{seepep}{\p{number}\p{title}\p{why}}
1032 Refer to an Python Enhancement Proposal (PEP). \var{number}
1033 should be the official number assigned by the PEP Editor,
1034 \var{title} should be the human-readable title of the PEP as
Fred Drake5802e482000-07-06 05:24:41 +00001035 found in the official copy of the document, and \var{why} should
Fred Drake08c5d0c2000-09-11 05:22:30 +00001036 explain what's interesting about the PEP. This should be used
1037 to refer the reader to PEPs which specify interfaces or language
1038 features relevant to the material in the annotated section of the
1039 documentation.
1040 \end{macrodesc}
1041
1042 \begin{macrodesc}{seerfc}{\p{number}\p{title}\p{why}}
1043 Refer to an IETF Request for Comments (RFC). Otherwise very
1044 similar to \macro{seepep}. This should be used
1045 to refer the reader to PEPs which specify protocols or data
Fred Drake5802e482000-07-06 05:24:41 +00001046 formats relevant to the material in the annotated section of the
1047 documentation.
1048 \end{macrodesc}
1049
Fred Drakeadade921999-04-22 13:05:27 +00001050 \begin{macrodesc}{seetext}{\p{text}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001051 Add arbitrary text \var{text} to the ``See also:'' list. This
1052 can be used to refer to off-line materials or on-line materials
Fred Drake5802e482000-07-06 05:24:41 +00001053 using the \macro{url} macro. This should consist of one or more
1054 complete sentences.
1055 \end{macrodesc}
1056
Fred Drake48449982000-09-12 17:52:33 +00001057 \begin{macrodesc}{seetitle}{\op{url}\p{title}\p{why}}
1058 Add a reference to an external document named \var{title}. If
1059 \var{url} is given, the title is made a hyperlink in the HTML
1060 version of the documentation, and displayed below the title in
1061 the typeset versions of the documentation.
1062 \end{macrodesc}
1063
Fred Drake5802e482000-07-06 05:24:41 +00001064 \begin{macrodesc}{seeurl}{\p{url}\p{why}}
1065 References to specific on-line resources should be given using
1066 the \macro{seeurl} macro. No title is associated with the
1067 reference, but the \var{why} text may include a title marked
1068 using the \macro{citetitle} macro.
Fred Drakeacffaee1999-03-16 16:09:13 +00001069 \end{macrodesc}
1070
1071
1072 \subsection{Index-generating Markup \label{indexing}}
1073
1074 Effective index generation for technical documents can be very
Fred Drakee15956b2000-04-03 04:51:13 +00001075 difficult, especially for someone familiar with the topic but not
Fred Drakeacffaee1999-03-16 16:09:13 +00001076 the creation of indexes. Much of the difficulty arises in the
1077 area of terminology: including the terms an expert would use for a
1078 concept is not sufficient. Coming up with the terms that a novice
Fred Drake2c4e0091999-03-29 14:55:55 +00001079 would look up is fairly difficult for an author who, typically, is
Fred Drakeacffaee1999-03-16 16:09:13 +00001080 an expert in the area she is writing on.
1081
Fred Drake2c4e0091999-03-29 14:55:55 +00001082 The truly difficult aspects of index generation are not areas with
1083 which the documentation tools can help. However, ease
Fred Drakee15956b2000-04-03 04:51:13 +00001084 of producing the index once content decisions are made is within
Fred Drakeacffaee1999-03-16 16:09:13 +00001085 the scope of the tools. Markup is provided which the processing
1086 software is able to use to generate a variety of kinds of index
1087 entry with minimal effort. Additionally, many of the environments
Fred Drake7a737df1999-04-23 14:41:44 +00001088 described in section \ref{info-units}, ``Information Units,'' will
Fred Drakeacffaee1999-03-16 16:09:13 +00001089 generate appropriate entries into the general and module indexes.
1090
1091 The following macro can be used to control the generation of index
Fred Drakeadade921999-04-22 13:05:27 +00001092 data, and should be used in the document preamble:
Fred Drakeacffaee1999-03-16 16:09:13 +00001093
1094 \begin{macrodesc}{makemodindex}{}
Fred Drakeadade921999-04-22 13:05:27 +00001095 This should be used in the document preamble if a ``Module
Fred Drakeacffaee1999-03-16 16:09:13 +00001096 Index'' is desired for a document containing reference material
1097 on many modules. This causes a data file
Fred Draked1fb7791999-05-17 16:33:54 +00001098 \code{lib\var{jobname}.idx} to be created from the
Fred Drakeacffaee1999-03-16 16:09:13 +00001099 \macro{declaremodule} macros. This file can be processed by the
1100 \program{makeindex} program to generate a file which can be
1101 \macro{input} into the document at the desired location of the
1102 module index.
1103 \end{macrodesc}
1104
1105 There are a number of macros that are useful for adding index
1106 entries for particular concepts, many of which are specific to
1107 programming languages or even Python.
1108
Fred Drakeadade921999-04-22 13:05:27 +00001109 \begin{macrodesc}{bifuncindex}{\p{name}}
Fred Drakeec8b9051999-04-23 20:01:17 +00001110 Add an index entry referring to a built-in function named
1111 \var{name}; parentheses should not be included after
Fred Drake2c4e0091999-03-29 14:55:55 +00001112 \var{name}.
Fred Drakeacffaee1999-03-16 16:09:13 +00001113 \end{macrodesc}
1114
Fred Drakeadade921999-04-22 13:05:27 +00001115 \begin{macrodesc}{exindex}{\p{exception}}
Fred Drake2c4e0091999-03-29 14:55:55 +00001116 Add a reference to an exception named \var{exception}. The
1117 exception may be either string- or class-based.
Fred Drakeacffaee1999-03-16 16:09:13 +00001118 \end{macrodesc}
1119
Fred Drakeadade921999-04-22 13:05:27 +00001120 \begin{macrodesc}{kwindex}{\p{keyword}}
Fred Drake2c4e0091999-03-29 14:55:55 +00001121 Add a reference to a language keyword (not a keyword parameter
1122 in a function or method call).
Fred Drakeacffaee1999-03-16 16:09:13 +00001123 \end{macrodesc}
1124
Fred Drakeadade921999-04-22 13:05:27 +00001125 \begin{macrodesc}{obindex}{\p{object type}}
Fred Drake2c4e0091999-03-29 14:55:55 +00001126 Add an index entry for a built-in object type.
Fred Drakeacffaee1999-03-16 16:09:13 +00001127 \end{macrodesc}
1128
Fred Drakeadade921999-04-22 13:05:27 +00001129 \begin{macrodesc}{opindex}{\p{operator}}
Fred Drake2c4e0091999-03-29 14:55:55 +00001130 Add a reference to an operator, such as \samp{+}.
Fred Drakeacffaee1999-03-16 16:09:13 +00001131 \end{macrodesc}
1132
Fred Drakeadade921999-04-22 13:05:27 +00001133 \begin{macrodesc}{refmodindex}{\op{key}\p{module}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001134 Add an index entry for module \var{module}; if \var{module}
1135 contains an underscore, the optional parameter \var{key} should
1136 be provided as the same string with underscores removed. An
1137 index entry ``\var{module} (module)'' will be generated. This
1138 is intended for use with non-standard modules implemented in
1139 Python.
1140 \end{macrodesc}
1141
Fred Drakeadade921999-04-22 13:05:27 +00001142 \begin{macrodesc}{refexmodindex}{\op{key}\p{module}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001143 As for \macro{refmodindex}, but the index entry will be
1144 ``\var{module} (extension module).'' This is intended for use
1145 with non-standard modules not implemented in Python.
1146 \end{macrodesc}
1147
Fred Drakeadade921999-04-22 13:05:27 +00001148 \begin{macrodesc}{refbimodindex}{\op{key}\p{module}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001149 As for \macro{refmodindex}, but the index entry will be
1150 ``\var{module} (built-in module).'' This is intended for use
1151 with standard modules not implemented in Python.
1152 \end{macrodesc}
1153
Fred Drakeadade921999-04-22 13:05:27 +00001154 \begin{macrodesc}{refstmodindex}{\op{key}\p{module}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001155 As for \macro{refmodindex}, but the index entry will be
1156 ``\var{module} (standard module).'' This is intended for use
1157 with standard modules implemented in Python.
1158 \end{macrodesc}
1159
Fred Drakeadade921999-04-22 13:05:27 +00001160 \begin{macrodesc}{stindex}{\p{statement}}
Fred Drake2c4e0091999-03-29 14:55:55 +00001161 Add an index entry for a statement type, such as \keyword{print}
Fred Drakeadade921999-04-22 13:05:27 +00001162 or \keyword{try}/\keyword{finally}.
1163
1164 XXX Need better examples of difference from \macro{kwindex}.
Fred Drakeacffaee1999-03-16 16:09:13 +00001165 \end{macrodesc}
1166
1167
1168 Additional macros are provided which are useful for conveniently
1169 creating general index entries which should appear at many places
1170 in the index by rotating a list of words. These are simple macros
1171 that simply use \macro{index} to build some number of index
1172 entries. Index entries build using these macros contain both
1173 primary and secondary text.
1174
Fred Drakeadade921999-04-22 13:05:27 +00001175 \begin{macrodesc}{indexii}{\p{word1}\p{word2}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001176 Build two index entries. This is exactly equivalent to using
1177 \code{\e index\{\var{word1}!\var{word2}\}} and
1178 \code{\e index\{\var{word2}!\var{word1}\}}.
1179 \end{macrodesc}
1180
Fred Drakeadade921999-04-22 13:05:27 +00001181 \begin{macrodesc}{indexiii}{\p{word1}\p{word2}\p{word3}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001182 Build three index entries. This is exactly equivalent to using
1183 \code{\e index\{\var{word1}!\var{word2} \var{word3}\}},
1184 \code{\e index\{\var{word2}!\var{word3}, \var{word1}\}}, and
1185 \code{\e index\{\var{word3}!\var{word1} \var{word2}\}}.
1186 \end{macrodesc}
1187
Fred Drakeadade921999-04-22 13:05:27 +00001188 \begin{macrodesc}{indexiv}{\p{word1}\p{word2}\p{word3}\p{word4}}
Fred Drakeacffaee1999-03-16 16:09:13 +00001189 Build four index entries. This is exactly equivalent to using
1190 \code{\e index\{\var{word1}!\var{word2} \var{word3} \var{word4}\}},
1191 \code{\e index\{\var{word2}!\var{word3} \var{word4}, \var{word1}\}},
1192 \code{\e index\{\var{word3}!\var{word4}, \var{word1} \var{word2}\}},
1193 and
1194 \code{\e index\{\var{word4}!\var{word1} \var{word2} \var{word3}\}}.
1195 \end{macrodesc}
1196
1197
1198\section{Special Names}
1199
1200 Many special names are used in the Python documentation, including
1201 the names of operating systems, programming languages, standards
1202 bodies, and the like. Many of these were assigned \LaTeX{} macros
1203 at some point in the distant past, and these macros lived on long
1204 past their usefulness. In the current markup, these entities are
1205 not assigned any special markup, but the preferred spellings are
1206 given here to aid authors in maintaining the consistency of
1207 presentation in the Python documentation.
1208
1209 \begin{description}
1210 \item[POSIX]
1211 The name assigned to a particular group of standards. This is
1212 always uppercase.
1213
1214 \item[Python]
1215 The name of our favorite programming language is always
1216 capitalized.
Fred Drake42934682000-04-03 15:00:28 +00001217
1218 \item[Unicode]
1219 The name of a character set and matching encoding. This is
1220 always written capitalized.
Fred Drakeacffaee1999-03-16 16:09:13 +00001221 \end{description}
1222
1223
1224\section{Processing Tools}
1225
1226 \subsection{External Tools}
1227
1228 Many tools are needed to be able to process the Python
1229 documentation if all supported formats are required. This
Fred Drakeadade921999-04-22 13:05:27 +00001230 section lists the tools used and when each is required. Consult
1231 the \file{Doc/README} file to see if there are specific version
1232 requirements for any of these.
Fred Drakeacffaee1999-03-16 16:09:13 +00001233
1234 \begin{description}
1235 \item[\program{dvips}]
1236 This program is a typical part of \TeX{} installations. It is
1237 used to generate PostScript from the ``device independent''
Fred Drake2c4e0091999-03-29 14:55:55 +00001238 \file{.dvi} files. It is needed for the conversion to
Fred Drakeacffaee1999-03-16 16:09:13 +00001239 PostScript.
1240
1241 \item[\program{emacs}]
1242 Emacs is the kitchen sink of programmers' editors, and a damn
1243 fine kitchen sink it is. It also comes with some of the
1244 processing needed to support the proper menu structures for
1245 Texinfo documents when an info conversion is desired. This is
Fred Drake2c4e0091999-03-29 14:55:55 +00001246 needed for the info conversion. Using \program{xemacs}
Fred Drakeacffaee1999-03-16 16:09:13 +00001247 instead of FSF \program{emacs} may lead to instability in the
1248 conversion, but that's because nobody seems to maintain the
1249 Emacs Texinfo code in a portable manner.
1250
1251 \item[\program{latex}]
1252 This is a world-class typesetter by Donald Knuth. It is used
1253 for the conversion to PostScript, and is needed for the HTML
1254 conversion as well (\LaTeX2HTML requires one of the
1255 intermediate files it creates).
1256
1257 \item[\program{latex2html}]
1258 Probably the longest Perl script anyone ever attempted to
1259 maintain. This converts \LaTeX{} documents to HTML documents,
1260 and does a pretty reasonable job. It is required for the
1261 conversions to HTML and GNU info.
1262
1263 \item[\program{lynx}]
1264 This is a text-mode Web browser which includes an
1265 HTML-to-plain text conversion. This is used to convert
1266 \code{howto} documents to text.
1267
1268 \item[\program{make}]
1269 Just about any version should work for the standard documents,
1270 but GNU \program{make} is required for the experimental
1271 processes in \file{Doc/tools/sgmlconv/}, at least while
1272 they're experimental.
1273
1274 \item[\program{makeindex}]
1275 This is a standard program for converting \LaTeX{} index data
1276 to a formatted index; it should be included with all \LaTeX{}
1277 installations. It is needed for the PDF and PostScript
1278 conversions.
1279
1280 \item[\program{makeinfo}]
1281 GNU \program{makeinfo} is used to convert Texinfo documents to
1282 GNU info files. Since Texinfo is used as an intermediate
1283 format in the info conversion, this program is needed in that
1284 conversion.
1285
1286 \item[\program{pdflatex}]
1287 pdf\TeX{} is a relatively new variant of \TeX, and is used to
1288 generate the PDF version of the manuals. It is typically
1289 installed as part of most of the large \TeX{} distributions.
Fred Drake7a737df1999-04-23 14:41:44 +00001290 \program{pdflatex} is pdf\TeX{} using the \LaTeX{} format.
Fred Drakeacffaee1999-03-16 16:09:13 +00001291
1292 \item[\program{perl}]
1293 Perl is required for \LaTeX2HTML{} and one of the scripts used
1294 to post-process \LaTeX2HTML output, as well as the
Fred Drake2c4e0091999-03-29 14:55:55 +00001295 HTML-to-Texinfo conversion. This is required for
Fred Drakeacffaee1999-03-16 16:09:13 +00001296 the HTML and GNU info conversions.
1297
1298 \item[\program{python}]
1299 Python is used for many of the scripts in the
1300 \file{Doc/tools/} directory; it is required for all
1301 conversions. This shouldn't be a problem if you're interested
1302 in writing documentation for Python!
1303 \end{description}
1304
1305
1306 \subsection{Internal Tools}
1307
1308 This section describes the various scripts that are used to
1309 implement various stages of document processing or to orchestrate
Fred Drake2c4e0091999-03-29 14:55:55 +00001310 entire build sequences. Most of these tools are only useful
Fred Drakeacffaee1999-03-16 16:09:13 +00001311 in the context of building the standard documentation, but some
1312 are more general.
1313
1314 \begin{description}
1315 \item[\program{mkhowto}]
Fred Drake87f768e1999-05-17 15:22:45 +00001316 This is the primary script used to format third-party
1317 documents. It contains all the logic needed to ``get it
1318 right.'' The proper way to use this script is to make a
1319 symbolic link to it or run it in place; the actual script file
1320 must be stored as part of the documentation source tree,
1321 though it may be used to format documents outside the
Fred Drakece444982000-04-11 18:52:52 +00001322 tree. Use \program{mkhowto} \longprogramopt{help}
Fred Draked290c101999-11-09 18:03:00 +00001323 for a list of
Fred Draked2a727f1999-05-27 21:45:54 +00001324 command line options.
Fred Drake87f768e1999-05-17 15:22:45 +00001325
Fred Draked1fb7791999-05-17 16:33:54 +00001326 \program{mkhowto} can be used for both \code{howto} and
1327 \code{manual} class documents. (For the later, be sure to get
1328 the latest version from the Python CVS repository rather than
1329 the version distributed in the \file{latex-1.5.2.tgz} source
1330 archive.)
1331
Fred Drake87f768e1999-05-17 15:22:45 +00001332 XXX Need more here.
Fred Drakeacffaee1999-03-16 16:09:13 +00001333 \end{description}
1334
1335
1336\section{Future Directions \label{futures}}
1337
1338 The history of the Python documentation is full of changes, most of
1339 which have been fairly small and evolutionary. There has been a
1340 great deal of discussion about making large changes in the markup
1341 languages and tools used to process the documentation. This section
1342 deals with the nature of the changes and what appears to be the most
1343 likely path of future development.
1344
1345 \subsection{Structured Documentation \label{structured}}
1346
1347 Most of the small changes to the \LaTeX{} markup have been made
1348 with an eye to divorcing the markup from the presentation, making
1349 both a bit more maintainable. Over the course of 1998, a large
1350 number of changes were made with exactly this in mind; previously,
1351 changes had been made but in a less systematic manner and with
1352 more concern for not needing to update the existing content. The
1353 result has been a highly structured and semantically loaded markup
1354 language implemented in \LaTeX. With almost no basic \TeX{} or
1355 \LaTeX{} markup in use, however, the markup syntax is about the
1356 only evidence of \LaTeX{} in the actual document sources.
1357
1358 One side effect of this is that while we've been able to use
1359 standard ``engines'' for manipulating the documents, such as
1360 \LaTeX{} and \LaTeX2HTML, most of the actual transformations have
Fred Drake7a737df1999-04-23 14:41:44 +00001361 been created specifically for Python. The \LaTeX{} document
1362 classes and \LaTeX2HTML support are both complete implementations
1363 of the specific markup designed for these documents.
Fred Drakeacffaee1999-03-16 16:09:13 +00001364
1365 Combining highly customized markup with the somewhat esoteric
1366 systems used to process the documents leads us to ask some
1367 questions: Can we do this more easily? and, Can we do this
1368 better? After a great deal of discussion with the community, we
1369 have determined that actively pursuing modern structured
Fred Drake2c4e0091999-03-29 14:55:55 +00001370 documentation systems is worth some investment of time.
Fred Drakeacffaee1999-03-16 16:09:13 +00001371
1372 There appear to be two real contenders in this arena: the Standard
1373 General Markup Language (SGML), and the Extensible Markup Language
1374 (XML). Both of these standards have advantages and disadvantages,
1375 and many advantages are shared.
1376
1377 SGML offers advantages which may appeal most to authors,
1378 especially those using ordinary text editors. There are also
1379 additional abilities to define content models. A number of
1380 high-quality tools with demonstrated maturity is available, but
1381 most are not free; for those which are, portability issues remain
1382 a problem.
1383
1384 The advantages of XML include the availability of a large number
1385 of evolving tools. Unfortunately, many of the associated
1386 standards are still evolving, and the tools will have to follow
1387 along. This means that developing a robust tool set that uses
1388 more than the basic XML 1.0 recommendation is not possible in the
1389 short term. The promised availability of a wide variety of
1390 high-quality tools which support some of the most important
1391 related standards is not immediate. Many tools are likely to be
1392 free.
1393
Fred Drakeadade921999-04-22 13:05:27 +00001394 XXX Eventual migration to SGML/XML.
Fred Drakeacffaee1999-03-16 16:09:13 +00001395
1396 \subsection{Discussion Forums \label{discussion}}
1397
1398 Discussion of the future of the Python documentation and related
Fred Drake7a737df1999-04-23 14:41:44 +00001399 topics takes place in the Documentation Special Interest Group, or
1400 ``Doc-SIG.'' Information on the group, including mailing list
1401 archives and subscription information, is available at
Fred Drakeacffaee1999-03-16 16:09:13 +00001402 \url{http://www.python.org/sigs/doc-sig/}. The SIG is open to all
1403 interested parties.
1404
1405 Comments and bug reports on the standard documents should be sent
1406 to \email{python-docs@python.org}. This may include comments
Fred Drakeadade921999-04-22 13:05:27 +00001407 about formatting, content, grammatical and spelling errors, or
Fred Draked1fb7791999-05-17 16:33:54 +00001408 this document. You can also send comments on this document
1409 directly to the author at \email{fdrake@acm.org}.
Fred Drakeacffaee1999-03-16 16:09:13 +00001410
1411\end{document}