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 'asdl_highlight', 'peg_highlight'] 19 20 21doctest_global_setup = ''' 22try: 23 import _tkinter 24except ImportError: 25 _tkinter = None 26''' 27 28manpages_url = 'https://manpages.debian.org/{path}' 29 30# General substitutions. 31project = 'Python' 32copyright = '2001-%s, Python Software Foundation' % time.strftime('%Y') 33 34# 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() 38 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 45# By default, highlight as Python 3. 46highlight_language = 'python3' 47 48# Minimum version of sphinx required 49needs_sphinx = '1.8' 50 51# Ignore any .rst files in the venv/ directory. 52exclude_patterns = ['venv/*', 'README.rst'] 53venvdir = os.getenv('VENVDIR') 54if venvdir is not None: 55 exclude_patterns.append(venvdir + '/*') 56 57# Disable Docutils smartquotes for several translations 58smartquotes_excludes = { 59 'languages': ['ja', 'fr', 'zh_TW', 'zh_CN'], 'builders': ['man', 'text'], 60} 61 62# Avoid a warning with Sphinx >= 2.0 63master_doc = 'contents' 64 65# Options for HTML output 66# ----------------------- 67 68# Use our custom theme. 69html_theme = 'python_docs_theme' 70html_theme_path = ['tools'] 71html_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} 76 77# Short title used e.g. for <title> HTML tags. 78html_short_title = '%s Documentation' % release 79 80# 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 84# Path to find HTML templates. 85templates_path = ['tools/templates'] 86 87# Custom sidebar templates, filenames relative to this file. 88html_sidebars = { 89 # Defaults taken from https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-html_sidebars 90 # Removes the quick search block 91 '**': ['localtoc.html', 'relations.html', 'customsourcelink.html'], 92 'index': ['indexsidebar.html'], 93} 94 95# Additional templates that should be rendered to pages. 96html_additional_pages = { 97 'download': 'download.html', 98 'index': 'indexcontent.html', 99} 100 101# Output an OpenSearch description file. 102html_use_opensearch = 'https://docs.python.org/' + version 103 104# Additional static files. 105html_static_path = ['tools/static'] 106 107# Output file base name for HTML help builder. 108htmlhelp_basename = 'python' + release.replace('.', '') 109 110# Split the index 111html_split_index = True 112 113 114# Options for LaTeX output 115# ------------------------ 116 117latex_engine = 'xelatex' 118 119# Get LaTeX to handle Unicode correctly 120latex_elements = { 121} 122 123# Additional stuff for the LaTeX preamble. 124latex_elements['preamble'] = r''' 125\authoraddress{ 126 \sphinxstrong{Python Software Foundation}\\ 127 Email: \sphinxemail{docs@python.org} 128} 129\let\Verbatim=\OriginalVerbatim 130\let\endVerbatim=\endOriginalVerbatim 131\setcounter{tocdepth}{2} 132''' 133 134# The paper size ('letter' or 'a4'). 135latex_elements['papersize'] = 'a4' 136 137# The font size ('10pt', '11pt' or '12pt'). 138latex_elements['pointsize'] = '10pt' 139 140# Grouping the document tree into LaTeX files. List of tuples 141# (source start file, target name, title, author, document class [howto/manual]). 142_stdauthor = r'Guido van Rossum\\and the Python development team' 143latex_documents = [ 144 ('c-api/index', 'c-api.tex', 145 'The Python/C API', _stdauthor, 'manual'), 146 ('distributing/index', 'distributing.tex', 147 'Distributing Python Modules', _stdauthor, 'manual'), 148 ('extending/index', 'extending.tex', 149 'Extending and Embedding Python', _stdauthor, 'manual'), 150 ('installing/index', 'installing.tex', 151 'Installing Python Modules', _stdauthor, 'manual'), 152 ('library/index', 'library.tex', 153 'The Python Library Reference', _stdauthor, 'manual'), 154 ('reference/index', 'reference.tex', 155 'The Python Language Reference', _stdauthor, 'manual'), 156 ('tutorial/index', 'tutorial.tex', 157 'Python Tutorial', _stdauthor, 'manual'), 158 ('using/index', 'using.tex', 159 'Python Setup and Usage', _stdauthor, 'manual'), 160 ('faq/index', 'faq.tex', 161 'Python Frequently Asked Questions', _stdauthor, 'manual'), 162 ('whatsnew/' + version, 'whatsnew.tex', 163 'What\'s New in Python', 'A. M. Kuchling', 'howto'), 164] 165# Collect all HOWTOs individually 166latex_documents.extend(('howto/' + fn[:-4], 'howto-' + fn[:-4] + '.tex', 167 '', _stdauthor, 'howto') 168 for fn in os.listdir('howto') 169 if fn.endswith('.rst') and fn != 'index.rst') 170 171# Documents to append as an appendix to all manuals. 172latex_appendices = ['glossary', 'about', 'license', 'copyright'] 173 174# Options for Epub output 175# ----------------------- 176 177epub_author = 'Python Documentation Authors' 178epub_publisher = 'Python Software Foundation' 179 180# 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} 215 216 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 226# Options for extensions 227# ---------------------- 228 229# Relative filename of the reference count data file. 230refcount_file = 'data/refcounts.dat' 231 232# Sphinx 2 and Sphinx 3 compatibility 233# ----------------------------------- 234 235# bpo-40204: Allow Sphinx 2 syntax in the C domain 236c_allow_pre_v3 = True 237 238# bpo-40204: Disable warnings on Sphinx 2 syntax of the C domain since the 239# documentation is built with -W (warnings treated as errors). 240c_warn_on_allowed_pre_v3 = False 241