pydoc¶
Generate Python documentation in HTML or text for interactive use.
In the Python interpreter, do “from pydoc import help” to provide online help. Calling help(thing) on a Python object documents the object.
Or, at the shell command line outside of Python:
Run “pydoc <name>” to show documentation on something. <name> may be the name of a function, module, package, or a dotted reference to a class or function within a module or module in a package. If the argument contains a path segment delimiter (e.g. slash on Unix, backslash on Windows) it is treated as the path to a Python source file.
Run “pydoc -k <keyword>” to search for a keyword in the synopsis lines of all available modules.
Run “pydoc -p <port>” to start an HTTP server on a given port on the local machine to generate documentation web pages. Port number 0 can be used to get an arbitrary unused port.
For platforms without a command line, “pydoc -g” starts the HTTP server and also pops up a little window for controlling it.
Run “pydoc -w <name>” to write out the HTML documentation for a module to a file named “<name>.html”.
Module docs for core modules are assumed to be in
This can be overridden by setting the PYTHONDOCS environment variable to a different URL or to a local directory containing the Library Reference Manual pages.
Functions¶
allmethods(cl) |
|
apropos(key) |
Print all the one-line module summaries that contain a substring. |
classify_class_attrs(object) |
Wrap inspect.classify_class_attrs, with fixup for data descriptors. |
classname(object, modname) |
Get a class name and qualify it with a module name if necessary. |
cli() |
Command-line interface (looks at sys.argv to decide what to do). |
cram(text, maxlen) |
Omit part of a string if needed to make it fit in a maximum length. |
describe(thing) |
Produce a short description of the given thing. |
doc(thing[, title, forceload]) |
Display text documentation, given an object or a path to an object. |
expandtabs((s [,tabsize]) -> string) |
Return a copy of the string s with all tab characters replaced by the appropriate number of spaces, depending on the current column, and the tabsize (default 8). |
extract_tb(tb[, limit]) |
Return list of up to limit pre-processed entries from traceback. |
find((s, sub [,start [,end]]) -> in) |
Return the lowest index in s where substring sub is found, such that sub is contained within s[start,end]. |
getdoc(object) |
Get the doc string or comments for an object. |
getpager() |
Decide what method to use for paging through text. |
gui() |
Graphical interface (starts web server and pops up a control window). |
importfile(path) |
Import a Python source file or compiled file given its path. |
isdata(object) |
Check if an object is of a type that probably means it’s data. |
ispackage(path) |
Guess whether a path refers to a package directory. |
ispath(x) |
|
join((list [,sep]) -> string) |
Return a string composed of the words in list, with intervening occurrences of sep. |
locate(path[, forceload]) |
Locate an object by name or dotted path, importing as necessary. |
lower((s) -> string) |
Return a copy of the string s converted to lowercase. |
pager(text) |
The first time this is called, determine what kind of pager to use. |
pathdirs() |
Convert sys.path into a list of absolute, existing, unique paths. |
pipepager(text, cmd) |
Page through text by feeding it to another program. |
plain(text) |
Remove boldface formatting from text. |
plainpager(text) |
Simply print unformatted text. |
render_doc(thing[, title, forceload]) |
Render text documentation, given an object or a path to an object. |
replace(text, *pairs) |
Do a series of global replacements on a string. |
resolve(thing[, forceload]) |
Given an object or a path to an object, get the object and its name. |
rfind((s, sub [,start [,end]]) -> int) |
Return the highest index in s where substring sub is found, such that sub is contained within s[start,end]. |
rstrip((s [,chars]) -> string) |
Return a copy of the string s with trailing whitespace removed. |
safeimport(path[, forceload, cache]) |
Import a module; handle errors; return None if the module isn’t found. |
serve(port[, callback, completer]) |
|
source_synopsis(file) |
|
split((s [,sep [,maxsplit]]) -> list of strings) |
Return a list of the words in the string s, using sep as the delimiter string. |
splitdoc(doc) |
Split a doc string into a synopsis line (if any) and the rest. |
strip((s [,chars]) -> string) |
Return a copy of the string s with leading and trailing whitespace removed. |
stripid(text) |
Remove the hexadecimal id from a Python object representation. |
synopsis(filename[, cache]) |
Get the one-line summary out of a module file. |
tempfilepager(text, cmd) |
Page through text by invoking a program on a temporary file. |
ttypager(text) |
Page through text on a text terminal. |
visiblename(name[, all, obj]) |
Decide whether to show documentation on a variable. |
writedoc(thing[, forceload]) |
Write HTML documentation to a file in the current directory. |
writedocs(dir[, pkgpath, done]) |
Write out HTML documentation for all modules in a directory tree. |
Classes¶
Doc |
|
HTMLDoc |
Formatter class for HTML documentation. |
HTMLRepr() |
Class for safely making an HTML representation of a Python object. |
Helper([input, output]) |
|
ModuleScanner |
An interruptible scanner that searches module synopses. |
Repr() |
|
Scanner(roots, children, descendp) |
A generic tree iterator. |
TextDoc |
Formatter class for text documentation. |
TextRepr() |
Class for safely making a text representation of a Python object. |
deque |
deque([iterable[, maxlen]]) –> deque object |
Exceptions¶
ErrorDuringImport(filename, exc_info) |
Errors that occurred while trying to import something to document it. |