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/master/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# Add RTD Theme only if they aren't overriding it already
 66using_rtd_theme = (
 67    (
 68        'html_theme' in globals() and
 69        html_theme in ['default'] and
 70        # Allow people to bail with a hack of having an html_style
 71        'html_style' not in globals()
 72    ) or 'html_theme' not in globals()
 73)
 74if using_rtd_theme:
 75    theme = importlib.import_module('sphinx_rtd_theme')
 76    html_theme = 'sphinx_rtd_theme'
 77    html_style = None
 78    html_theme_options = {}
 79    if 'html_theme_path' in globals():
 80        html_theme_path.append(theme.get_html_theme_path())
 81    else:
 82        html_theme_path = [theme.get_html_theme_path()]
 83
 84if globals().get('websupport2_base_url', False):
 85    websupport2_base_url = 'https://readthedocs.org/websupport'
 86    websupport2_static_url = 'https://assets.readthedocs.org/static/'
 87
 88
 89#Add project information to the template context.
 90context = {
 91    'using_theme': using_rtd_theme,
 92    'html_theme': html_theme,
 93    'current_version': "5.2",
 94    'version_slug': "5.2",
 95    'MEDIA_URL': "https://media.readthedocs.org/",
 96    'STATIC_URL': "https://assets.readthedocs.org/static/",
 97    'PRODUCTION_DOMAIN': "readthedocs.org",
 98    'versions': [
 99    ("latest", "/en/latest/"),
100    ("stable", "/en/stable/"),
101    ("5.2", "/en/5.2/"),
102    ("5.1", "/en/5.1/"),
103    ("4.0", "/en/4.0/"),
104    ],
105    'downloads': [ 
106    ],
107    'subprojects': [ 
108    ],
109    'slug': 'test-sync-versions',
110    'name': u'test-sync-versions',
111    'rtd_language': u'en',
112    'programming_language': u'words',
113    'canonical_url': 'https://test-sync-versions.readthedocs.io/en/latest/',
114    'analytics_code': 'None',
115    'single_version': False,
116    'conf_py_path': '/docs/',
117    'api_host': 'https://readthedocs.org',
118    'github_user': 'readthedocs',
119    'proxied_api_host': '/_',
120    'github_repo': 'test-builds',
121    'github_version': '5.2',
122    'display_github': True,
123    'bitbucket_user': 'None',
124    'bitbucket_repo': 'None',
125    'bitbucket_version': '5.2',
126    'display_bitbucket': False,
127    'gitlab_user': 'None',
128    'gitlab_repo': 'None',
129    'gitlab_version': '5.2',
130    'display_gitlab': False,
131    'READTHEDOCS': True,
132    'using_theme': (html_theme == "default"),
133    'new_theme': (html_theme == "sphinx_rtd_theme"),
134    'source_suffix': SUFFIX,
135    'ad_free': False,
136    'docsearch_disabled': False,
137    'user_analytics_code': '',
138    'global_analytics_code': 'UA-17997319-1',
139    'commit': 'bbfc9916',
140}
141
142# For sphinx >=1.8 we can use html_baseurl to set the canonical URL.
143# https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-html_baseurl
144if version_info >= (1, 8):
145    if not globals().get('html_baseurl'):
146        html_baseurl = context['canonical_url']
147    context['canonical_url'] = None
148
149
150
151
152
153if 'html_context' in globals():
154    
155    html_context.update(context)
156    
157else:
158    html_context = context
159
160# Add custom RTD extension
161if 'extensions' in globals():
162    # Insert at the beginning because it can interfere
163    # with other extensions.
164    # See https://github.com/rtfd/readthedocs.org/pull/4054
165    extensions.insert(0, "readthedocs_ext.readthedocs")
166else:
167    extensions = ["readthedocs_ext.readthedocs"]
168
169# Add External version warning banner to the external version documentation
170if 'tag' == 'external':
171    extensions.insert(1, "readthedocs_ext.external_version_warning")
172    readthedocs_vcs_url = 'None'
173    readthedocs_build_url = 'https://readthedocs.org/projects/test-sync-versions/builds/16366633/'
174
175project_language = 'en'
176
177# User's Sphinx configurations
178language_user = globals().get('language', None)
179latex_engine_user = globals().get('latex_engine', None)
180latex_elements_user = globals().get('latex_elements', None)
181
182# Remove this once xindy gets installed in Docker image and XINDYOPS
183# env variable is supported
184# https://github.com/rtfd/readthedocs-docker-images/pull/98
185latex_use_xindy = False
186
187chinese = any([
188    language_user in ('zh_CN', 'zh_TW'),
189    project_language in ('zh_CN', 'zh_TW'),
190])
191
192japanese = any([
193    language_user == 'ja',
194    project_language == 'ja',
195])
196
197if chinese:
198    latex_engine = latex_engine_user or 'xelatex'
199
200    latex_elements_rtd = {
201        'preamble': '\\usepackage[UTF8]{ctex}\n',
202    }
203    latex_elements = latex_elements_user or latex_elements_rtd
204elif japanese:
205    latex_engine = latex_engine_user or 'platex'
206
207# Make sure our build directory is always excluded
208exclude_patterns = globals().get('exclude_patterns', [])
209exclude_patterns.extend(['_build'])