blob: 4d743976223e1df09cee7a68662dfb059272af21 [file] [log] [blame]
Georg Brandl116aa622007-08-15 14:28:22 +00001
2:mod:`pydoc` --- Documentation generator and online help system
3===============================================================
4
5.. module:: pydoc
6 :synopsis: Documentation generator and online help system.
7.. moduleauthor:: Ka-Ping Yee <ping@lfw.org>
8.. sectionauthor:: Ka-Ping Yee <ping@lfw.org>
9
10
Georg Brandl116aa622007-08-15 14:28:22 +000011.. index::
12 single: documentation; generation
13 single: documentation; online
14 single: help; online
15
16The :mod:`pydoc` module automatically generates documentation from Python
17modules. The documentation can be presented as pages of text on the console,
18served to a Web browser, or saved to HTML files.
19
20The built-in function :func:`help` invokes the online help system in the
21interactive interpreter, which uses :mod:`pydoc` to generate its documentation
22as text on the console. The same text documentation can also be viewed from
23outside the Python interpreter by running :program:`pydoc` as a script at the
24operating system's command prompt. For example, running ::
25
26 pydoc sys
27
28at a shell prompt will display documentation on the :mod:`sys` module, in a
29style similar to the manual pages shown by the Unix :program:`man` command. The
30argument to :program:`pydoc` can be the name of a function, module, or package,
31or a dotted reference to a class, method, or function within a module or module
32in a package. If the argument to :program:`pydoc` looks like a path (that is,
33it contains the path separator for your operating system, such as a slash in
34Unix), and refers to an existing Python source file, then documentation is
35produced for that file.
36
37Specifying a :option:`-w` flag before the argument will cause HTML documentation
38to be written out to a file in the current directory, instead of displaying text
39on the console.
40
41Specifying a :option:`-k` flag before the argument will search the synopsis
42lines of all available modules for the keyword given as the argument, again in a
43manner similar to the Unix :program:`man` command. The synopsis line of a
44module is the first line of its documentation string.
45
46You can also use :program:`pydoc` to start an HTTP server on the local machine
47that will serve documentation to visiting Web browsers. :program:`pydoc`
48:option:`-p 1234` will start a HTTP server on port 1234, allowing you to browse
49the documentation at ``http://localhost:1234/`` in your preferred Web browser.
50:program:`pydoc` :option:`-g` will start the server and additionally bring up a
51small :mod:`Tkinter`\ -based graphical interface to help you search for
52documentation pages.
53
54When :program:`pydoc` generates documentation, it uses the current environment
55and path to locate modules. Thus, invoking :program:`pydoc` :option:`spam`
56documents precisely the version of the module you would get if you started the
57Python interpreter and typed ``import spam``.
58
59Module docs for core modules are assumed to reside in
60http://www.python.org/doc/current/lib/. This can be overridden by setting the
61:envvar:`PYTHONDOCS` environment variable to a different URL or to a local
62directory containing the Library Reference Manual pages.
63