Today we’ll be talking about the PyDoc HTML reports, which can be used to read documentation in a more visual way than just reading the output of the help function.
Here’s the video version:
Starting the Server
The PyDoc HTML Reports can be read in a web browser. To start off you have to start a local server. You can do it in the console (or command line) using the following command:
pydoc –b
This starts the local server and opens the web browser where you can view the documentation. So, let’s launch the reports. Open the console and type the following:
python –m pydoc –b
The –m command line argument is there to locate the PyDoc’s module on your module import search path. As soon as you press Enter, the server is started and the documentation page is opened in the browser. If it doesn’t work for you, there may be several reasons. Try the Windows Launcher instead:
py –m pydoc –b
If this doesn’t work either, type the full path of where your python is installed followed by the pydoc command, like so:
C:\python37\python –m pydoc –b
Using the Documentation
Now, if all works fine, you should see the web page with the documentation:
You can use the links to search documentation for the modules, for the keywords or to read documentation by topic. You can also use the two input fields at the top. If you need help on a specific module, type its name in the Get field. Type random and click Get to see the results:
If you want to search for related topics, use the Search field. When done, just enter q in the console to stop the server.
Just one more thing. You can also save a modules’s HTML documentation to file so that you can view it offline whenever you want to. For example to save the documentation for the random module, use the following syntax in your console:
python -m pydoc -w random
This will save the documentation as random.html. Now you can open the file and read the documentation.