1Python Documentation README
2~~~~~~~~~~~~~~~~~~~~~~~~~~~
3
4This directory contains the reStructuredText (reST) sources to the Python
5documentation. You don't need to build them yourself, `prebuilt versions are
6available <https://docs.python.org/dev/download.html>`_.
7
8Documentation on authoring Python documentation, including information about
9both style and markup, is available in the "`Documenting Python
10<https://devguide.python.org/documenting/>`_" chapter of the
11developers guide.
12
13
14Building the docs
15=================
16
17The documentation is built with several tools which are not included in this
18tree but are maintained separately and are available from
19`PyPI <https://pypi.org/>`_.
20
21* `Sphinx <https://pypi.org/project/Sphinx/>`_
22* `blurb <https://pypi.org/project/blurb/>`_
23* `python-docs-theme <https://pypi.org/project/python-docs-theme/>`_
24
25The easiest way to install these tools is to create a virtual environment and
26install the tools into there.
27
28Using make
29----------
30
31To get started on UNIX, you can create a virtual environment and build
32documentation with the commands::
33
34 make venv
35 make html
36
37The virtual environment in the ``venv`` directory will contain all the tools
38necessary to build the documentation downloaded and installed from PyPI.
39If you'd like to create the virtual environment in a different location,
40you can specify it using the ``VENVDIR`` variable.
41
42You can also skip creating the virtual environment altogether, in which case
43the Makefile will look for instances of ``sphinxbuild`` and ``blurb``
44installed on your process ``PATH`` (configurable with the ``SPHINXBUILD`` and
45``BLURB`` variables).
46
47On Windows, we try to emulate the Makefile as closely as possible with a
48``make.bat`` file. If you need to specify the Python interpreter to use,
49set the PYTHON environment variable.
50
51Available make targets are:
52
53* "clean", which removes all build files and the virtual environment.
54
55* "clean-venv", which removes the virtual environment directory.
56
57* "venv", which creates a virtual environment with all necessary tools
58 installed.
59
60* "html", which builds standalone HTML files for offline viewing.
61
62* "htmlview", which re-uses the "html" builder, but then opens the main page
63 in your default web browser.
64
65* "htmlhelp", which builds HTML files and a HTML Help project file usable to
66 convert them into a single Compiled HTML (.chm) file -- these are popular
67 under Microsoft Windows, but very handy on every platform.
68
69 To create the CHM file, you need to run the Microsoft HTML Help Workshop
70 over the generated project (.hhp) file. The make.bat script does this for
71 you on Windows.
72
73* "latex", which builds LaTeX source files as input to "pdflatex" to produce
74 PDF documents.
75
76* "text", which builds a plain text file for each source file.
77
78* "epub", which builds an EPUB document, suitable to be viewed on e-book
79 readers.
80
81* "linkcheck", which checks all external references to see whether they are
82 broken, redirected or malformed, and outputs this information to stdout as
83 well as a plain-text (.txt) file.
84
85* "changes", which builds an overview over all versionadded/versionchanged/
86 deprecated items in the current version. This is meant as a help for the
87 writer of the "What's New" document.
88
89* "coverage", which builds a coverage overview for standard library modules and
90 C API.
91
92* "pydoc-topics", which builds a Python module containing a dictionary with
93 plain text documentation for the labels defined in
94 `tools/pyspecific.py` -- pydoc needs these to show topic and keyword help.
95
96* "suspicious", which checks the parsed markup for text that looks like
97 malformed and thus unconverted reST.
98
99* "check", which checks for frequent markup errors.
100
101* "serve", which serves the build/html directory on port 8000.
102
103* "dist", (Unix only) which creates distributable archives of HTML, text,
104 PDF, and EPUB builds.
105
106
107Without make
108------------
109
110First, install the tool dependencies from PyPI.
111
112Then, from the ``Doc`` directory, run ::
113
114 sphinx-build -b<builder> . build/<builder>
115
116where ``<builder>`` is one of html, text, latex, or htmlhelp (for explanations
117see the make targets above).
118
119Deprecation header
120==================
121
122You can define the ``outdated`` variable in ``html_context`` to show a
123red banner on each page redirecting to the "latest" version.
124
125The link points to the same page on ``/3/``, sadly for the moment the
126language is lost during the process.
127
128
129Contributing
130============
131
132Bugs in the content should be reported to the
133`Python bug tracker <https://bugs.python.org>`_.
134
135Bugs in the toolset should be reported to the tools themselves.
136
137You can also send a mail to the Python Documentation Team at docs@python.org,
138and we will process your request as soon as possible.
139
140If you want to help the Documentation Team, you are always welcome. Just send
141a mail to docs@python.org.
142