blob: 6b88c23a44473f06d9bd3e959c1c5bb25c30749e [file] [log] [blame]
Georg Brandl116aa622007-08-15 14:28:22 +00001#
2# Python documentation build configuration file
3#
Christian Heimes679db4a2008-01-18 09:56:22 +00004# This file is execfile()d with the current directory set to its containing dir.
5#
Georg Brandl116aa622007-08-15 14:28:22 +00006# The contents of this file are pickled, so don't put values in the namespace
7# that aren't pickleable (module imports are okay, they're removed automatically).
Christian Heimes2c181612007-12-17 20:04:13 +00008
Georg Brandl86def6c2008-01-21 20:36:10 +00009import sys, os, time
Georg Brandle0390292014-10-29 08:07:37 +010010sys.path.append(os.path.abspath('tools/extensions'))
Marco Buttu909a6f62017-03-18 17:59:33 +010011sys.path.append(os.path.abspath('includes'))
Georg Brandl86def6c2008-01-21 20:36:10 +000012
Christian Heimes2c181612007-12-17 20:04:13 +000013# General configuration
14# ---------------------
Georg Brandl116aa622007-08-15 14:28:22 +000015
Georg Brandl5c01d992013-10-12 19:54:30 +020016extensions = ['sphinx.ext.coverage', 'sphinx.ext.doctest',
Batuhan Taskayab7a78ca2020-05-07 23:57:26 +030017 'pyspecific', 'c_annotations', 'escape4chm',
Ammar Askar8c5d0342020-12-18 14:00:51 -050018 'asdl_highlight', 'peg_highlight', 'glossary_search']
Stéphane Wirtel859c0682018-10-12 09:51:05 +020019
20doctest_global_setup = '''
21try:
22 import _tkinter
23except ImportError:
24 _tkinter = None
25'''
Batuhan Taşkayaeab99652019-05-19 00:53:53 +030026
27manpages_url = 'https://manpages.debian.org/{path}'
28
Christian Heimes679db4a2008-01-18 09:56:22 +000029# General substitutions.
30project = 'Python'
Berker Peksag2ec1bee2016-04-24 03:21:13 +030031copyright = '2001-%s, Python Software Foundation' % time.strftime('%Y')
Christian Heimes679db4a2008-01-18 09:56:22 +000032
Georg Brandl86def6c2008-01-21 20:36:10 +000033# We look for the Include/patchlevel.h file in the current Python source tree
34# and replace the values accordingly.
35import patchlevel
36version, release = patchlevel.get_version_info()
Georg Brandl116aa622007-08-15 14:28:22 +000037
38# There are two options for replacing |today|: either, you set today to some
39# non-false value, then it is used:
40today = ''
41# Else, today_fmt is used as the format for a strftime call.
42today_fmt = '%B %d, %Y'
43
Georg Brandl64063702008-09-09 19:10:58 +000044# By default, highlight as Python 3.
45highlight_language = 'python3'
46
Anthony Sottilea16ab002019-02-15 18:41:15 -050047# Minimum version of sphinx required
48needs_sphinx = '1.8'
Larry Hastings3732ed22014-03-15 21:13:56 -070049
Senthil Kumaran889f9142016-06-04 22:22:26 -070050# Ignore any .rst files in the venv/ directory.
Julien Palard73e05492019-08-26 08:11:43 +020051exclude_patterns = ['venv/*', 'README.rst']
52venvdir = os.getenv('VENVDIR')
53if venvdir is not None:
54 exclude_patterns.append(venvdir + '/*')
Brett Cannon9b166662015-03-30 15:35:37 -040055
Adrian Liawc03bf0a2018-11-05 05:04:51 +080056# Disable Docutils smartquotes for several translations
57smartquotes_excludes = {
58 'languages': ['ja', 'fr', 'zh_TW', 'zh_CN'], 'builders': ['man', 'text'],
59}
60
Jean-François Bfc8284e2018-12-22 23:31:08 +010061# Avoid a warning with Sphinx >= 2.0
62master_doc = 'contents'
Christian Heimes2c181612007-12-17 20:04:13 +000063
64# Options for HTML output
65# -----------------------
66
Georg Brandl9a333a62014-10-29 08:04:27 +010067# Use our custom theme.
Jon Wayne Parrottbf63e8d2018-03-01 13:02:50 -080068html_theme = 'python_docs_theme'
Ned Deily14366f32014-09-30 18:41:37 -070069html_theme_path = ['tools']
Jon Wayne Parrottbf63e8d2018-03-01 13:02:50 -080070html_theme_options = {
71 'collapsiblesidebar': True,
72 'issues_url': 'https://docs.python.org/3/bugs.html',
73 'root_include_title': False # We use the version switcher instead.
74}
Georg Brandla0745232010-07-30 11:31:03 +000075
Georg Brandl9a333a62014-10-29 08:04:27 +010076# Short title used e.g. for <title> HTML tags.
Georg Brandlab712142012-03-25 20:31:57 +020077html_short_title = '%s Documentation' % release
78
Christian Heimes2c181612007-12-17 20:04:13 +000079# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
80# using the given strftime format.
81html_last_updated_fmt = '%b %d, %Y'
82
Georg Brandl9a333a62014-10-29 08:04:27 +010083# Path to find HTML templates.
Georg Brandla1f84862014-10-29 08:11:46 +010084templates_path = ['tools/templates']
Christian Heimes2c181612007-12-17 20:04:13 +000085
Christian Heimes679db4a2008-01-18 09:56:22 +000086# Custom sidebar templates, filenames relative to this file.
87html_sidebars = {
Zachary Warea3090a42016-09-09 13:11:27 -070088 # Defaults taken from http://www.sphinx-doc.org/en/stable/config.html#confval-html_sidebars
89 # Removes the quick search block
90 '**': ['localtoc.html', 'relations.html', 'customsourcelink.html'],
91 'index': ['indexsidebar.html'],
Christian Heimes679db4a2008-01-18 09:56:22 +000092}
93
94# Additional templates that should be rendered to pages.
95html_additional_pages = {
Georg Brandl45832ea2008-03-12 08:52:43 +000096 'download': 'download.html',
Christian Heimesa342c012008-04-20 21:01:16 +000097 'index': 'indexcontent.html',
Christian Heimes679db4a2008-01-18 09:56:22 +000098}
99
Georg Brandle7570052008-05-03 20:52:18 +0000100# Output an OpenSearch description file.
Georg Brandle73778c2014-10-29 08:36:35 +0100101html_use_opensearch = 'https://docs.python.org/' + version
Georg Brandle7570052008-05-03 20:52:18 +0000102
103# Additional static files.
Georg Brandl97e9ec62014-09-30 22:51:30 +0200104html_static_path = ['tools/static']
Georg Brandle7570052008-05-03 20:52:18 +0000105
Christian Heimes679db4a2008-01-18 09:56:22 +0000106# Output file base name for HTML help builder.
Christian Heimesb558a2e2008-03-02 22:46:37 +0000107htmlhelp_basename = 'python' + release.replace('.', '')
Christian Heimes679db4a2008-01-18 09:56:22 +0000108
Amaury Forgeot d'Arc35c86582008-06-17 21:11:29 +0000109# Split the index
110html_split_index = True
111
Christian Heimes2c181612007-12-17 20:04:13 +0000112
113# Options for LaTeX output
114# ------------------------
115
Julien Palard7324b5c2017-12-02 23:24:39 +0100116latex_engine = 'xelatex'
117
Ryan Gonzaleze7ffb992017-02-10 22:47:37 -0600118# Get LaTeX to handle Unicode correctly
François Magimelda9b4cf2017-09-22 19:16:57 +0200119latex_elements = {
François Magimelda9b4cf2017-09-22 19:16:57 +0200120}
Ryan Gonzaleze7ffb992017-02-10 22:47:37 -0600121
122# Additional stuff for the LaTeX preamble.
123latex_elements['preamble'] = r'''
124\authoraddress{
François Magimelda9b4cf2017-09-22 19:16:57 +0200125 \sphinxstrong{Python Software Foundation}\\
126 Email: \sphinxemail{docs@python.org}
Ryan Gonzaleze7ffb992017-02-10 22:47:37 -0600127}
128\let\Verbatim=\OriginalVerbatim
129\let\endVerbatim=\endOriginalVerbatim
Cheryl Sabellaa4ba8a32020-02-18 18:01:15 -0500130\setcounter{tocdepth}{2}
Ryan Gonzaleze7ffb992017-02-10 22:47:37 -0600131'''
132
Christian Heimes679db4a2008-01-18 09:56:22 +0000133# The paper size ('letter' or 'a4').
Ryan Gonzaleze7ffb992017-02-10 22:47:37 -0600134latex_elements['papersize'] = 'a4'
Christian Heimes2c181612007-12-17 20:04:13 +0000135
Christian Heimes679db4a2008-01-18 09:56:22 +0000136# The font size ('10pt', '11pt' or '12pt').
François Magimelda9b4cf2017-09-22 19:16:57 +0200137latex_elements['pointsize'] = '10pt'
Christian Heimes679db4a2008-01-18 09:56:22 +0000138
139# Grouping the document tree into LaTeX files. List of tuples
140# (source start file, target name, title, author, document class [howto/manual]).
Georg Brandl9ab33ea2014-10-29 08:14:04 +0100141_stdauthor = r'Guido van Rossum\\and the Python development team'
Christian Heimes679db4a2008-01-18 09:56:22 +0000142latex_documents = [
Christian Heimes292d3512008-02-03 16:51:08 +0000143 ('c-api/index', 'c-api.tex',
Christian Heimes679db4a2008-01-18 09:56:22 +0000144 'The Python/C API', _stdauthor, 'manual'),
Larry Hastings3732ed22014-03-15 21:13:56 -0700145 ('distributing/index', 'distributing.tex',
Christian Heimes679db4a2008-01-18 09:56:22 +0000146 'Distributing Python Modules', _stdauthor, 'manual'),
Christian Heimes292d3512008-02-03 16:51:08 +0000147 ('extending/index', 'extending.tex',
Christian Heimes679db4a2008-01-18 09:56:22 +0000148 'Extending and Embedding Python', _stdauthor, 'manual'),
Larry Hastings3732ed22014-03-15 21:13:56 -0700149 ('installing/index', 'installing.tex',
Christian Heimes679db4a2008-01-18 09:56:22 +0000150 'Installing Python Modules', _stdauthor, 'manual'),
Christian Heimes292d3512008-02-03 16:51:08 +0000151 ('library/index', 'library.tex',
Christian Heimes679db4a2008-01-18 09:56:22 +0000152 'The Python Library Reference', _stdauthor, 'manual'),
Christian Heimes292d3512008-02-03 16:51:08 +0000153 ('reference/index', 'reference.tex',
Christian Heimes679db4a2008-01-18 09:56:22 +0000154 'The Python Language Reference', _stdauthor, 'manual'),
Christian Heimes292d3512008-02-03 16:51:08 +0000155 ('tutorial/index', 'tutorial.tex',
Christian Heimes679db4a2008-01-18 09:56:22 +0000156 'Python Tutorial', _stdauthor, 'manual'),
Christian Heimes292d3512008-02-03 16:51:08 +0000157 ('using/index', 'using.tex',
Georg Brandl8d582162010-09-03 22:33:27 +0000158 'Python Setup and Usage', _stdauthor, 'manual'),
Georg Brandle5b5ff42010-11-12 06:19:48 +0000159 ('faq/index', 'faq.tex',
160 'Python Frequently Asked Questions', _stdauthor, 'manual'),
Christian Heimes292d3512008-02-03 16:51:08 +0000161 ('whatsnew/' + version, 'whatsnew.tex',
Christian Heimes679db4a2008-01-18 09:56:22 +0000162 'What\'s New in Python', 'A. M. Kuchling', 'howto'),
163]
164# Collect all HOWTOs individually
Christian Heimes292d3512008-02-03 16:51:08 +0000165latex_documents.extend(('howto/' + fn[:-4], 'howto-' + fn[:-4] + '.tex',
Benjamin Petersonf608c612008-11-16 18:33:53 +0000166 '', _stdauthor, 'howto')
Christian Heimes679db4a2008-01-18 09:56:22 +0000167 for fn in os.listdir('howto')
168 if fn.endswith('.rst') and fn != 'index.rst')
169
Christian Heimes679db4a2008-01-18 09:56:22 +0000170# Documents to append as an appendix to all manuals.
Christian Heimes292d3512008-02-03 16:51:08 +0000171latex_appendices = ['glossary', 'about', 'license', 'copyright']
Christian Heimesd3eb5a152008-02-24 00:38:49 +0000172
Senthil Kumarancbe63562016-01-08 01:01:56 -0800173# Options for Epub output
174# -----------------------
175
176epub_author = 'Python Documentation Authors'
177epub_publisher = 'Python Software Foundation'
Georg Brandl9a333a62014-10-29 08:04:27 +0100178
Christian Heimesd3eb5a152008-02-24 00:38:49 +0000179# Options for the coverage checker
180# --------------------------------
181
182# The coverage checker will ignore all modules/functions/classes whose names
183# match any of the following regexes (using re.match).
184coverage_ignore_modules = [
185 r'[T|t][k|K]',
186 r'Tix',
187 r'distutils.*',
188]
189
190coverage_ignore_functions = [
191 'test($|_)',
192]
193
194coverage_ignore_classes = [
195]
196
197# Glob patterns for C source files for C API coverage, relative to this directory.
198coverage_c_path = [
199 '../Include/*.h',
200]
201
202# Regexes to find C items in the source files.
203coverage_c_regexes = {
204 'cfunction': (r'^PyAPI_FUNC\(.*\)\s+([^_][\w_]+)'),
205 'data': (r'^PyAPI_DATA\(.*\)\s+([^_][\w_]+)'),
206 'macro': (r'^#define ([^_][\w_]+)\(.*\)[\s|\\]'),
207}
208
209# The coverage checker will ignore all C items whose names match these regexes
210# (using re.match) -- the keys must be the same as in coverage_c_regexes.
211coverage_ignore_c_items = {
212# 'cfunction': [...]
213}
Georg Brandl9a333a62014-10-29 08:04:27 +0100214
Georg Brandl0ef49662014-10-29 10:57:01 +0100215
216# Options for the link checker
217# ----------------------------
218
219# Ignore certain URLs.
220linkcheck_ignore = [r'https://bugs.python.org/(issue)?\d+',
221 # Ignore PEPs for now, they all have permanent redirects.
222 r'http://www.python.org/dev/peps/pep-\d+']
223
224
Georg Brandl9a333a62014-10-29 08:04:27 +0100225# Options for extensions
226# ----------------------
227
228# Relative filename of the reference count data file.
229refcount_file = 'data/refcounts.dat'
Victor Stinner423e77d2020-08-12 21:49:22 +0200230
231# Sphinx 2 and Sphinx 3 compatibility
232# -----------------------------------
233
234# bpo-40204: Allow Sphinx 2 syntax in the C domain
235c_allow_pre_v3 = True
236
237# bpo-40204: Disable warnings on Sphinx 2 syntax of the C domain since the
238# documentation is built with -W (warnings treated as errors).
239c_warn_on_allowed_pre_v3 = False