1#
2# Python documentation build configuration file
3#
4# This file is execfile()d with the current directory set to its containing dir.
5#
6# 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).
8
9import sys, os, time
10sys.path.append(os.path.abspath('tools/extensions'))
11sys.path.append(os.path.abspath('includes'))
12
13# General configuration
14# ---------------------
15
16extensions = ['sphinx.ext.coverage', 'sphinx.ext.doctest',
17              'pyspecific', 'c_annotations', 'escape4chm']
18
19
20doctest_global_setup = '''
21try:
22    import _tkinter
23except ImportError:
24    _tkinter = None
25'''
26
27manpages_url = 'https://manpages.debian.org/{path}'
28
29# General substitutions.
30project = 'Python'
31copyright = '2001-%s, Python Software Foundation' % time.strftime('%Y')
32
33# 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()
37
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
44# By default, highlight as Python 3.
45highlight_language = 'python3'
46
47# Minimum version of sphinx required
48needs_sphinx = '1.8'
49
50# Ignore any .rst files in the venv/ directory.
51exclude_patterns = ['venv/*', 'README.rst']
52venvdir = os.getenv('VENVDIR')
53if venvdir is not None:
54    exclude_patterns.append(venvdir + '/*')
55
56# Disable Docutils smartquotes for several translations
57smartquotes_excludes = {
58    'languages': ['ja', 'fr', 'zh_TW', 'zh_CN'], 'builders': ['man', 'text'],
59}
60
61# Avoid a warning with Sphinx >= 2.0
62master_doc = 'contents'
63
64# Options for HTML output
65# -----------------------
66
67# Use our custom theme.
68html_theme = 'python_docs_theme'
69html_theme_path = ['tools']
70html_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}
75
76# Short title used e.g. for <title> HTML tags.
77html_short_title = '%s Documentation' % release
78
79# 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
83# Path to find HTML templates.
84templates_path = ['tools/templates']
85
86# Custom sidebar templates, filenames relative to this file.
87html_sidebars = {
88    # 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'],
92}
93
94# Additional templates that should be rendered to pages.
95html_additional_pages = {
96    'download': 'download.html',
97    'index': 'indexcontent.html',
98}
99
100# Output an OpenSearch description file.
101html_use_opensearch = 'https://docs.python.org/' + version
102
103# Additional static files.
104html_static_path = ['tools/static']
105
106# Output file base name for HTML help builder.
107htmlhelp_basename = 'python' + release.replace('.', '')
108
109# Split the index
110html_split_index = True
111
112
113# Options for LaTeX output
114# ------------------------
115
116latex_engine = 'xelatex'
117
118# Get LaTeX to handle Unicode correctly
119latex_elements = {
120}
121
122# Additional stuff for the LaTeX preamble.
123latex_elements['preamble'] = r'''
124\authoraddress{
125  \sphinxstrong{Python Software Foundation}\\
126  Email: \sphinxemail{docs@python.org}
127}
128\let\Verbatim=\OriginalVerbatim
129\let\endVerbatim=\endOriginalVerbatim
130'''
131
132# The paper size ('letter' or 'a4').
133latex_elements['papersize'] = 'a4'
134
135# The font size ('10pt', '11pt' or '12pt').
136latex_elements['pointsize'] = '10pt'
137
138# Grouping the document tree into LaTeX files. List of tuples
139# (source start file, target name, title, author, document class [howto/manual]).
140_stdauthor = r'Guido van Rossum\\and the Python development team'
141latex_documents = [
142    ('c-api/index', 'c-api.tex',
143     'The Python/C API', _stdauthor, 'manual'),
144    ('distributing/index', 'distributing.tex',
145     'Distributing Python Modules', _stdauthor, 'manual'),
146    ('extending/index', 'extending.tex',
147     'Extending and Embedding Python', _stdauthor, 'manual'),
148    ('installing/index', 'installing.tex',
149     'Installing Python Modules', _stdauthor, 'manual'),
150    ('library/index', 'library.tex',
151     'The Python Library Reference', _stdauthor, 'manual'),
152    ('reference/index', 'reference.tex',
153     'The Python Language Reference', _stdauthor, 'manual'),
154    ('tutorial/index', 'tutorial.tex',
155     'Python Tutorial', _stdauthor, 'manual'),
156    ('using/index', 'using.tex',
157     'Python Setup and Usage', _stdauthor, 'manual'),
158    ('faq/index', 'faq.tex',
159     'Python Frequently Asked Questions', _stdauthor, 'manual'),
160    ('whatsnew/' + version, 'whatsnew.tex',
161     'What\'s New in Python', 'A. M. Kuchling', 'howto'),
162]
163# Collect all HOWTOs individually
164latex_documents.extend(('howto/' + fn[:-4], 'howto-' + fn[:-4] + '.tex',
165                        '', _stdauthor, 'howto')
166                       for fn in os.listdir('howto')
167                       if fn.endswith('.rst') and fn != 'index.rst')
168
169# Documents to append as an appendix to all manuals.
170latex_appendices = ['glossary', 'about', 'license', 'copyright']
171
172# Options for Epub output
173# -----------------------
174
175epub_author = 'Python Documentation Authors'
176epub_publisher = 'Python Software Foundation'
177
178# Options for the coverage checker
179# --------------------------------
180
181# The coverage checker will ignore all modules/functions/classes whose names
182# match any of the following regexes (using re.match).
183coverage_ignore_modules = [
184    r'[T|t][k|K]',
185    r'Tix',
186    r'distutils.*',
187]
188
189coverage_ignore_functions = [
190    'test($|_)',
191]
192
193coverage_ignore_classes = [
194]
195
196# Glob patterns for C source files for C API coverage, relative to this directory.
197coverage_c_path = [
198    '../Include/*.h',
199]
200
201# Regexes to find C items in the source files.
202coverage_c_regexes = {
203    'cfunction': (r'^PyAPI_FUNC\(.*\)\s+([^_][\w_]+)'),
204    'data': (r'^PyAPI_DATA\(.*\)\s+([^_][\w_]+)'),
205    'macro': (r'^#define ([^_][\w_]+)\(.*\)[\s|\\]'),
206}
207
208# The coverage checker will ignore all C items whose names match these regexes
209# (using re.match) -- the keys must be the same as in coverage_c_regexes.
210coverage_ignore_c_items = {
211#    'cfunction': [...]
212}
213
214
215# Options for the link checker
216# ----------------------------
217
218# Ignore certain URLs.
219linkcheck_ignore = [r'https://bugs.python.org/(issue)?\d+',
220                    # Ignore PEPs for now, they all have permanent redirects.
221                    r'http://www.python.org/dev/peps/pep-\d+']
222
223
224# Options for extensions
225# ----------------------
226
227# Relative filename of the reference count data file.
228refcount_file = 'data/refcounts.dat'
229
230# Sphinx 2 and Sphinx 3 compatibility
231# -----------------------------------
232
233# bpo-40204: Allow Sphinx 2 syntax in the C domain
234c_allow_pre_v3 = True
235
236# bpo-40204: Disable warnings on Sphinx 2 syntax of the C domain since the
237# documentation is built with -W (warnings treated as errors).
238c_warn_on_allowed_pre_v3 = False
239