67 lines · 3.0 KB · TeX
RawDownload
\section{\module{pydoc} ---         Documentation generator and online help system} \declaremodule{standard}{pydoc}\modulesynopsis{Documentation generator and online help system.}\moduleauthor{Ka-Ping Yee}{ping@lfw.org}\sectionauthor{Ka-Ping Yee}{ping@lfw.org} \versionadded{2.1}\index{documentation!generation}\index{documentation!online}\index{help!online} The \module{pydoc} module automatically generates documentation fromPython modules.  The documentation can be presented as pages of texton the console, served to a Web browser, or saved to HTML files. The built-in function \function{help()} invokes the online help systemin the interactive interpreter, which uses \module{pydoc} to generateits documentation as text on the console.  The same text documentationcan also be viewed from outside the Python interpreter by running\program{pydoc} as a script at the operating system's command prompt.For example, running \begin{verbatim}pydoc sys\end{verbatim} at a shell prompt will display documentation on the \refmodule{sys}module, in a style similar to the manual pages shown by the \UNIX{}\program{man} command.  The argument to \program{pydoc} can be the nameof a function, module, or package, or a dotted reference to a class,method, or function within a module or module in a package.  If theargument to \program{pydoc} looks like a path (that is, it contains thepath separator for your operating system, such as a slash in \UNIX),and refers to an existing Python source file, then documentation isproduced for that file. Specifying a \programopt{-w} flag before the argument will cause HTMLdocumentation to be written out to a file in the current directory,instead of displaying text on the console. Specifying a \programopt{-k} flag before the argument will search thesynopsis lines of all available modules for the keyword given as theargument, again in a manner similar to the \UNIX{} \program{man}command.  The synopsis line of a module is the first line of itsdocumentation string. You can also use \program{pydoc} to start an HTTP server on the localmachine that will serve documentation to visiting Web browsers.\program{pydoc} \programopt{-p 1234} will start a HTTP server on port1234, allowing you to browse the documentation at\code{http://localhost:1234/} in your preferred Web browser.\program{pydoc} \programopt{-g} will start the server and additionallybring up a small \refmodule{Tkinter}-based graphical interface to helpyou search for documentation pages. When \program{pydoc} generates documentation, it uses the currentenvironment and path to locate modules.  Thus, invoking\program{pydoc} \programopt{spam} documents precisely the version ofthe module you would get if you started the Python interpreter andtyped \samp{import spam}. Module docs for core modules are assumed to reside in{}\url{http://www.python.org/doc/current/lib/}.  This can be overridden bysetting the \envvar{PYTHONDOCS} environment variable to a different URL orto a local directory containing the Library Reference Manual pages.