diff --git a/Doc/lib.tex b/Doc/lib.tex index 07f70cf1a5f..873e8fb5961 100644 --- a/Doc/lib.tex +++ b/Doc/lib.tex @@ -1,5 +1,9 @@ \documentstyle[twoside,11pt,myformat]{report} +% NOTE: this file controls which chapters/sections of the library +% manual are actually printed. It is easy to customize your manual +% by commenting out sections that you're not interested in. + \title{Python Library Reference} \input{boilerplate} @@ -112,7 +116,7 @@ language. %\input{libamoeba} % AMOEBA ONLY -%\input{libmac} % MACINTOSH ONLY +\input{libmac} % MACINTOSH ONLY \input{libstdwin} % STDWIN ONLY diff --git a/Doc/lib/lib.tex b/Doc/lib/lib.tex index 07f70cf1a5f..873e8fb5961 100644 --- a/Doc/lib/lib.tex +++ b/Doc/lib/lib.tex @@ -1,5 +1,9 @@ \documentstyle[twoside,11pt,myformat]{report} +% NOTE: this file controls which chapters/sections of the library +% manual are actually printed. It is easy to customize your manual +% by commenting out sections that you're not interested in. + \title{Python Library Reference} \input{boilerplate} @@ -112,7 +116,7 @@ language. %\input{libamoeba} % AMOEBA ONLY -%\input{libmac} % MACINTOSH ONLY +\input{libmac} % MACINTOSH ONLY \input{libstdwin} % STDWIN ONLY diff --git a/Doc/lib/libcgi.tex b/Doc/lib/libcgi.tex index 9d2764470c1..a5d1cdf42ee 100644 --- a/Doc/lib/libcgi.tex +++ b/Doc/lib/libcgi.tex @@ -6,6 +6,8 @@ \indexii{MIME}{headers} \index{URL} +\renewcommand{\indexsubitem}{(in module cgi)} + This module makes it easy to write Python scripts that run in a WWW server using the Common Gateway Interface. It was written by Michael McLay and subsequently modified by Steve Majewski and Guido van @@ -113,7 +115,7 @@ if it is unique, or raise \code{IndexError} if the field was specified more than once in the form. (If the field wasn't specified at all, \code{KeyError} is raised.) To access fields that are specified multiple times, use \code{form.getlist(fieldname)}. The -\code{values()} and \code{items()} methods return mixed lists -- +\code{values()} and \code{items()} methods return mixed lists --- containing strings for singly-defined fields, and lists of strings for multiply-defined fields. \end{funcdesc} diff --git a/Doc/lib/libftplib.tex b/Doc/lib/libftplib.tex index 105ccdfa77b..acd8784afa3 100644 --- a/Doc/lib/libftplib.tex +++ b/Doc/lib/libftplib.tex @@ -1,3 +1,6 @@ \section{Built-in module \sectcode{ftplib}} \stmodindex{ftplib} + +\renewcommand{\indexsubitem}{(in module ftplib)} + To be provided. diff --git a/Doc/lib/libfuncs.tex b/Doc/lib/libfuncs.tex index ed2427b7e72..91a9ec9e111 100644 --- a/Doc/lib/libfuncs.tex +++ b/Doc/lib/libfuncs.tex @@ -120,7 +120,7 @@ exactly one argument.) This function is similar to the \code{eval()} function or the \code{exec} statement, but parses a file instead of a string. It is different from the \code{import} statement in that it does not use - the module administration -- it reads the file unconditionally and + the module administration --- it reads the file unconditionally and does not create a new module. The arguments are a file name and two optional dictionaries. The diff --git a/Doc/lib/libgopherlib.tex b/Doc/lib/libgopherlib.tex index 9b81e37756b..904a64b96f5 100644 --- a/Doc/lib/libgopherlib.tex +++ b/Doc/lib/libgopherlib.tex @@ -1,3 +1,6 @@ \section{Built-in module \sectcode{gopherlib}} \stmodindex{gopherlib} + +\renewcommand{\indexsubitem}{(in module gopherlib)} + To be provided. diff --git a/Doc/lib/libhtmllib.tex b/Doc/lib/libhtmllib.tex index 9ea10eebc52..e19277461a8 100644 --- a/Doc/lib/libhtmllib.tex +++ b/Doc/lib/libhtmllib.tex @@ -1,3 +1,271 @@ \section{Built-in module \sectcode{htmllib}} \stmodindex{htmllib} -To be provided. +\index{HTML} +\index{hypertext} + +\renewcommand{\indexsubitem}{(in module htmllib)} + +This module defines a number of classes which can serve as a basis for +parsing text files formatted in HTML (HyperText Mark-up Language). +The classes are not directly concerned with I/O --- the have to be fed +their input in string form, and will make calls to methods of a +``formatter'' object in order to produce output. The classes are +designed to be used as base classes for other classes in order to add +functionality, and allow most of their methods to be extended or +overridden. In turn, the classes are derived from and extend the +class \code{SGMLParser} defined in module \code{sgmllib}. +\index{SGML} +\stmodindex{sgmllib} +\ttindex{SGMLParser} +\index{formatter} + +The following is a summary of the interface defined by +\code{sgmllib.SGMLParser}: + +\begin{itemize} + +\item +The interface to feed data to an instance is through the \code{feed()} +method, which takes a string argument. This can be called with as +little or as much text at a time. When the data contains complete +HTML elements, these are processed immediately; incomplete elements +are saved in a buffer. To force processing of all unprocessed data, +call the \code{close()} method. + +Example: to parse the entire contents of a file, do +\code{parser.feed(open(file).read()); parser.close()}. + +\item +The interface to define semantics for HTML tags is very simple: derive +a class and define methods called \code{start_\var{tag}()}, +\code{end_\var{tag}()}, or \code{do_\var{tag}()}. The parser will +call these at appropriate moments: \code{start_\var{tag}} or +\code{do_\var{tag}} is called when an opening tag of the form +\code{<\var{tag} ...>} is encountered; \code{end_\var{tag}} is called +when a closing tag of the form \code{<\var{tag}>} is encountered. If +an opening tag requires a corresponding closing tag, like \code{
}, the class +should define the \code{do_\var{tag}} method. + +\end{itemize} + +The module defines the following classes: + +\begin{funcdesc}{HTMLParser}{} +This is the most basic HTML parser class. It defines one additional +entity name over the names defined by the \code{SGMLParser} base +class, \code{\•}. It also defines handlers for the following +tags: \code{
...} and similar tag pairs). +\end{datadesc} + +Although no documented implementation of a formatter exists, the +\code{FormattingParser} class assumes that formatters have a +certain interface. This interface requires the following methods: +\index{formatter} + +\begin{funcdesc}{setfont}{fontspec} +Set the font to be used subsequently. The \var{fontspec} argument is +an item in a style sheet's font set. +\end{funcdesc} + +\begin{funcdesc}{flush}{} +Finish the current line, if not empty, and begin a new one. +\end{funcdesc} + +\begin{funcdesc}{setleftindent}{n} +Set the left indentation of the following lines to \var{n} units. +\end{funcdesc} + +\begin{funcdesc}{needvspace}{n} +Require at least \var{n} blank lines before the next line. Implies +\code{flush()}. +\end{funcdesc} + +\begin{funcdesc}{addword}{word\, space} +Add a var{word} to the current paragraph, followed by \var{space} +spaces. +\end{funcdesc} + +\begin{datadesc}{nospace} +If this instance variable is true, empty words are ignored by +\code{addword}. It is set to false after a non-empty word has been +added. +\end{datadesc} + +\begin{funcdesc}{setjust}{justification} +Set the justification of the current paragraph. The +\var{justification} can be \code{'c'} (center), \code{'l'} (left +justified), \code{'r'} (right justified) or \code{'lr'} (left and +right justified). +\end{funcdesc} + +\begin{funcdesc}{bgn_anchor}{id} +Begin an anchor. The \var{id} parameter is the value of the parser's +\code{inanchor} attribute. +\end{funcdesc} + +\begin{funcdesc}{end_anchor}{id} +End an anchor. The \var{id} parameter is the value of the parser's +\code{inanchor} attribute. +\end{funcdesc} + +A sample formatters implementation can be found in the module +\code{fmt}, which in turn uses the module \code{Para}. These are +currently not intended as a +\ttindex{fmt} +\ttindex{Para} diff --git a/Doc/lib/libhttplib.tex b/Doc/lib/libhttplib.tex index a284faa1faf..e36bba45a56 100644 --- a/Doc/lib/libhttplib.tex +++ b/Doc/lib/libhttplib.tex @@ -2,6 +2,8 @@ \stmodindex{httplib} \index{HTTP} +\renewcommand{\indexsubitem}{(in module httplib)} + This module defines a class which implements the client side of the HTTP protocol. It is normally not used directly --- the module \code{urlllib} module uses it to handle URLs that use HTTP. diff --git a/Doc/lib/libimp.tex b/Doc/lib/libimp.tex index 1a313fa164b..befde619b14 100644 --- a/Doc/lib/libimp.tex +++ b/Doc/lib/libimp.tex @@ -38,7 +38,7 @@ returned by \code{get_suffixes} describing the kind of file found. \begin{funcdesc}{init_builtin}{name} Initialize the built-in module called \var{name} and return its module object. If the module was already initialized, it will be initialized -{\em again}. A few modules cannot be initialized twice -- attempting +{\em again}. A few modules cannot be initialized twice --- attempting to initialize these again will raise an exception. If there is no built-in module called \var{name}, \code{None} is returned. \end{funcdesc} @@ -73,7 +73,7 @@ it will be initialized {\em again}. The \var{name} argument is used to create or access a module object. The \var{pathname} argument points to the byte-compiled code file. The optional \var{file} argument is the byte-compiled code file, open for reading in binary -mode, from the beginning -- if not given, the function opens +mode, from the beginning --- if not given, the function opens \var{pathname}. It must currently be a real file object, not a user-defined class emulating a file. \end{funcdesc} @@ -97,7 +97,7 @@ return its module object. If the module was already initialized, it will be initialized {\em again}. The \var{name} argument is used to create or access a module object. The \var{pathname} argument points to the source file. The optional \var{file} argument is the source -file, open for reading as text, from the beginning -- if not given, +file, open for reading as text, from the beginning --- if not given, the function opens \var{pathname}. It must currently be a real file object, not a user-defined class emulating a file. Note that if a properly matching byte-compiled file (with suffix \code{.pyc}) exists, diff --git a/Doc/lib/libmimetools.tex b/Doc/lib/libmimetools.tex index c32224b3170..0d1a81b8b41 100644 --- a/Doc/lib/libmimetools.tex +++ b/Doc/lib/libmimetools.tex @@ -1,3 +1,6 @@ \section{Built-in module \sectcode{mimetools}} \stmodindex{mimetools} + +\renewcommand{\indexsubitem}{(in module mimetools)} + To be provided. diff --git a/Doc/lib/libnntplib.tex b/Doc/lib/libnntplib.tex index 93e7ed10372..6aac67139a9 100644 --- a/Doc/lib/libnntplib.tex +++ b/Doc/lib/libnntplib.tex @@ -1,3 +1,6 @@ \section{Built-in module \sectcode{nntplib}} \stmodindex{nntplib} + +\renewcommand{\indexsubitem}{(in module nntplib)} + To be provided. diff --git a/Doc/lib/librfc822.tex b/Doc/lib/librfc822.tex index 43a5ceae6f1..641ea85e34b 100644 --- a/Doc/lib/librfc822.tex +++ b/Doc/lib/librfc822.tex @@ -1,6 +1,8 @@ \section{Built-in module \sectcode{rfc822}} \stmodindex{rfc822} +\renewcommand{\indexsubitem}{(in module rfc822)} + This module defines a class, \code{Message}, which represents a collection of ``email headers'' as defined by the Internet standard RFC 822. It is used in various contexts, usually to read such headers diff --git a/Doc/lib/libsgmllib.tex b/Doc/lib/libsgmllib.tex index 03d9ba262f8..29e26c2f157 100644 --- a/Doc/lib/libsgmllib.tex +++ b/Doc/lib/libsgmllib.tex @@ -1,3 +1,148 @@ \section{Built-in module \sectcode{sgmllib}} \stmodindex{sgmllib} -To be provided. +\index{SGML} + +\renewcommand{\indexsubitem}{(in module sgmllib)} + +This module defines a class \code{SGMLParser} which serves as the +basis for parsing text files formatted in SGML (Standard Generalized +Mark-up Language). In fact, it does not provide a full SGML parser +--- it only parses SGML insofar as it is used by HTML, and module only +exists as a basis for the \code{htmllib} module. +\stmodindex{htmllib} + +In particular, the parser is hardcoded to recognize the following +elements: + +\begin{itemize} + +\item +Opening and closing tags of the form +``\code{<\var{tag} \var{attr}="\var{value}" ...>}'' and +``\code{\var{tag}>}'', respectively. + +\item +Character references of the form ``\code{\&\#\var{name};}''. + +\item +Entity references of the form ``\code{\&\var{name};}''. + +\item +SGML comments of the form ``\code{