Welcome to pywebdoc’s documentation!

Presentation

pywebdoc is a CLI application to quickly open web documentation about Python. This tool works for standard libraries and PyPI packages. It opens web pages on your default web browser.

_images/demo.gif

Installation

You can install latest release of pywebdoc using pip3:

pip3 install pywebdoc

CLI Reference

The command line interface of pywebdoc is available for Linux, macOS and Windows. It uses click. To check if you successfully installed the library, you can entry in a command prompt:

pywebdoc --help

You will see the following content:

Usage: pywebdoc [OPTIONS] COMMAND [ARGS]...

Open Python packages url.

Options:
--version      Show the version and exit.
-v, --verbose  Give more output
--help         Show this message and exit.

Commands:
home           Open the home-page of a PyPI package.
list-packages  Make HTML file with the list of installed PyPI packages.
list-std       List standard libraries documentation urls.
py             Open the Python official documentation.
pypi           Open the PyPI web page of a package.
rtd            Open the documentation page of a package on ReadTheDocs.
std            Open the documentation page of a standard Python library.

It is the help menu of the CLI. You can see all the commands you can use.

Python official documentation

To open the Python official documentation, use the py command:

pywebdoc py [OPTIONS]

You can set the Python version with the VERSION option (default: 3) and the language with the LANG option (default: english).

For example, to open Python 3.9 documentation in french:

pywebdoc py -v 3.9 -l fr

This command will open your default web browser on this page:

_images/pyfr.png

Standard library

To open the documentation page of a standard Python library, use the std command:

pywebdoc std [OPTIONS] LIBRARY

The LIBRARY argument is the name of the library or module. You can also set the Python version and the language using the same options than the py command.

For example, to open the documentation of time:

pywebdoc std time

This is the web page opened:

_images/time.png

You can also open modules like os.path:

pywebdoc std os.path
_images/path.png

Note

If the URL does not exist, you see a “404 Not Found” error in the command prompt.

PyPI package

Pywebdoc can also open URLS about PyPI packages.

PyPI web page

First, you can open the PyPI web page of a package using the pypi command:

pywebdoc pypi [OPTIONS] PACKAGE

The PACKAGE argument is the name of the package. You can choose the release version with the VERSION option. For example, to open the PyPI web page of Sphinx 3.1.0:

pywebdoc pypi sphinx -v 3.1.0

This command will open this web page:

_images/pypi.png

Home-page

You can also open the home-page of a PyPI package using the home command:

pywebdoc home [OPTIONS] PACKAGE

Warning

This command will call the pip command to get the URL of the home-page. So, the package must be installed.

For example, to open the home-page of numpy, use:

pywebdoc home numpy

This command will open this URL:

_images/numpy.png

ReadTheDocs documentation

Finally, some PyPI packages host documentation on ReadTheDocs. To open the documentation page of a package on ReadTheDocs, use the command:

pywebdoc rtd [OPTIONS] PACKAGE

You can choose the documentation version with the VERSION option (default: latest) and the language with the LANG option (default: en). For example, you can open the documentation of numpy using:

pywebdoc rtd numpy
_images/rtd.png

Listing

With pywebdoc, you can also see the list of your packages and libraries and their documentation.

  • To get the list of standard Python libraries, use the list-std command:

pywebdoc list-std [OPTIONS]

You can use the same options as the py command. For example, the command

pywebdoc list-std

will open this URL:

_images/list-std.png
  • To get the list of installed PyPI packages, use the list-packages command:

pywebdoc list-packages [OPTIONS]

This command will create a HTML file with the list of installed PyPI packages. The creation of this page may take several minutes. On this page, you will see the following informations about packages:

  • name

  • version

  • summary

  • home-page

  • license

Once the file is created, it will be opened immediately. If you need to update the HTML file, use the UPDATE option.

For example, you can see below an example of this file:

_images/list-packages.png

API Reference

You can see below the modules of the pywebdoc package.

url

The url module manages the URLS. The URLS are ckecked with requests.

url.check_url(url, log=True)

Return True if no 404 error on url, else False.

url.open_url(url)

Open url if no 404 error is catched.

class url.UrlTemplate(template)

Bases: object

Manage an url template.

property template

Get url template.

render(**kwargs)

Render url template.

open_url(**kwargs)

Render the url template and open it.

packages

The packages module manages installed PyPI packages.

class packages.Package(name)

Bases: object

Manage an installed PyPI package.

property name

Get name.

property url

Get PyPI url.

property version

Get version.

property summary

Get summary.

property home_page

Get home-page.

static get_list()

Return the list of installed packages.

static make_html_list(filename)

Make html file with packages list.

pip

The pip module can call the pip command to get informations about installed PyPI packages.

pip.call(*args)

Call pip command and get result.

pip.get_installed_packages()

Return the list of installed packages.

pip.get_url(package)

Get the home-page url of a PyPI package. The package must be installed.

template

The template module manages templates. It uses jinja2.

class template.Templates(directory)

Bases: object

Manage the templates.

property env

Get environment.

get_template(filename)

Return a template.

logger

The logger module manages the configuration of the logger. It uses colorlog to get colored logging messages.

logger.logger_config(level, name=None)

Setup the logging environment.

error

The error module manages errors of pywebdoc.

exception error.PywebdocError

Bases: Exception

Custom class to raise pywebdoc exceptions.

GitHub repository: https://github.com/Quentin18/pywebdoc/

Indices and tables