blob: 449bb8b9eba1bbae59527f1493cf72a55e0f22b5 [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
24The Python language documentation has a substantial body of
25documentation, 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
96 separate directory. These directories are given short,
Fred Drake2f4bebd1999-04-28 16:43:11 +000097 three-character names:
98
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
163 Python documentation is the while \TeX{} is unstructured, \LaTeX{} was
164 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
194 printed components of the document marked up structurally.
195
196 XXX This section will discuss what the markup looks like, and
197 explain the difference between an environment and a macro.
Fred Drake2c4e0091999-03-29 14:55:55 +0000198
199
Fred Drakeadade921999-04-22 13:05:27 +0000200\section{Document Classes \label{classes}}
Fred Drakeacffaee1999-03-16 16:09:13 +0000201
202 Two \LaTeX{} document classes are defined specifically for use with
203 the Python documentation. The \code{manual} class is for large
204 documents which are sectioned into chapters, and the \code{howto}
205 class is for smaller documents.
206
207 The \code{manual} documents are larger and are used for most of the
208 standard documents. This document class is based on the standard
209 \LaTeX{} \code{report} class and is formatted very much like a long
Fred Drake698d5201999-11-10 15:54:57 +0000210 technical report. The \citetitle[../ref/ref.html]{Python Reference
211 Manual} is a good example of a \code{manual} document, and the
212 \citetitle[../lib/lib.html]{Python Library Reference} is a large
213 example.
Fred Drakeacffaee1999-03-16 16:09:13 +0000214
215 The \code{howto} documents are shorter, and don't have the large
216 structure of the \code{manual} documents. This class is based on
217 the standard \LaTeX{} \code{article} class and is formatted somewhat
218 like the Linux Documentation Project's ``HOWTO'' series as done
219 originally using the LinuxDoc software. The original intent for the
220 document class was that it serve a similar role as the LDP's HOWTO
221 series, but the applicability of the class turns out to be somewhat
222 more broad. This class is used for ``how-to'' documents (this
223 document is an example) and for shorter reference manuals for small,
224 fairly cohesive module libraries. Examples of the later use include
Fred Drake698d5201999-11-10 15:54:57 +0000225 the standard \citetitle[../mac/mac.html]{Macintosh Library Modules}
226 and
227\citetitle[http://starship.python.org/crew/fdrake/manuals/krb5py/krb5py.html]{Using
Fred Drakeacffaee1999-03-16 16:09:13 +0000228 Kerberos from Python}, which contains reference material for an
229 extension package. These documents are roughly equivalent to a
230 single chapter from a larger work.
231
232
Fred Drake7a737df1999-04-23 14:41:44 +0000233\section{Special Markup Constructs}
Fred Drakeacffaee1999-03-16 16:09:13 +0000234
Fred Drake2c4e0091999-03-29 14:55:55 +0000235 The Python document classes define a lot of new environments and
236 macros. This section contains the reference material for these
237 facilities.
238
Fred Drakee15956b2000-04-03 04:51:13 +0000239 \subsection{Meta-information Markup \label{meta-info}}
240
241 \begin{macrodesc}{sectionauthor}{\p{author}\p{email}}
242 Identifies the author of the current section. \var{author}
243 should be the author's name such that it can be used for
244 presentation (though it isn't), and \var{email} should be the
245 author's email address. The domain name portion of
246 the address should be lower case.
247
248 No presentation is generated from this markup, but it is used to
249 help keep track of contributions.
250 \end{macrodesc}
251
Fred Drakeacffaee1999-03-16 16:09:13 +0000252 \subsection{Information Units \label{info-units}}
253
Fred Drake2f4bebd1999-04-28 16:43:11 +0000254 XXX Explain terminology, or come up with something more ``lay.''
Fred Drakeacffaee1999-03-16 16:09:13 +0000255
Fred Drakeadade921999-04-22 13:05:27 +0000256 There are a number of environments used to describe specific
257 features provided by modules. Each environment requires
258 parameters needed to provide basic information about what is being
259 described, and the environment content should be the description.
260 Most of these environments make entries in the general index (if
261 one is being produced for the document); if no index entry is
262 desired, non-indexing variants are available for many of these
263 environments. The environments have names of the form
264 \code{\var{feature}desc}, and the non-indexing variants are named
265 \code{\var{feature}descni}. The available variants are explicitly
266 included in the list below.
267
268 For each of these environments, the first parameter, \var{name},
269 provides the name by which the feature is accessed.
270
271 Environments which describe features of objects within a module,
272 such as object methods or data attributes, allow an optional
273 \var{type name} parameter. When the feature is an attribute of
274 class instances, \var{type name} only needs to be given if the
275 class was not the most recently described class in the module; the
276 \var{name} value from the most recent \env{classdesc} is implied.
277 For features of built-in or extension types, the \var{type name}
Fred Drake7a737df1999-04-23 14:41:44 +0000278 value should always be provided. Another special case includes
279 methods and members of general ``protocols,'' such as the
280 formatter and writer protocols described for the
281 \module{formatter} module: these may be documented without any
282 specific implementation classes, and will always require the
283 \var{type name} parameter to be provided.
Fred Drakeadade921999-04-22 13:05:27 +0000284
285 \begin{envdesc}{datadesc}{\p{name}}
286 This environment is used to document global data in a module,
287 including both variables and values used as ``defined
288 constants.'' Class and object attributes are not documented
289 using this environment.
Fred Drakeacffaee1999-03-16 16:09:13 +0000290 \end{envdesc}
Fred Drake7a737df1999-04-23 14:41:44 +0000291 \begin{envdesc}{datadescni}{\p{name}}
Fred Drakeacffaee1999-03-16 16:09:13 +0000292 Like \env{datadesc}, but without creating any index entries.
293 \end{envdesc}
294
Fred Drakeadade921999-04-22 13:05:27 +0000295 \begin{envdesc}{excdesc}{\p{name}}
Fred Drakeacffaee1999-03-16 16:09:13 +0000296 Describe an exception. This may be either a string exception or
297 a class exception.
298 \end{envdesc}
299
Fred Drakeadade921999-04-22 13:05:27 +0000300 \begin{envdesc}{funcdesc}{\p{name}\p{parameters}}
301 Describe a module-level function. \var{parameters} should
302 not include the parentheses used in the call syntax. Object
303 methods are not documented using this environment. Bound object
304 methods placed in the module namespace as part of the public
305 interface of the module are documented using this, as they are
306 equivalent to normal functions for most purposes.
307
308 The description should include information about the parameters
309 required and how they are used (especially whether mutable
310 objects passed as parameters are modified), side effects, and
311 possible exceptions. A small example may be provided.
Fred Drakeacffaee1999-03-16 16:09:13 +0000312 \end{envdesc}
Fred Drakeadade921999-04-22 13:05:27 +0000313 \begin{envdesc}{funcdescni}{\p{name}\p{parameters}}
Fred Drakeacffaee1999-03-16 16:09:13 +0000314 Like \env{funcdesc}, but without creating any index entries.
315 \end{envdesc}
316
Fred Drakeadade921999-04-22 13:05:27 +0000317 \begin{envdesc}{classdesc}{\p{name}\p{constructor parameters}}
318 Describe a class and its constructor. \var{constructor
319 parameters} should not include the \var{self} parameter or
320 the parentheses used in the call syntax.
Fred Drakeacffaee1999-03-16 16:09:13 +0000321 \end{envdesc}
322
Fred Drakeadade921999-04-22 13:05:27 +0000323 \begin{envdesc}{memberdesc}{\op{type name}\p{name}}
324 Describe an object data attribute. The description should
325 include information about the type of the data to be expected
326 and whether it may be changed directly.
Fred Drakeacffaee1999-03-16 16:09:13 +0000327 \end{envdesc}
Fred Drakeadade921999-04-22 13:05:27 +0000328 \begin{envdesc}{memberdescni}{\op{type name}\p{name}}
Fred Drakeacffaee1999-03-16 16:09:13 +0000329 Like \env{memberdesc}, but without creating any index entries.
330 \end{envdesc}
331
Fred Drakeadade921999-04-22 13:05:27 +0000332 \begin{envdesc}{methoddesc}{\op{type name}\p{name}\p{parameters}}
333 Describe an object method. \var{parameters} should not include
334 the \var{self} parameter or the parentheses used in the call
335 syntax. The description should include similar information to
336 that described for \env{funcdesc}.
Fred Drakeacffaee1999-03-16 16:09:13 +0000337 \end{envdesc}
Fred Drakeadade921999-04-22 13:05:27 +0000338 \begin{envdesc}{methoddescni}{\op{type name}\p{name}\p{parameters}}
Fred Drakeacffaee1999-03-16 16:09:13 +0000339 Like \env{methoddesc}, but without creating any index entries.
340 \end{envdesc}
341
342
Fred Drake5eb992b1999-06-11 14:25:45 +0000343 \subsection{Showing Code Examples}
344
345 Examples of Python source code or interactive sessions are
346 represented as \env{verbatim} environments. This environment
347 is a standard part of \LaTeX{}. It is important to only use
348 spaces for indentation in code examples since \TeX{} drops tabs
349 instead of converting them to spaces.
350
351 Representing an interactive session requires including the prompts
352 and output along with the Python code. No special markup is
353 required for interactive sessions.
354
355 Within the \env{verbatim} environment, characters special to
356 \LaTeX{} do not need to be specially marked in any way. The entire
357 example will be presented in a monospaced font; no attempt at
358 ``pretty-printing'' is made, as the environment must work for
359 non-Python code and non-code displays.
360
361 The Python Documentation Special Interest Group has discussed a
362 number of approaches to creating pretty-printed code displays and
363 interactive sessions; see the Doc-SIG area on the Python Web site
364 for more information on this topic.
365
366
Fred Drakeacffaee1999-03-16 16:09:13 +0000367 \subsection{Inline Markup}
368
Fred Drake87f768e1999-05-17 15:22:45 +0000369 The macros described in this section are used to mark just about
370 anything interesting in the document text. They may be used in
371 headings (though anything involving hyperlinks should be avoided
372 there) as well as in the body text.
Fred Drake2f4bebd1999-04-28 16:43:11 +0000373
374 \begin{macrodesc}{bfcode}{\p{text}}
375 Like \macro{code}, but also makes the font bold-face.
376 \end{macrodesc}
377
378 \begin{macrodesc}{cdata}{\p{name}}
379 The name of a C-language variable.
380 \end{macrodesc}
381
382 \begin{macrodesc}{cfunction}{\p{name}}
383 The name of a C-language function. \var{name} should include the
384 function name and the trailing parentheses.
385 \end{macrodesc}
386
387 \begin{macrodesc}{character}{\p{char}}
388 A character when discussing the character rather than a one-byte
389 string value. The character will be typeset as with \macro{samp}.
390 \end{macrodesc}
391
Fred Drake29a710f1999-11-10 22:51:18 +0000392 \begin{macrodesc}{citetitle}{\op{url}\p{title}}
393 A title for a referenced publication. If \var{url} is specified,
394 the title will be made into a hyperlink when formatted as HTML.
395 \end{macrodesc}
396
Fred Drake2f4bebd1999-04-28 16:43:11 +0000397 \begin{macrodesc}{class}{\p{name}}
398 A class name; a dotted name may be used.
399 \end{macrodesc}
400
401 \begin{macrodesc}{code}{\p{text}}
402 A short code fragment or literal constant value. Typically, it
403 should not include any spaces since no quotation marks are
404 added.
405 \end{macrodesc}
406
407 \begin{macrodesc}{constant}{\p{name}}
408 The name of a ``defined'' constant. This may be a C-language
409 \code{\#define} or a Python variable that is not intended to be
410 changed.
411 \end{macrodesc}
412
413 \begin{macrodesc}{ctype}{\p{name}}
414 The name of a C \keyword{typedef} or structure. For structures
415 defined without a \keyword{typedef}, use \code{\e ctype\{struct
416 struct_tag\}} to make it clear that the \keyword{struct} is
417 required.
418 \end{macrodesc}
419
420 \begin{macrodesc}{deprecated}{\p{version}\p{what to do}}
421 Declare whatever is being described as being deprecated starting
422 with release \var{version}. The text given as \var{what to do}
423 should recommend something to use instead.
424 \end{macrodesc}
425
426 \begin{macrodesc}{dfn}{\p{term}}
427 Mark the defining instance of \var{term} in the text. (No index
428 entries are generated.)
429 \end{macrodesc}
430
Fred Draked1fb7791999-05-17 16:33:54 +0000431 \begin{macrodesc}{e}{}
432 Produces a backslash. This is convenient in \macro{code} and
Fred Drake31edf4d2000-09-07 20:06:07 +0000433 similar macros, and is only defined there. To create a
Fred Drake2b853412000-04-11 19:08:30 +0000434 backslash in ordinary text (such as the contents of the
435 \macro{file} macro), use the standard \macro{textbackslash} macro.
Fred Draked1fb7791999-05-17 16:33:54 +0000436 \end{macrodesc}
437
Fred Drake2f4bebd1999-04-28 16:43:11 +0000438 \begin{macrodesc}{email}{\p{address}}
439 An email address. Note that this is \emph{not} hyperlinked in
Fred Drakee15956b2000-04-03 04:51:13 +0000440 any of the possible output formats. The domain name portion of
441 the address should be lower case.
Fred Drake2f4bebd1999-04-28 16:43:11 +0000442 \end{macrodesc}
443
444 \begin{macrodesc}{emph}{\p{text}}
445 Emphasized text; this will be presented in an italic font.
446 \end{macrodesc}
447
448 \begin{macrodesc}{envvar}{\p{name}}
449 An environment variable. Index entries are generated.
450 \end{macrodesc}
451
452 \begin{macrodesc}{exception}{\p{name}}
453 The name of an exception. A dotted name may be used.
454 \end{macrodesc}
455
456 \begin{macrodesc}{file}{\p{file or dir}}
457 The name of a file or directory. In the PDF and PostScript
458 outputs, single quotes and a font change are used to indicate
459 the file name, but no quotes are used in the HTML output.
Fred Drake31edf4d2000-09-07 20:06:07 +0000460 \strong{Warning:} The \macro{file} macro cannot be used in the
461 content of a section title due to processing limitations.
Fred Drake2f4bebd1999-04-28 16:43:11 +0000462 \end{macrodesc}
463
464 \begin{macrodesc}{filenq}{\p{file or dir}}
465 Like \macro{file}, but single quotes are never used. This can
466 be used in conjunction with tables if a column will only contain
467 file or directory names.
Fred Drake31edf4d2000-09-07 20:06:07 +0000468 \strong{Warning:} The \macro{filenq} macro cannot be used in the
469 content of a section title due to processing limitations.
Fred Drake2f4bebd1999-04-28 16:43:11 +0000470 \end{macrodesc}
471
472 \begin{macrodesc}{function}{\p{name}}
473 The name of a Python function; dotted names may be used.
474 \end{macrodesc}
475
476 \begin{macrodesc}{kbd}{\p{key sequence}}
477 Mark a sequence of keystrokes. What form \var{key sequence}
478 takes may depend on platform- or application-specific
479 conventions. For example, an \program{xemacs} key sequence
480 may be marked like \code{\e kbd\{C-x C-f\}}.
481 \end{macrodesc}
482
483 \begin{macrodesc}{keyword}{\p{name}}
484 The name of a keyword in a programming language.
485 \end{macrodesc}
486
487 \begin{macrodesc}{makevar}{\p{name}}
488 The name of a \program{make} variable.
489 \end{macrodesc}
490
491 \begin{macrodesc}{manpage}{\p{name}\p{section}}
492 A reference to a \UNIX{} manual page.
493 \end{macrodesc}
494
495 \begin{macrodesc}{member}{\p{name}}
496 The name of a data attribute of an object.
497 \end{macrodesc}
498
499 \begin{macrodesc}{method}{\p{name}}
500 The name of a method of an object. \var{name} should include the
501 method name and the trailing parentheses. A dotted name may be
502 used.
503 \end{macrodesc}
504
505 \begin{macrodesc}{mimetype}{\p{name}}
506 The name of a MIME type.
507 \end{macrodesc}
508
509 \begin{macrodesc}{module}{\p{name}}
Fred Drake2b853412000-04-11 19:08:30 +0000510 The name of a module; a dotted name may be used. This should
511 also be used for package names.
Fred Drake2f4bebd1999-04-28 16:43:11 +0000512 \end{macrodesc}
513
514 \begin{macrodesc}{newsgroup}{\p{name}}
515 The name of a USENET newsgroup.
516 \end{macrodesc}
517
Fred Drake2f4bebd1999-04-28 16:43:11 +0000518 \begin{macrodesc}{program}{\p{name}}
519 The name of an executable program. This may differ from the
520 file name for the executable for some platforms. In particular,
521 the \file{.exe} (or other) extension should be omitted for DOS
522 and Windows programs.
523 \end{macrodesc}
524
Fred Drake29a710f1999-11-10 22:51:18 +0000525 \begin{macrodesc}{programopt}{\p{option}}
Fred Drakece444982000-04-11 18:52:52 +0000526 A command-line option to an executable program. Use this only
527 for ``shot'' options, and include the leading hyphen.
528 \end{macrodesc}
529
530 \begin{macrodesc}{longprogramopt}{\p{option}}
531 A long command-line option to an executable program. This
532 should only be used for long option names which will be prefixed
533 by two hyphens; the hyphens should not be provided as part of
534 \var{option}.
Fred Drake29a710f1999-11-10 22:51:18 +0000535 \end{macrodesc}
536
Fred Drake08c5d0c2000-09-11 05:22:30 +0000537 \begin{macrodesc}{pep}{\p{number}}
538 A reference to a Python Enhancement Proposal. This generates
539 appropriate index entries. The text \samp{PEP \var{number}} is
540 generated; in the HTML output, this text is a hyperlink to an
541 online copy of the specified PEP.
542 \end{macrodesc}
543
Fred Drake2f4bebd1999-04-28 16:43:11 +0000544 \begin{macrodesc}{refmodule}{\op{key}\p{name}}
545 Like \macro{module}, but create a hyperlink to the documentation
546 for the named module. Note that the corresponding
547 \macro{declaremodule} must be in the same document. If the
548 \macro{declaremodule} defines a module key different from the
549 module name, it must also be provided as \var{key} to the
550 \macro{refmodule} macro.
551 \end{macrodesc}
552
553 \begin{macrodesc}{regexp}{\p{string}}
554 Mark a regular expression.
555 \end{macrodesc}
556
557 \begin{macrodesc}{rfc}{\p{number}}
558 A reference to an Internet Request for Comments. This generates
559 appropriate index entries. The text \samp{RFC \var{number}} is
560 generated; in the HTML output, this text is a hyperlink to an
561 online copy of the specified RFC.
562 \end{macrodesc}
563
564 \begin{macrodesc}{samp}{\p{text}}
565 A short code sample, but possibly longer than would be given
566 using \macro{code}. Since quotation marks are added, spaces are
567 acceptable.
568 \end{macrodesc}
569
570 \begin{macrodesc}{strong}{\p{text}}
571 Strongly emphasized text; this will be presented using a bold
572 font.
573 \end{macrodesc}
574
Fred Draked1fb7791999-05-17 16:33:54 +0000575 \begin{macrodesc}{url}{\p{url}}
576 A URL (or URN). The URL will be presented as text. In the HTML
577 and PDF formatted versions, the URL will also be a hyperlink.
578 This can be used when referring to external resources. Note
579 that many characters are special to \LaTeX{} and this macro
580 does not always do the right thing. In particular, the tilde
581 character (\character{\~}) is mis-handled; encoding it as a
582 hex-sequence does work, use \samp{\%7e} in place of the tilde
583 character.
584 \end{macrodesc}
585
Fred Drake2f4bebd1999-04-28 16:43:11 +0000586 \begin{macrodesc}{var}{\p{name}}
587 The name of a variable or formal parameter in running text.
588 \end{macrodesc}
589
590 \begin{macrodesc}{version}{}
591 The version number for the documentation, as specified using
592 \macro{release} in the preamble.
593 \end{macrodesc}
Fred Drakeacffaee1999-03-16 16:09:13 +0000594
Fred Drakec26cc912000-05-02 17:43:44 +0000595 \begin{macrodesc}{versionadded}{\p{version}}
596 The version of Python which added the described feature to the
597 library or C API. This is typically added to the end of the
598 first paragraph of the description before any availability
599 notes. The location should be selected so the explanation makes
600 sense and may vary as needed.
601 \end{macrodesc}
602
603 \begin{macrodesc}{versionchanged}{\op{explanation}\p{version}}
604 The version of Python in which the named feature was changed in
605 some way (new parameters, changed side effects, etc.).
606 \var{explanation} should be a \emph{brief} explanation of the
607 change consisting of a non-capitalized sentence fragment; a
608 period will be appended by the formatting process.
609 This is typically added to the end of the first paragraph of the
610 description before any availability notes and after
611 \macro{versionadded}. The location should be selected so the
612 explanation makes sense and may vary as needed.
613 \end{macrodesc}
614
Fred Drakeacffaee1999-03-16 16:09:13 +0000615
616 \subsection{Module-specific Markup}
617
618 The markup described in this section is used to provide information
619 about a module being documented. A typical use of this markup
620 appears at the top of the section used to document a module. A
621 typical example might look like this:
622
623\begin{verbatim}
624\section{\module{spam} ---
625 Access to the SPAM facility}
626
627\declaremodule{extension}{spam}
Fred Drake2c4e0091999-03-29 14:55:55 +0000628 \platform{Unix}
Fred Drakeadade921999-04-22 13:05:27 +0000629\modulesynopsis{Access to the SPAM facility of \UNIX{}.}
Fred Drake2c4e0091999-03-29 14:55:55 +0000630\moduleauthor{Jane Doe}{jane.doe@frobnitz.org}
Fred Drakeacffaee1999-03-16 16:09:13 +0000631\end{verbatim}
632
Fred Drake7932ed02000-08-11 17:37:33 +0000633 Python packages\index{packages} --- collections of modules that can
634 be described as a unit --- are documented using the same markup as
635 modules. The name for a module in a package should be typed in
636 ``fully qualified'' form (i.e., it should include the package name).
637 For example, a module ``foo'' in package ``bar'' should be marked as
638 \samp{\e module\{bar.foo\}}, and the beginning of the reference
639 section would appear as:
640
641\begin{verbatim}
642\section{\module{bar.foo} ---
643 Module from the \module{bar} package}
644
645\declaremodule{extension}{bar.foo}
646\modulesynopsis{Nifty module from the \module{bar} package.}
647\moduleauthor{Jane Doe}{jane.doe@frobnitz.org}
648\end{verbatim}
649
650 Note that the name of a package is also marked using
651 \macro{module}.
652
Fred Drakeadade921999-04-22 13:05:27 +0000653 \begin{macrodesc}{declaremodule}{\op{key}\p{type}\p{name}}
Fred Drake87f768e1999-05-17 15:22:45 +0000654 Requires two parameters: module type (\samp{standard},
655 \samp{builtin}, \samp{extension}, or \samp{}), and the module
656 name. An optional parameter should be given as the basis for the
657 module's ``key'' used for linking to or referencing the section.
658 The ``key'' should only be given if the module's name contains any
659 underscores, and should be the name with the underscores stripped.
660 Note that the \var{type} parameter must be one of the values
661 listed above or an error will be printed. For modules which are
662 contained in packages, the fully-qualified name should be given as
663 \var{name} parameter. This should be the first thing after the
664 \macro{section} used to introduce the module.
Fred Drakeacffaee1999-03-16 16:09:13 +0000665 \end{macrodesc}
666
Fred Drakeadade921999-04-22 13:05:27 +0000667 \begin{macrodesc}{platform}{\p{specifier}}
Fred Drakeacffaee1999-03-16 16:09:13 +0000668 Specifies the portability of the module. \var{specifier} is a
669 comma-separated list of keys that specify what platforms the
670 module is available on. The keys are short identifiers;
671 examples that are in use include \samp{IRIX}, \samp{Mac},
672 \samp{Windows}, and \samp{Unix}. It is important to use a key
Fred Drake7a737df1999-04-23 14:41:44 +0000673 which has already been used when applicable. This is used to
674 provide annotations in the Module Index and the HTML and GNU info
675 output.
Fred Drakeacffaee1999-03-16 16:09:13 +0000676 \end{macrodesc}
677
Fred Drakeadade921999-04-22 13:05:27 +0000678 \begin{macrodesc}{modulesynopsis}{\p{text}}
Fred Drakeacffaee1999-03-16 16:09:13 +0000679 The \var{text} is a short, ``one line'' description of the
680 module that can be used as part of the chapter introduction.
Fred Drakeadade921999-04-22 13:05:27 +0000681 This is must be placed after \macro{declaremodule}.
Fred Drakeacffaee1999-03-16 16:09:13 +0000682 The synopsis is used in building the contents of the table
683 inserted as the \macro{localmoduletable}. No text is
684 produced at the point of the markup.
685 \end{macrodesc}
686
Fred Drakeadade921999-04-22 13:05:27 +0000687 \begin{macrodesc}{moduleauthor}{\p{name}\p{email}}
Fred Drakeacffaee1999-03-16 16:09:13 +0000688 This macro is used to encode information about who authored a
689 module. This is currently not used to generate output, but can be
690 used to help determine the origin of the module.
691 \end{macrodesc}
692
693
694 \subsection{Library-level Markup}
695
696 This markup is used when describing a selection of modules. For
Fred Drake698d5201999-11-10 15:54:57 +0000697 example, the \citetitle[../mac/mac.html]{Macintosh Library
698 Modules} document uses this to help provide an overview of the
699 modules in the collection, and many chapters in the
700 \citetitle[../lib/lib.html]{Python Library Reference} use it for
Fred Drakeacffaee1999-03-16 16:09:13 +0000701 the same purpose.
702
703 \begin{macrodesc}{localmoduletable}{}
Fred Drake2c4e0091999-03-29 14:55:55 +0000704 If a \file{.syn} file exists for the current
Fred Drakeacffaee1999-03-16 16:09:13 +0000705 chapter (or for the entire document in \code{howto} documents), a
706 \env{synopsistable} is created with the contents loaded from the
707 \file{.syn} file.
708 \end{macrodesc}
709
710
711 \subsection{Table Markup}
712
713 There are three general-purpose table environments defined which
714 should be used whenever possible. These environments are defined
715 to provide tables of specific widths and some convenience for
716 formatting. These environments are not meant to be general
717 replacements for the standard \LaTeX{} table environments, but can
718 be used for an advantage when the documents are processed using
719 the tools for Python documentation processing. In particular, the
720 generated HTML looks good! There is also an advantage for the
Fred Drake7a737df1999-04-23 14:41:44 +0000721 eventual conversion of the documentation to SGML (see section
Fred Drake2c4e0091999-03-29 14:55:55 +0000722 \ref{futures}, ``Future Directions'').
Fred Drakeacffaee1999-03-16 16:09:13 +0000723
724 Each environment is named \env{table\var{cols}}, where \var{cols}
725 is the number of columns in the table specified in lower-case
726 Roman numerals. Within each of these environments, an additional
727 macro, \macro{line\var{cols}}, is defined, where \var{cols}
728 matches the \var{cols} value of the corresponding table
Fred Drake2c4e0091999-03-29 14:55:55 +0000729 environment. These are supported for \var{cols} values of
730 \code{ii}, \code{iii}, and \code{iv}. These environments are all
731 built on top of the \env{tabular} environment.
Fred Drakeacffaee1999-03-16 16:09:13 +0000732
Fred Drake2b853412000-04-11 19:08:30 +0000733 Note that all tables in the standard Python documentation use
734 vertical lines between columns, and this must be specified in the
735 markup for each table. A general border around the outside of the
736 table is not used, but would be the responsibility of the
737 processor.
738
Fred Drakeadade921999-04-22 13:05:27 +0000739 \begin{envdesc}{tableii}{\p{colspec}\p{col1font}\p{heading1}\p{heading2}}
Fred Drakeacffaee1999-03-16 16:09:13 +0000740 Create a two-column table using the \LaTeX{} column specifier
741 \var{colspec}. The column specifier should indicate vertical
742 bars between columns as appropriate for the specific table, but
743 should not specify vertical bars on the outside of the table
744 (that is considered a stylesheet issue). The \var{col1font}
745 parameter is used as a stylistic treatment of the first column
746 of the table: the first column is presented as
747 \code{\e\var{col1font}\{column1\}}. To avoid treating the first
Fred Drakeadade921999-04-22 13:05:27 +0000748 column specially, \var{col1font} may be \samp{textrm}. The
Fred Drakeacffaee1999-03-16 16:09:13 +0000749 column headings are taken from the values \var{heading1} and
750 \var{heading2}.
751 \end{envdesc}
752
Fred Drakeadade921999-04-22 13:05:27 +0000753 \begin{macrodesc}{lineii}{\p{column1}\p{column2}}
Fred Drakeacffaee1999-03-16 16:09:13 +0000754 Create a single table row within a \env{tableii} environment.
755 The text for the first column will be generated by applying the
756 macro named by the \var{col1font} value when the \env{tableii}
757 was opened.
758 \end{macrodesc}
759
Fred Drakeadade921999-04-22 13:05:27 +0000760 \begin{envdesc}{tableiii}{\p{colspec}\p{col1font}\p{heading1}\p{heading2}\p{heading3}}
Fred Drakeacffaee1999-03-16 16:09:13 +0000761 Like the \env{tableii} environment, but with a third column.
762 The heading for the third column is given by \var{heading3}.
763 \end{envdesc}
764
Fred Drakeadade921999-04-22 13:05:27 +0000765 \begin{macrodesc}{lineiii}{\p{column1}\p{column2}\p{column3}}
Fred Drakeacffaee1999-03-16 16:09:13 +0000766 Like the \macro{lineii} macro, but with a third column. The
767 text for the third column is given by \var{column3}.
768 \end{macrodesc}
769
Fred Drakeadade921999-04-22 13:05:27 +0000770 \begin{envdesc}{tableiv}{\p{colspec}\p{col1font}\p{heading1}\p{heading2}\p{heading3}\p{heading4}}
Fred Drakeacffaee1999-03-16 16:09:13 +0000771 Like the \env{tableiii} environment, but with a fourth column.
772 The heading for the fourth column is given by \var{heading4}.
773 \end{envdesc}
774
Fred Drakeadade921999-04-22 13:05:27 +0000775 \begin{macrodesc}{lineiv}{\p{column1}\p{column2}\p{column3}\p{column4}}
Fred Drakeacffaee1999-03-16 16:09:13 +0000776 Like the \macro{lineiii} macro, but with a fourth column. The
777 text for the fourth column is given by \var{column4}.
778 \end{macrodesc}
779
780
781 An additional table-like environment is \env{synopsistable}. The
782 table generated by this environment contains two columns, and each
783 row is defined by an alternate definition of
Fred Drakee15956b2000-04-03 04:51:13 +0000784 \macro{modulesynopsis}. This environment is not normally used by
785 authors, but is created by the \macro{localmoduletable} macro.
Fred Drakeacffaee1999-03-16 16:09:13 +0000786
787
788 \subsection{Reference List Markup \label{references}}
789
790 Many sections include a list of references to module documentation
791 or external documents. These lists are created using the
792 \env{seealso} environment. This environment defines some
793 additional macros to support creating reference entries in a
794 reasonable manner.
795
Fred Drake5802e482000-07-06 05:24:41 +0000796 The \env{seealso} environment is typically placed in a section
797 just before any sub-sections. This is done to ensure that
798 reference links related to the section are not hidden in a
799 subsection in the hypertext renditions of the documentation.
800
Fred Drakeacffaee1999-03-16 16:09:13 +0000801 \begin{envdesc}{seealso}{}
802 This environment creates a ``See also:'' heading and defines the
803 markup used to describe individual references.
804 \end{envdesc}
805
Fred Drake48449982000-09-12 17:52:33 +0000806 For each of the following macros, \var{why} should be one or more
807 complete sentences, starting with a capital letter (unless it
808 starts with an identifier, which should not be modified), and
809 ending with the apropriate punctuation.
Fred Drake5802e482000-07-06 05:24:41 +0000810
Fred Drakeadade921999-04-22 13:05:27 +0000811 \begin{macrodesc}{seemodule}{\op{key}\p{name}\p{why}}
Fred Drakeacffaee1999-03-16 16:09:13 +0000812 Refer to another module. \var{why} should be a brief
813 explanation of why the reference may be interesting. The module
814 name is given in \var{name}, with the link key given in
815 \var{key} if necessary. In the HTML and PDF conversions, the
816 module name will be a hyperlink to the referred-to module.
Fred Drakeadade921999-04-22 13:05:27 +0000817 \strong{Note:} The module must be documented in the same
818 document (the corresponding \macro{declaremodule} is required).
Fred Drakeacffaee1999-03-16 16:09:13 +0000819 \end{macrodesc}
820
Fred Drake08c5d0c2000-09-11 05:22:30 +0000821 \begin{macrodesc}{seepep}{\p{number}\p{title}\p{why}}
822 Refer to an Python Enhancement Proposal (PEP). \var{number}
823 should be the official number assigned by the PEP Editor,
824 \var{title} should be the human-readable title of the PEP as
Fred Drake5802e482000-07-06 05:24:41 +0000825 found in the official copy of the document, and \var{why} should
Fred Drake08c5d0c2000-09-11 05:22:30 +0000826 explain what's interesting about the PEP. This should be used
827 to refer the reader to PEPs which specify interfaces or language
828 features relevant to the material in the annotated section of the
829 documentation.
830 \end{macrodesc}
831
832 \begin{macrodesc}{seerfc}{\p{number}\p{title}\p{why}}
833 Refer to an IETF Request for Comments (RFC). Otherwise very
834 similar to \macro{seepep}. This should be used
835 to refer the reader to PEPs which specify protocols or data
Fred Drake5802e482000-07-06 05:24:41 +0000836 formats relevant to the material in the annotated section of the
837 documentation.
838 \end{macrodesc}
839
Fred Drakeadade921999-04-22 13:05:27 +0000840 \begin{macrodesc}{seetext}{\p{text}}
Fred Drakeacffaee1999-03-16 16:09:13 +0000841 Add arbitrary text \var{text} to the ``See also:'' list. This
842 can be used to refer to off-line materials or on-line materials
Fred Drake5802e482000-07-06 05:24:41 +0000843 using the \macro{url} macro. This should consist of one or more
844 complete sentences.
845 \end{macrodesc}
846
Fred Drake48449982000-09-12 17:52:33 +0000847 \begin{macrodesc}{seetitle}{\op{url}\p{title}\p{why}}
848 Add a reference to an external document named \var{title}. If
849 \var{url} is given, the title is made a hyperlink in the HTML
850 version of the documentation, and displayed below the title in
851 the typeset versions of the documentation.
852 \end{macrodesc}
853
Fred Drake5802e482000-07-06 05:24:41 +0000854 \begin{macrodesc}{seeurl}{\p{url}\p{why}}
855 References to specific on-line resources should be given using
856 the \macro{seeurl} macro. No title is associated with the
857 reference, but the \var{why} text may include a title marked
858 using the \macro{citetitle} macro.
Fred Drakeacffaee1999-03-16 16:09:13 +0000859 \end{macrodesc}
860
861
862 \subsection{Index-generating Markup \label{indexing}}
863
864 Effective index generation for technical documents can be very
Fred Drakee15956b2000-04-03 04:51:13 +0000865 difficult, especially for someone familiar with the topic but not
Fred Drakeacffaee1999-03-16 16:09:13 +0000866 the creation of indexes. Much of the difficulty arises in the
867 area of terminology: including the terms an expert would use for a
868 concept is not sufficient. Coming up with the terms that a novice
Fred Drake2c4e0091999-03-29 14:55:55 +0000869 would look up is fairly difficult for an author who, typically, is
Fred Drakeacffaee1999-03-16 16:09:13 +0000870 an expert in the area she is writing on.
871
Fred Drake2c4e0091999-03-29 14:55:55 +0000872 The truly difficult aspects of index generation are not areas with
873 which the documentation tools can help. However, ease
Fred Drakee15956b2000-04-03 04:51:13 +0000874 of producing the index once content decisions are made is within
Fred Drakeacffaee1999-03-16 16:09:13 +0000875 the scope of the tools. Markup is provided which the processing
876 software is able to use to generate a variety of kinds of index
877 entry with minimal effort. Additionally, many of the environments
Fred Drake7a737df1999-04-23 14:41:44 +0000878 described in section \ref{info-units}, ``Information Units,'' will
Fred Drakeacffaee1999-03-16 16:09:13 +0000879 generate appropriate entries into the general and module indexes.
880
881 The following macro can be used to control the generation of index
Fred Drakeadade921999-04-22 13:05:27 +0000882 data, and should be used in the document preamble:
Fred Drakeacffaee1999-03-16 16:09:13 +0000883
884 \begin{macrodesc}{makemodindex}{}
Fred Drakeadade921999-04-22 13:05:27 +0000885 This should be used in the document preamble if a ``Module
Fred Drakeacffaee1999-03-16 16:09:13 +0000886 Index'' is desired for a document containing reference material
887 on many modules. This causes a data file
Fred Draked1fb7791999-05-17 16:33:54 +0000888 \code{lib\var{jobname}.idx} to be created from the
Fred Drakeacffaee1999-03-16 16:09:13 +0000889 \macro{declaremodule} macros. This file can be processed by the
890 \program{makeindex} program to generate a file which can be
891 \macro{input} into the document at the desired location of the
892 module index.
893 \end{macrodesc}
894
895 There are a number of macros that are useful for adding index
896 entries for particular concepts, many of which are specific to
897 programming languages or even Python.
898
Fred Drakeadade921999-04-22 13:05:27 +0000899 \begin{macrodesc}{bifuncindex}{\p{name}}
Fred Drakeec8b9051999-04-23 20:01:17 +0000900 Add an index entry referring to a built-in function named
901 \var{name}; parentheses should not be included after
Fred Drake2c4e0091999-03-29 14:55:55 +0000902 \var{name}.
Fred Drakeacffaee1999-03-16 16:09:13 +0000903 \end{macrodesc}
904
Fred Drakeadade921999-04-22 13:05:27 +0000905 \begin{macrodesc}{exindex}{\p{exception}}
Fred Drake2c4e0091999-03-29 14:55:55 +0000906 Add a reference to an exception named \var{exception}. The
907 exception may be either string- or class-based.
Fred Drakeacffaee1999-03-16 16:09:13 +0000908 \end{macrodesc}
909
Fred Drakeadade921999-04-22 13:05:27 +0000910 \begin{macrodesc}{kwindex}{\p{keyword}}
Fred Drake2c4e0091999-03-29 14:55:55 +0000911 Add a reference to a language keyword (not a keyword parameter
912 in a function or method call).
Fred Drakeacffaee1999-03-16 16:09:13 +0000913 \end{macrodesc}
914
Fred Drakeadade921999-04-22 13:05:27 +0000915 \begin{macrodesc}{obindex}{\p{object type}}
Fred Drake2c4e0091999-03-29 14:55:55 +0000916 Add an index entry for a built-in object type.
Fred Drakeacffaee1999-03-16 16:09:13 +0000917 \end{macrodesc}
918
Fred Drakeadade921999-04-22 13:05:27 +0000919 \begin{macrodesc}{opindex}{\p{operator}}
Fred Drake2c4e0091999-03-29 14:55:55 +0000920 Add a reference to an operator, such as \samp{+}.
Fred Drakeacffaee1999-03-16 16:09:13 +0000921 \end{macrodesc}
922
Fred Drakeadade921999-04-22 13:05:27 +0000923 \begin{macrodesc}{refmodindex}{\op{key}\p{module}}
Fred Drakeacffaee1999-03-16 16:09:13 +0000924 Add an index entry for module \var{module}; if \var{module}
925 contains an underscore, the optional parameter \var{key} should
926 be provided as the same string with underscores removed. An
927 index entry ``\var{module} (module)'' will be generated. This
928 is intended for use with non-standard modules implemented in
929 Python.
930 \end{macrodesc}
931
Fred Drakeadade921999-04-22 13:05:27 +0000932 \begin{macrodesc}{refexmodindex}{\op{key}\p{module}}
Fred Drakeacffaee1999-03-16 16:09:13 +0000933 As for \macro{refmodindex}, but the index entry will be
934 ``\var{module} (extension module).'' This is intended for use
935 with non-standard modules not implemented in Python.
936 \end{macrodesc}
937
Fred Drakeadade921999-04-22 13:05:27 +0000938 \begin{macrodesc}{refbimodindex}{\op{key}\p{module}}
Fred Drakeacffaee1999-03-16 16:09:13 +0000939 As for \macro{refmodindex}, but the index entry will be
940 ``\var{module} (built-in module).'' This is intended for use
941 with standard modules not implemented in Python.
942 \end{macrodesc}
943
Fred Drakeadade921999-04-22 13:05:27 +0000944 \begin{macrodesc}{refstmodindex}{\op{key}\p{module}}
Fred Drakeacffaee1999-03-16 16:09:13 +0000945 As for \macro{refmodindex}, but the index entry will be
946 ``\var{module} (standard module).'' This is intended for use
947 with standard modules implemented in Python.
948 \end{macrodesc}
949
Fred Drakeadade921999-04-22 13:05:27 +0000950 \begin{macrodesc}{stindex}{\p{statement}}
Fred Drake2c4e0091999-03-29 14:55:55 +0000951 Add an index entry for a statement type, such as \keyword{print}
Fred Drakeadade921999-04-22 13:05:27 +0000952 or \keyword{try}/\keyword{finally}.
953
954 XXX Need better examples of difference from \macro{kwindex}.
Fred Drakeacffaee1999-03-16 16:09:13 +0000955 \end{macrodesc}
956
957
958 Additional macros are provided which are useful for conveniently
959 creating general index entries which should appear at many places
960 in the index by rotating a list of words. These are simple macros
961 that simply use \macro{index} to build some number of index
962 entries. Index entries build using these macros contain both
963 primary and secondary text.
964
Fred Drakeadade921999-04-22 13:05:27 +0000965 \begin{macrodesc}{indexii}{\p{word1}\p{word2}}
Fred Drakeacffaee1999-03-16 16:09:13 +0000966 Build two index entries. This is exactly equivalent to using
967 \code{\e index\{\var{word1}!\var{word2}\}} and
968 \code{\e index\{\var{word2}!\var{word1}\}}.
969 \end{macrodesc}
970
Fred Drakeadade921999-04-22 13:05:27 +0000971 \begin{macrodesc}{indexiii}{\p{word1}\p{word2}\p{word3}}
Fred Drakeacffaee1999-03-16 16:09:13 +0000972 Build three index entries. This is exactly equivalent to using
973 \code{\e index\{\var{word1}!\var{word2} \var{word3}\}},
974 \code{\e index\{\var{word2}!\var{word3}, \var{word1}\}}, and
975 \code{\e index\{\var{word3}!\var{word1} \var{word2}\}}.
976 \end{macrodesc}
977
Fred Drakeadade921999-04-22 13:05:27 +0000978 \begin{macrodesc}{indexiv}{\p{word1}\p{word2}\p{word3}\p{word4}}
Fred Drakeacffaee1999-03-16 16:09:13 +0000979 Build four index entries. This is exactly equivalent to using
980 \code{\e index\{\var{word1}!\var{word2} \var{word3} \var{word4}\}},
981 \code{\e index\{\var{word2}!\var{word3} \var{word4}, \var{word1}\}},
982 \code{\e index\{\var{word3}!\var{word4}, \var{word1} \var{word2}\}},
983 and
984 \code{\e index\{\var{word4}!\var{word1} \var{word2} \var{word3}\}}.
985 \end{macrodesc}
986
987
988\section{Special Names}
989
990 Many special names are used in the Python documentation, including
991 the names of operating systems, programming languages, standards
992 bodies, and the like. Many of these were assigned \LaTeX{} macros
993 at some point in the distant past, and these macros lived on long
994 past their usefulness. In the current markup, these entities are
995 not assigned any special markup, but the preferred spellings are
996 given here to aid authors in maintaining the consistency of
997 presentation in the Python documentation.
998
999 \begin{description}
1000 \item[POSIX]
1001 The name assigned to a particular group of standards. This is
1002 always uppercase.
1003
1004 \item[Python]
1005 The name of our favorite programming language is always
1006 capitalized.
Fred Drake42934682000-04-03 15:00:28 +00001007
1008 \item[Unicode]
1009 The name of a character set and matching encoding. This is
1010 always written capitalized.
Fred Drakeacffaee1999-03-16 16:09:13 +00001011 \end{description}
1012
1013
1014\section{Processing Tools}
1015
1016 \subsection{External Tools}
1017
1018 Many tools are needed to be able to process the Python
1019 documentation if all supported formats are required. This
Fred Drakeadade921999-04-22 13:05:27 +00001020 section lists the tools used and when each is required. Consult
1021 the \file{Doc/README} file to see if there are specific version
1022 requirements for any of these.
Fred Drakeacffaee1999-03-16 16:09:13 +00001023
1024 \begin{description}
1025 \item[\program{dvips}]
1026 This program is a typical part of \TeX{} installations. It is
1027 used to generate PostScript from the ``device independent''
Fred Drake2c4e0091999-03-29 14:55:55 +00001028 \file{.dvi} files. It is needed for the conversion to
Fred Drakeacffaee1999-03-16 16:09:13 +00001029 PostScript.
1030
1031 \item[\program{emacs}]
1032 Emacs is the kitchen sink of programmers' editors, and a damn
1033 fine kitchen sink it is. It also comes with some of the
1034 processing needed to support the proper menu structures for
1035 Texinfo documents when an info conversion is desired. This is
Fred Drake2c4e0091999-03-29 14:55:55 +00001036 needed for the info conversion. Using \program{xemacs}
Fred Drakeacffaee1999-03-16 16:09:13 +00001037 instead of FSF \program{emacs} may lead to instability in the
1038 conversion, but that's because nobody seems to maintain the
1039 Emacs Texinfo code in a portable manner.
1040
1041 \item[\program{latex}]
1042 This is a world-class typesetter by Donald Knuth. It is used
1043 for the conversion to PostScript, and is needed for the HTML
1044 conversion as well (\LaTeX2HTML requires one of the
1045 intermediate files it creates).
1046
1047 \item[\program{latex2html}]
1048 Probably the longest Perl script anyone ever attempted to
1049 maintain. This converts \LaTeX{} documents to HTML documents,
1050 and does a pretty reasonable job. It is required for the
1051 conversions to HTML and GNU info.
1052
1053 \item[\program{lynx}]
1054 This is a text-mode Web browser which includes an
1055 HTML-to-plain text conversion. This is used to convert
1056 \code{howto} documents to text.
1057
1058 \item[\program{make}]
1059 Just about any version should work for the standard documents,
1060 but GNU \program{make} is required for the experimental
1061 processes in \file{Doc/tools/sgmlconv/}, at least while
1062 they're experimental.
1063
1064 \item[\program{makeindex}]
1065 This is a standard program for converting \LaTeX{} index data
1066 to a formatted index; it should be included with all \LaTeX{}
1067 installations. It is needed for the PDF and PostScript
1068 conversions.
1069
1070 \item[\program{makeinfo}]
1071 GNU \program{makeinfo} is used to convert Texinfo documents to
1072 GNU info files. Since Texinfo is used as an intermediate
1073 format in the info conversion, this program is needed in that
1074 conversion.
1075
1076 \item[\program{pdflatex}]
1077 pdf\TeX{} is a relatively new variant of \TeX, and is used to
1078 generate the PDF version of the manuals. It is typically
1079 installed as part of most of the large \TeX{} distributions.
Fred Drake7a737df1999-04-23 14:41:44 +00001080 \program{pdflatex} is pdf\TeX{} using the \LaTeX{} format.
Fred Drakeacffaee1999-03-16 16:09:13 +00001081
1082 \item[\program{perl}]
1083 Perl is required for \LaTeX2HTML{} and one of the scripts used
1084 to post-process \LaTeX2HTML output, as well as the
Fred Drake2c4e0091999-03-29 14:55:55 +00001085 HTML-to-Texinfo conversion. This is required for
Fred Drakeacffaee1999-03-16 16:09:13 +00001086 the HTML and GNU info conversions.
1087
1088 \item[\program{python}]
1089 Python is used for many of the scripts in the
1090 \file{Doc/tools/} directory; it is required for all
1091 conversions. This shouldn't be a problem if you're interested
1092 in writing documentation for Python!
1093 \end{description}
1094
1095
1096 \subsection{Internal Tools}
1097
1098 This section describes the various scripts that are used to
1099 implement various stages of document processing or to orchestrate
Fred Drake2c4e0091999-03-29 14:55:55 +00001100 entire build sequences. Most of these tools are only useful
Fred Drakeacffaee1999-03-16 16:09:13 +00001101 in the context of building the standard documentation, but some
1102 are more general.
1103
1104 \begin{description}
1105 \item[\program{mkhowto}]
Fred Drake87f768e1999-05-17 15:22:45 +00001106 This is the primary script used to format third-party
1107 documents. It contains all the logic needed to ``get it
1108 right.'' The proper way to use this script is to make a
1109 symbolic link to it or run it in place; the actual script file
1110 must be stored as part of the documentation source tree,
1111 though it may be used to format documents outside the
Fred Drakece444982000-04-11 18:52:52 +00001112 tree. Use \program{mkhowto} \longprogramopt{help}
Fred Draked290c101999-11-09 18:03:00 +00001113 for a list of
Fred Draked2a727f1999-05-27 21:45:54 +00001114 command line options.
Fred Drake87f768e1999-05-17 15:22:45 +00001115
Fred Draked1fb7791999-05-17 16:33:54 +00001116 \program{mkhowto} can be used for both \code{howto} and
1117 \code{manual} class documents. (For the later, be sure to get
1118 the latest version from the Python CVS repository rather than
1119 the version distributed in the \file{latex-1.5.2.tgz} source
1120 archive.)
1121
Fred Drake87f768e1999-05-17 15:22:45 +00001122 XXX Need more here.
Fred Drakeacffaee1999-03-16 16:09:13 +00001123 \end{description}
1124
1125
1126\section{Future Directions \label{futures}}
1127
1128 The history of the Python documentation is full of changes, most of
1129 which have been fairly small and evolutionary. There has been a
1130 great deal of discussion about making large changes in the markup
1131 languages and tools used to process the documentation. This section
1132 deals with the nature of the changes and what appears to be the most
1133 likely path of future development.
1134
1135 \subsection{Structured Documentation \label{structured}}
1136
1137 Most of the small changes to the \LaTeX{} markup have been made
1138 with an eye to divorcing the markup from the presentation, making
1139 both a bit more maintainable. Over the course of 1998, a large
1140 number of changes were made with exactly this in mind; previously,
1141 changes had been made but in a less systematic manner and with
1142 more concern for not needing to update the existing content. The
1143 result has been a highly structured and semantically loaded markup
1144 language implemented in \LaTeX. With almost no basic \TeX{} or
1145 \LaTeX{} markup in use, however, the markup syntax is about the
1146 only evidence of \LaTeX{} in the actual document sources.
1147
1148 One side effect of this is that while we've been able to use
1149 standard ``engines'' for manipulating the documents, such as
1150 \LaTeX{} and \LaTeX2HTML, most of the actual transformations have
Fred Drake7a737df1999-04-23 14:41:44 +00001151 been created specifically for Python. The \LaTeX{} document
1152 classes and \LaTeX2HTML support are both complete implementations
1153 of the specific markup designed for these documents.
Fred Drakeacffaee1999-03-16 16:09:13 +00001154
1155 Combining highly customized markup with the somewhat esoteric
1156 systems used to process the documents leads us to ask some
1157 questions: Can we do this more easily? and, Can we do this
1158 better? After a great deal of discussion with the community, we
1159 have determined that actively pursuing modern structured
Fred Drake2c4e0091999-03-29 14:55:55 +00001160 documentation systems is worth some investment of time.
Fred Drakeacffaee1999-03-16 16:09:13 +00001161
1162 There appear to be two real contenders in this arena: the Standard
1163 General Markup Language (SGML), and the Extensible Markup Language
1164 (XML). Both of these standards have advantages and disadvantages,
1165 and many advantages are shared.
1166
1167 SGML offers advantages which may appeal most to authors,
1168 especially those using ordinary text editors. There are also
1169 additional abilities to define content models. A number of
1170 high-quality tools with demonstrated maturity is available, but
1171 most are not free; for those which are, portability issues remain
1172 a problem.
1173
1174 The advantages of XML include the availability of a large number
1175 of evolving tools. Unfortunately, many of the associated
1176 standards are still evolving, and the tools will have to follow
1177 along. This means that developing a robust tool set that uses
1178 more than the basic XML 1.0 recommendation is not possible in the
1179 short term. The promised availability of a wide variety of
1180 high-quality tools which support some of the most important
1181 related standards is not immediate. Many tools are likely to be
1182 free.
1183
Fred Drakeadade921999-04-22 13:05:27 +00001184 XXX Eventual migration to SGML/XML.
Fred Drakeacffaee1999-03-16 16:09:13 +00001185
1186 \subsection{Discussion Forums \label{discussion}}
1187
1188 Discussion of the future of the Python documentation and related
Fred Drake7a737df1999-04-23 14:41:44 +00001189 topics takes place in the Documentation Special Interest Group, or
1190 ``Doc-SIG.'' Information on the group, including mailing list
1191 archives and subscription information, is available at
Fred Drakeacffaee1999-03-16 16:09:13 +00001192 \url{http://www.python.org/sigs/doc-sig/}. The SIG is open to all
1193 interested parties.
1194
1195 Comments and bug reports on the standard documents should be sent
1196 to \email{python-docs@python.org}. This may include comments
Fred Drakeadade921999-04-22 13:05:27 +00001197 about formatting, content, grammatical and spelling errors, or
Fred Draked1fb7791999-05-17 16:33:54 +00001198 this document. You can also send comments on this document
1199 directly to the author at \email{fdrake@acm.org}.
Fred Drakeacffaee1999-03-16 16:09:13 +00001200
1201\end{document}