The Python language has a substantial body of documentation, much of it contributed by various authors. The markup used for the Python documentation is
, developed by the
project, amended by custom directives and using a toolset named
to post-process the HTML output.
The documentation in HTML, PDF or EPUB format is generated from text files written using the
and contained in the
.
Note
If you’re interested in contributing to Python’s documentation, there’s no need to write reStructuredText if you’re not so inclined; plain text contributions are more than welcome as well. Send an e-mail to
or open an issue on the
.
Introduction
Python’s documentation has long been considered to be good for a free programming language. There are a number of reasons for this, the most important being the early commitment of Python’s creator, Guido van Rossum, to providing documentation on the language and its libraries, and the continuing involvement of the user community in providing assistance for creating and maintaining documentation.
The involvement of the community takes many forms, from authoring to bug reports to just plain complaining when the documentation could be more complete or easier to use.
This section is aimed at authors and potential authors of documentation for Python. More specifically, it is for people contributing to the standard documentation and developing additional documents using the same tools as the standard documents. This guide will be less useful for authors using the Python documentation tools for topics other than Python, and less useful still for authors not using the tools at all.
If your interest is in contributing to the Python documentation, but you don’t have the time or inclination to learn reStructuredText and the markup structures documented here, there’s a welcoming place for you among the Python contributors as well. Any time you feel that you can clarify existing documentation or provide documentation that’s missing, the existing documentation team will gladly work with you to integrate your text, dealing with the markup for you. Please don’t let the material in this section stand between the documentation and your desire to help out!
Building the documentation
To build the documentation, follow the steps in one of the sections below. You can view the documentation after building the HTML by opening the file Doc/build/html/index.html in a web browser.
Initial requirements
Ensure your current working directory is the top level Doc/ directory inside your
. You can switch to it with:
cdDoc Ensure your Python version is at least 3.11. You can verify it with:
python--version Create a virtual environment
You can create a new
with the required dependencies using:
Build using make / make.bat
Unix/macOS
A Unix Makefile is provided,
.
Windows
A Windows make.bat is provided,
, which attempts to emulate the Unix Makefile as closely as practical.
Important
The Windows make.bat batch file lacks a makevenv target. Instead, it automatically installs any missing dependencies into the currently activated environment (or the base Python, if none). Make sure the environment you
is
before running make.bat.
To build the docs as HTML, run:
Unix/macOS
makehtml Windows
.\make html Tip
Replace html with htmlview to open the docs in a web browser once the build completes.
Replace html with htmllive to rebuild the docs, start a local server, and automatically reload the page in your browser when you make changes to reST files (Unix only).
To build a documentation translation, see this
.
It is also possible to build only certain pages of the documentation in order to save time during the build process. Following is an example for building two pages:
Unix/macOS
makehtmlSOURCES="tutorial/classes.rst tutorial/inputoutput.rst"Windows
See
. When invoking sphinx-build, pass the desired pages as the final parameter, like so:
python -m sphinx -b html . build/html tutorial/classes.rst tutorial/inputoutput.rst To check the docs for common errors with
(which is run on all
), use:
Unix/macOS
makecheck Windows
.\make check To list other supported make targets, run:
Unix/macOS
makehelpWindows
.\make help See
for more information.
Build using Sphinx directly
Advanced users may want to invoke Sphinx directly, to pass specialized options or to handle specific use cases.
Make sure the environment you
is
. Then, install the documentation requirements,
. Using pip:
python-mpipinstall--upgrade-rrequirements.txt Finally, directly invoke Sphinx with:
python-msphinx-bhtml.build/html To use a different
, replace html above with the desired builder name.