LinuxCommandLibrary

pydoc3

TLDR

View module documentation

$ pydoc3 [module]
copy
Search documentation
$ pydoc3 -k [keyword]
copy
Start documentation server
$ pydoc3 -p [8080]
copy
Write HTML documentation
$ pydoc3 -w [module]
copy
View builtin function
$ pydoc3 [print]
copy

SYNOPSIS

pydoc3 [options] [name]

DESCRIPTION

pydoc3 is the Python 3 documentation browser. It displays docstrings, module contents, and can generate HTML documentation or serve it via built-in web server.

PARAMETERS

-k keyword

Search for keyword.
-p port
Start HTTP server.
-b
Open browser to server.
-w module
Write HTML file.
-n host
Server hostname.

EXAMPLES

$ # View module docs
pydoc3 os
pydoc3 json.loads

# Search for topic
pydoc3 -k sort

# Start doc server
pydoc3 -p 8080
# Then browse http://localhost:8080

# With browser auto-open
pydoc3 -b

# Generate HTML
pydoc3 -w mymodule
copy

IN PYTHON

$ # Get help in interpreter
help(str.split)

# Same as pydoc
import pydoc
pydoc.doc(str.split)
copy

CAVEATS

Shows docstrings, not source. For source, use inspect module. Part of Python standard library.

HISTORY

pydoc is part of the Python standard library, providing documentation access since Python 2.1.

SEE ALSO

python3(1), sphinx(1), help(3)

Copied to clipboard