@@ -64,79 +64,109 @@ Building the documentation
64
64
65
65
.. highlight :: bash
66
66
67
- The toolset used to build the docs is written in Python and is called Sphinx _.
68
- Sphinx is maintained separately and is not included in this tree. Also needed
69
- are blurb _, a tool to create :file: `Misc/NEWS ` on demand; and
70
- python-docs-theme _, the Sphinx theme for the Python documentation.
67
+ To build the documentation, follow the steps in one of the sections below.
68
+ You can view the documentation after building the HTML
69
+ by opening the file :file: `Doc/build/html/index.html ` in a web browser.
71
70
72
- To build the documentation, follow the instructions from one of the sections
73
- below. You can view the documentation after building the HTML by pointing
74
- a browser at the file :file: `Doc/build/html/index.html `.
71
+ .. note ::
75
72
76
- You are expected to have installed the latest stable version of
77
- Sphinx _ and blurb _ on your system or in a virtualenv _ (which can be
78
- created using ``make venv ``), so that the Makefile can find the
79
- ``sphinx-build `` command. You can also specify the location of
80
- ``sphinx-build `` with the ``SPHINXBUILD `` :command: `make ` variable.
73
+ The following instructions all assume your current working dir is
74
+ the ``Doc `` subdirectory in your :ref: `CPython repository clone <checkout >`.
75
+ Make sure to switch to it with ``cd Doc `` if necessary.
81
76
82
77
83
- .. _building-using-make :
78
+ .. _doc-create-venv :
79
+
80
+ Create a virtual environment
81
+ ----------------------------
84
82
85
- Using make / make.bat
86
- ---------------------
83
+ .. _doc-create-venv-unix :
87
84
88
- **On Unix **, run the following from the root of your :ref: `repository clone
89
- <checkout>` to build the output as HTML::
85
+ **On Unix platforms ** that support :program: `make `
86
+ (including Linux, macOS and BSD),
87
+ you can create a new :mod: `venv ` with the required dependencies using::
90
88
91
- cd Doc
92
89
make venv
93
- make html
94
90
95
- or alternatively ``make -C Doc/ venv html ``. ``htmlview `` can be used
96
- instead of ``html `` to conveniently open the docs in a browser once the
97
- build completes.
91
+ Building the docs with :program: `make ` will automatically use this environment
92
+ without you having to activate it.
93
+
94
+ .. _doc-create-venv-windows :
95
+
96
+ **On Windows **, or if not using :program: `make `,
97
+ `create a new virtual environment <venv-create _>`__ manually.
98
+ Always be sure to `activate this environment <venv-activate _>`__
99
+ before building the documentation.
100
+
101
+
102
+ .. _building-using-make :
103
+ .. _using-make-make-bat :
104
+ .. _doc-build-make :
105
+
106
+ Build using make / make.bat
107
+ ---------------------------
98
108
99
- You can also use ``make help `` to see a list of targets supported by
100
- :command: `make `. Note that ``make check `` is automatically run when
101
- you submit a :ref: `pull request <pullrequest >`, so you should make
102
- sure that it runs without errors.
109
+ A Unix ``Makefile `` is provided, :cpy-file: `Doc/Makefile `,
110
+ along with a :cpy-file: `Doc/make.bat ` batch file for Windows
111
+ that attempts to emulate it as closely as practical.
103
112
104
- **On Windows **, the :cpy-file: `Doc/make.bat ` batchfile tries to emulate
105
- :command: `make ` as closely as possible, but the venv target is not implemented,
106
- so you will probably want to make sure you are working in a virtual environment
107
- before proceeding, otherwise all dependencies will be automatically installed
108
- on your system.
113
+ .. important ::
109
114
110
- When ready, run the following from the root of your :ref: `repository clone
111
- <checkout>` to build the output as HTML::
115
+ The Windows ``make.bat `` batch file lacks a ``make venv `` target.
116
+ Instead, it automatically installs any missing dependencies
117
+ into the currently activated environment (or the base Python, if none).
118
+ Make sure the environment you :ref: `created above <doc-create-venv-windows >`
119
+ is `activated <venv-activate _>`__ before running ``make.bat ``.
120
+
121
+ To build the docs as HTML, run::
112
122
113
- cd Doc
114
123
make html
115
124
116
- You can also use ``make help `` to see a list of targets supported by
117
- :cpy-file: `Doc/make.bat `.
125
+ .. tip :: Substitute ``htmlview`` for ``html`` to open the docs in a web browser
126
+ once the build completes.
127
+
128
+ To check the docs for common errors with `Sphinx Lint `_
129
+ (which is run on all :ref: `pull requests <pullrequest >`), use::
130
+
131
+ make check
132
+
133
+ To list other supported :program: `make ` targets, run::
134
+
135
+ make help
136
+
137
+ See :cpy-file: `Doc/README.rst ` for more information.
138
+
139
+
140
+ .. _using-sphinx-build :
141
+ .. _doc-build-sphinx :
142
+
143
+ Build using Sphinx directly
144
+ ---------------------------
145
+
146
+ Advanced users may want to invoke Sphinx directly,
147
+ to pass specialized options or to handle specific use cases.
118
148
119
- See also :cpy-file: `Doc/README.rst ` for more information.
149
+ Make sure the environment you :ref: `created above <doc-create-venv-windows >`
150
+ is `activated <venv-activate _>`__.
151
+ Then, install the documentation requirements, :cpy-file: `Doc/requirements.txt `.
152
+ Using pip::
120
153
121
- Using sphinx-build
122
- ------------------
154
+ python -m pip install --upgrade -r requirements.txt
123
155
124
- Sometimes we directly want to execute the sphinx-build tool instead of through
125
- ``make `` (although the latter is still the preferred way). In this case, you can
126
- use the following command line from the ``Doc `` directory (make sure to install
127
- Sphinx _, blurb _ and python-docs-theme _ packages from PyPI)::
156
+ Finally, directly invoke Sphinx with::
128
157
129
- sphinx-build -b<builder> . build/<builder>
158
+ python -m sphinx -b html . build/html
130
159
131
- where `` <builder> `` is one of html, text, latex, or htmlhelp (for explanations
132
- see the make targets above) .
160
+ To use a different ` Sphinx builder `_,
161
+ replace `` html `` above with the desired builder `` name `` .
133
162
134
163
135
164
.. _docutils : https://docutils.sourceforge.io/
136
- .. _python-docs-theme : https://pypi.org/project/python-docs-theme/
137
165
.. _Sphinx : https://www.sphinx-doc.org/
138
- .. _virtualenv : https://virtualenv.pypa.io/
139
- .. _blurb : https://pypi.org/project/blurb/
166
+ .. _Sphinx builder : https://www.sphinx-doc.org/en/master/usage/builders/index.html
167
+ .. _Sphinx Lint : https://github.com/sphinx-contrib/sphinx-lint
168
+ .. _venv-activate : https://packaging.python.org/en/latest/guides/installing-using-pip-and-virtual-environments/#activating-a-virtual-environment
169
+ .. _venv-create : https://packaging.python.org/en/latest/guides/installing-using-pip-and-virtual-environments/#creating-a-virtual-environment
140
170
141
171
142
172
Style Guide
0 commit comments