conf.py

  1# -*- coding: utf-8 -*-
  2
  3# Default settings
  4project = 'Test Builds'
  5extensions = [
  6    'sphinx_autorun',
  7]
  8
  9latex_engine = 'xelatex'  # allow us to build Unicode chars
 10
 11
 12# Include all your settings here
 13html_theme = 'sphinx_rtd_theme'
 14
 15
 16
 17
 18###########################################################################
 19#          auto-created readthedocs.org specific configuration            #
 20###########################################################################
 21
 22
 23#
 24# The following code was added during an automated build on readthedocs.org
 25# It is auto created and injected for every build. The result is based on the
 26# conf.py.tmpl file found in the readthedocs.org codebase:
 27# https://github.com/rtfd/readthedocs.org/blob/main/readthedocs/doc_builder/templates/doc_builder/conf.py.tmpl
 28#
 29# Note: this file shouldn't rely on extra dependencies.
 30
 31import importlib
 32import sys
 33import os.path
 34
 35# Borrowed from six.
 36PY3 = sys.version_info[0] == 3
 37string_types = str if PY3 else basestring
 38
 39from sphinx import version_info
 40
 41# Get suffix for proper linking to GitHub
 42# This is deprecated in Sphinx 1.3+,
 43# as each page can have its own suffix
 44if globals().get('source_suffix', False):
 45    if isinstance(source_suffix, string_types):
 46        SUFFIX = source_suffix
 47    elif isinstance(source_suffix, (list, tuple)):
 48        # Sphinx >= 1.3 supports list/tuple to define multiple suffixes
 49        SUFFIX = source_suffix[0]
 50    elif isinstance(source_suffix, dict):
 51        # Sphinx >= 1.8 supports a mapping dictionary for multiple suffixes
 52        SUFFIX = list(source_suffix.keys())[0]  # make a ``list()`` for py2/py3 compatibility
 53    else:
 54        # default to .rst
 55        SUFFIX = '.rst'
 56else:
 57    SUFFIX = '.rst'
 58
 59# Add RTD Static Path. Add to the end because it overwrites previous files.
 60if not 'html_static_path' in globals():
 61    html_static_path = []
 62if os.path.exists('_static'):
 63    html_static_path.append('_static')
 64
 65# Define this variable in case it's not defined by the user.
 66# It defaults to `alabaster` which is the default from Sphinx.
 67# https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-html_theme
 68html_theme = globals().get('html_theme', 'alabaster')
 69
 70#Add project information to the template context.
 71context = {
 72    'html_theme': html_theme,
 73    'current_version': "latest",
 74    'version_slug': "latest",
 75    'MEDIA_URL': "https://media.readthedocs.org/",
 76    'STATIC_URL': "https://assets.readthedocs.org/static/",
 77    'PRODUCTION_DOMAIN': "readthedocs.org",
 78    'proxied_static_path': "/_/static/",
 79    'versions': [
 80    ("latest", "/en/latest/"),
 81    ("stable", "/en/stable/"),
 82    ("5.2", "/en/5.2/"),
 83    ("5.1", "/en/5.1/"),
 84    ("4.0", "/en/4.0/"),
 85    ],
 86    'downloads': [ 
 87    ],
 88    'subprojects': [ 
 89    ],
 90    'slug': 'test-sync-versions',
 91    'name': u'test-sync-versions',
 92    'rtd_language': u'en',
 93    'programming_language': u'words',
 94    'canonical_url': '',
 95    'analytics_code': 'None',
 96    'single_version': False,
 97    'conf_py_path': '/docs/',
 98    'api_host': 'https://readthedocs.org',
 99    'github_user': 'readthedocs',
100    'proxied_api_host': '/_',
101    'github_repo': 'test-builds',
102    'github_version': 'master',
103    'display_github': True,
104    'bitbucket_user': 'None',
105    'bitbucket_repo': 'None',
106    'bitbucket_version': 'master',
107    'display_bitbucket': False,
108    'gitlab_user': 'None',
109    'gitlab_repo': 'None',
110    'gitlab_version': 'master',
111    'display_gitlab': False,
112    'READTHEDOCS': True,
113    'using_theme': (html_theme == "default"),
114    'new_theme': (html_theme == "sphinx_rtd_theme"),
115    'source_suffix': SUFFIX,
116    'ad_free': False,
117    'docsearch_disabled': False,
118    'user_analytics_code': '',
119    'global_analytics_code': 'UA-17997319-1',
120    'commit': '88245884',
121}
122
123# For sphinx >=1.8 we can use html_baseurl to set the canonical URL.
124# https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-html_baseurl
125if version_info >= (1, 8):
126    if not globals().get('html_baseurl'):
127        html_baseurl = context['canonical_url']
128    context['canonical_url'] = None
129
130
131
132
133
134if 'html_context' in globals():
135    for key in context:
136        if key not in html_context:
137            html_context[key] = context[key]
138else:
139    html_context = context
140
141# Add custom RTD extension
142if 'extensions' in globals():
143    # Insert at the beginning because it can interfere
144    # with other extensions.
145    # See https://github.com/rtfd/readthedocs.org/pull/4054
146    extensions.insert(0, "readthedocs_ext.readthedocs")
147else:
148    extensions = ["readthedocs_ext.readthedocs"]
149
150# Add External version warning banner to the external version documentation
151if 'branch' == 'external':
152    extensions.insert(1, "readthedocs_ext.external_version_warning")
153    readthedocs_vcs_url = 'None'
154    readthedocs_build_url = 'https://readthedocs.org/projects/test-sync-versions/builds/22271572/'
155
156project_language = 'en'
157
158# User's Sphinx configurations
159language_user = globals().get('language', None)
160latex_engine_user = globals().get('latex_engine', None)
161latex_elements_user = globals().get('latex_elements', None)
162
163# Remove this once xindy gets installed in Docker image and XINDYOPS
164# env variable is supported
165# https://github.com/rtfd/readthedocs-docker-images/pull/98
166latex_use_xindy = False
167
168chinese = any([
169    language_user in ('zh_CN', 'zh_TW'),
170    project_language in ('zh_CN', 'zh_TW'),
171])
172
173japanese = any([
174    language_user == 'ja',
175    project_language == 'ja',
176])
177
178if chinese:
179    latex_engine = latex_engine_user or 'xelatex'
180
181    latex_elements_rtd = {
182        'preamble': '\\usepackage[UTF8]{ctex}\n',
183    }
184    latex_elements = latex_elements_user or latex_elements_rtd
185elif japanese:
186    latex_engine = latex_engine_user or 'platex'
187
188# Make sure our build directory is always excluded
189exclude_patterns = globals().get('exclude_patterns', [])
190exclude_patterns.extend(['_build'])