blob: 12d74ea24ce4aca139b5f2a1120b365d488e7fa0 [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',
18 'asdl_highlight']
Christian Heimes26855632008-01-27 23:50:43 +000019
Stéphane Wirtel859c0682018-10-12 09:51:05 +020020
21doctest_global_setup = '''
22try:
23 import _tkinter
24except ImportError:
25 _tkinter = None
26'''
Batuhan Taşkayaeab99652019-05-19 00:53:53 +030027
28manpages_url = 'https://manpages.debian.org/{path}'
29
Christian Heimes679db4a2008-01-18 09:56:22 +000030# General substitutions.
31project = 'Python'
Berker Peksag2ec1bee2016-04-24 03:21:13 +030032copyright = '2001-%s, Python Software Foundation' % time.strftime('%Y')
Christian Heimes679db4a2008-01-18 09:56:22 +000033
Georg Brandl86def6c2008-01-21 20:36:10 +000034# We look for the Include/patchlevel.h file in the current Python source tree
35# and replace the values accordingly.
36import patchlevel
37version, release = patchlevel.get_version_info()
Georg Brandl116aa622007-08-15 14:28:22 +000038
39# There are two options for replacing |today|: either, you set today to some
40# non-false value, then it is used:
41today = ''
42# Else, today_fmt is used as the format for a strftime call.
43today_fmt = '%B %d, %Y'
44
Georg Brandl64063702008-09-09 19:10:58 +000045# By default, highlight as Python 3.
46highlight_language = 'python3'
47
Anthony Sottilea16ab002019-02-15 18:41:15 -050048# Minimum version of sphinx required
49needs_sphinx = '1.8'
Larry Hastings3732ed22014-03-15 21:13:56 -070050
Senthil Kumaran889f9142016-06-04 22:22:26 -070051# Ignore any .rst files in the venv/ directory.
Julien Palard73e05492019-08-26 08:11:43 +020052exclude_patterns = ['venv/*', 'README.rst']
53venvdir = os.getenv('VENVDIR')
54if venvdir is not None:
55 exclude_patterns.append(venvdir + '/*')
Brett Cannon9b166662015-03-30 15:35:37 -040056
Adrian Liawc03bf0a2018-11-05 05:04:51 +080057# Disable Docutils smartquotes for several translations
58smartquotes_excludes = {
59 'languages': ['ja', 'fr', 'zh_TW', 'zh_CN'], 'builders': ['man', 'text'],
60}
61
Jean-François Bfc8284e2018-12-22 23:31:08 +010062# Avoid a warning with Sphinx >= 2.0
63master_doc = 'contents'
Christian Heimes2c181612007-12-17 20:04:13 +000064
65# Options for HTML output
66# -----------------------
67
Georg Brandl9a333a62014-10-29 08:04:27 +010068# Use our custom theme.
Jon Wayne Parrottbf63e8d2018-03-01 13:02:50 -080069html_theme = 'python_docs_theme'
Ned Deily14366f32014-09-30 18:41:37 -070070html_theme_path = ['tools']
Jon Wayne Parrottbf63e8d2018-03-01 13:02:50 -080071html_theme_options = {
72 'collapsiblesidebar': True,
73 'issues_url': 'https://docs.python.org/3/bugs.html',
74 'root_include_title': False # We use the version switcher instead.
75}
Georg Brandla0745232010-07-30 11:31:03 +000076
Georg Brandl9a333a62014-10-29 08:04:27 +010077# Short title used e.g. for <title> HTML tags.
Georg Brandlab712142012-03-25 20:31:57 +020078html_short_title = '%s Documentation' % release
79
Christian Heimes2c181612007-12-17 20:04:13 +000080# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
81# using the given strftime format.
82html_last_updated_fmt = '%b %d, %Y'
83
Georg Brandl9a333a62014-10-29 08:04:27 +010084# Path to find HTML templates.
Georg Brandla1f84862014-10-29 08:11:46 +010085templates_path = ['tools/templates']
Christian Heimes2c181612007-12-17 20:04:13 +000086
Christian Heimes679db4a2008-01-18 09:56:22 +000087# Custom sidebar templates, filenames relative to this file.
88html_sidebars = {
Zachary Warea3090a42016-09-09 13:11:27 -070089 # Defaults taken from http://www.sphinx-doc.org/en/stable/config.html#confval-html_sidebars
90 # Removes the quick search block
91 '**': ['localtoc.html', 'relations.html', 'customsourcelink.html'],
92 'index': ['indexsidebar.html'],
Christian Heimes679db4a2008-01-18 09:56:22 +000093}
94
95# Additional templates that should be rendered to pages.
96html_additional_pages = {
Georg Brandl45832ea2008-03-12 08:52:43 +000097 'download': 'download.html',
Christian Heimesa342c012008-04-20 21:01:16 +000098 'index': 'indexcontent.html',
Christian Heimes679db4a2008-01-18 09:56:22 +000099}
100
Georg Brandle7570052008-05-03 20:52:18 +0000101# Output an OpenSearch description file.
Georg Brandle73778c2014-10-29 08:36:35 +0100102html_use_opensearch = 'https://docs.python.org/' + version
Georg Brandle7570052008-05-03 20:52:18 +0000103
104# Additional static files.
Georg Brandl97e9ec62014-09-30 22:51:30 +0200105html_static_path = ['tools/static']
Georg Brandle7570052008-05-03 20:52:18 +0000106
Christian Heimes679db4a2008-01-18 09:56:22 +0000107# Output file base name for HTML help builder.
Christian Heimesb558a2e2008-03-02 22:46:37 +0000108htmlhelp_basename = 'python' + release.replace('.', '')
Christian Heimes679db4a2008-01-18 09:56:22 +0000109
Amaury Forgeot d'Arc35c86582008-06-17 21:11:29 +0000110# Split the index
111html_split_index = True
112
Christian Heimes2c181612007-12-17 20:04:13 +0000113
114# Options for LaTeX output
115# ------------------------
116
Julien Palard7324b5c2017-12-02 23:24:39 +0100117latex_engine = 'xelatex'
118
Ryan Gonzaleze7ffb992017-02-10 22:47:37 -0600119# Get LaTeX to handle Unicode correctly
François Magimelda9b4cf2017-09-22 19:16:57 +0200120latex_elements = {
François Magimelda9b4cf2017-09-22 19:16:57 +0200121}
Ryan Gonzaleze7ffb992017-02-10 22:47:37 -0600122
123# Additional stuff for the LaTeX preamble.
124latex_elements['preamble'] = r'''
125\authoraddress{
François Magimelda9b4cf2017-09-22 19:16:57 +0200126 \sphinxstrong{Python Software Foundation}\\
127 Email: \sphinxemail{docs@python.org}
Ryan Gonzaleze7ffb992017-02-10 22:47:37 -0600128}
129\let\Verbatim=\OriginalVerbatim
130\let\endVerbatim=\endOriginalVerbatim
Cheryl Sabellaa4ba8a32020-02-18 18:01:15 -0500131\setcounter{tocdepth}{2}
Ryan Gonzaleze7ffb992017-02-10 22:47:37 -0600132'''
133
Christian Heimes679db4a2008-01-18 09:56:22 +0000134# The paper size ('letter' or 'a4').
Ryan Gonzaleze7ffb992017-02-10 22:47:37 -0600135latex_elements['papersize'] = 'a4'
Christian Heimes2c181612007-12-17 20:04:13 +0000136
Christian Heimes679db4a2008-01-18 09:56:22 +0000137# The font size ('10pt', '11pt' or '12pt').
François Magimelda9b4cf2017-09-22 19:16:57 +0200138latex_elements['pointsize'] = '10pt'
Christian Heimes679db4a2008-01-18 09:56:22 +0000139
140# Grouping the document tree into LaTeX files. List of tuples
141# (source start file, target name, title, author, document class [howto/manual]).
Georg Brandl9ab33ea2014-10-29 08:14:04 +0100142_stdauthor = r'Guido van Rossum\\and the Python development team'
Christian Heimes679db4a2008-01-18 09:56:22 +0000143latex_documents = [
Christian Heimes292d3512008-02-03 16:51:08 +0000144 ('c-api/index', 'c-api.tex',
Christian Heimes679db4a2008-01-18 09:56:22 +0000145 'The Python/C API', _stdauthor, 'manual'),
Larry Hastings3732ed22014-03-15 21:13:56 -0700146 ('distributing/index', 'distributing.tex',
Christian Heimes679db4a2008-01-18 09:56:22 +0000147 'Distributing Python Modules', _stdauthor, 'manual'),
Christian Heimes292d3512008-02-03 16:51:08 +0000148 ('extending/index', 'extending.tex',
Christian Heimes679db4a2008-01-18 09:56:22 +0000149 'Extending and Embedding Python', _stdauthor, 'manual'),
Larry Hastings3732ed22014-03-15 21:13:56 -0700150 ('installing/index', 'installing.tex',
Christian Heimes679db4a2008-01-18 09:56:22 +0000151 'Installing Python Modules', _stdauthor, 'manual'),
Christian Heimes292d3512008-02-03 16:51:08 +0000152 ('library/index', 'library.tex',
Christian Heimes679db4a2008-01-18 09:56:22 +0000153 'The Python Library Reference', _stdauthor, 'manual'),
Christian Heimes292d3512008-02-03 16:51:08 +0000154 ('reference/index', 'reference.tex',
Christian Heimes679db4a2008-01-18 09:56:22 +0000155 'The Python Language Reference', _stdauthor, 'manual'),
Christian Heimes292d3512008-02-03 16:51:08 +0000156 ('tutorial/index', 'tutorial.tex',
Christian Heimes679db4a2008-01-18 09:56:22 +0000157 'Python Tutorial', _stdauthor, 'manual'),
Christian Heimes292d3512008-02-03 16:51:08 +0000158 ('using/index', 'using.tex',
Georg Brandl8d582162010-09-03 22:33:27 +0000159 'Python Setup and Usage', _stdauthor, 'manual'),
Georg Brandle5b5ff42010-11-12 06:19:48 +0000160 ('faq/index', 'faq.tex',
161 'Python Frequently Asked Questions', _stdauthor, 'manual'),
Christian Heimes292d3512008-02-03 16:51:08 +0000162 ('whatsnew/' + version, 'whatsnew.tex',
Christian Heimes679db4a2008-01-18 09:56:22 +0000163 'What\'s New in Python', 'A. M. Kuchling', 'howto'),
164]
165# Collect all HOWTOs individually
Christian Heimes292d3512008-02-03 16:51:08 +0000166latex_documents.extend(('howto/' + fn[:-4], 'howto-' + fn[:-4] + '.tex',
Benjamin Petersonf608c612008-11-16 18:33:53 +0000167 '', _stdauthor, 'howto')
Christian Heimes679db4a2008-01-18 09:56:22 +0000168 for fn in os.listdir('howto')
169 if fn.endswith('.rst') and fn != 'index.rst')
170
Christian Heimes679db4a2008-01-18 09:56:22 +0000171# Documents to append as an appendix to all manuals.
Christian Heimes292d3512008-02-03 16:51:08 +0000172latex_appendices = ['glossary', 'about', 'license', 'copyright']
Christian Heimesd3eb5a152008-02-24 00:38:49 +0000173
Senthil Kumarancbe63562016-01-08 01:01:56 -0800174# Options for Epub output
175# -----------------------
176
177epub_author = 'Python Documentation Authors'
178epub_publisher = 'Python Software Foundation'
Georg Brandl9a333a62014-10-29 08:04:27 +0100179
Christian Heimesd3eb5a152008-02-24 00:38:49 +0000180# Options for the coverage checker
181# --------------------------------
182
183# The coverage checker will ignore all modules/functions/classes whose names
184# match any of the following regexes (using re.match).
185coverage_ignore_modules = [
186 r'[T|t][k|K]',
187 r'Tix',
188 r'distutils.*',
189]
190
191coverage_ignore_functions = [
192 'test($|_)',
193]
194
195coverage_ignore_classes = [
196]
197
198# Glob patterns for C source files for C API coverage, relative to this directory.
199coverage_c_path = [
200 '../Include/*.h',
201]
202
203# Regexes to find C items in the source files.
204coverage_c_regexes = {
205 'cfunction': (r'^PyAPI_FUNC\(.*\)\s+([^_][\w_]+)'),
206 'data': (r'^PyAPI_DATA\(.*\)\s+([^_][\w_]+)'),
207 'macro': (r'^#define ([^_][\w_]+)\(.*\)[\s|\\]'),
208}
209
210# The coverage checker will ignore all C items whose names match these regexes
211# (using re.match) -- the keys must be the same as in coverage_c_regexes.
212coverage_ignore_c_items = {
213# 'cfunction': [...]
214}
Georg Brandl9a333a62014-10-29 08:04:27 +0100215
Georg Brandl0ef49662014-10-29 10:57:01 +0100216
217# Options for the link checker
218# ----------------------------
219
220# Ignore certain URLs.
221linkcheck_ignore = [r'https://bugs.python.org/(issue)?\d+',
222 # Ignore PEPs for now, they all have permanent redirects.
223 r'http://www.python.org/dev/peps/pep-\d+']
224
225
Georg Brandl9a333a62014-10-29 08:04:27 +0100226# Options for extensions
227# ----------------------
228
229# Relative filename of the reference count data file.
230refcount_file = 'data/refcounts.dat'