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    ],
 83    'downloads': [ 
 84    ],
 85    'subprojects': [ 
 86    ],
 87    'slug': 'rtd-staticfiles',
 88    'name': u'staticfile',
 89    'rtd_language': u'en',
 90    'programming_language': u'words',
 91    'canonical_url': '',
 92    'analytics_code': 'None',
 93    'single_version': False,
 94    'conf_py_path': '/docs/',
 95    'api_host': 'https://readthedocs.org',
 96    'github_user': 'readthedocs',
 97    'proxied_api_host': '/_',
 98    'github_repo': 'test-builds',
 99    'github_version': 'main',
100    'display_github': True,
101    'bitbucket_user': 'None',
102    'bitbucket_repo': 'None',
103    'bitbucket_version': 'main',
104    'display_bitbucket': False,
105    'gitlab_user': 'None',
106    'gitlab_repo': 'None',
107    'gitlab_version': 'main',
108    'display_gitlab': False,
109    'READTHEDOCS': True,
110    'using_theme': (html_theme == "default"),
111    'new_theme': (html_theme == "sphinx_rtd_theme"),
112    'source_suffix': SUFFIX,
113    'ad_free': False,
114    'docsearch_disabled': False,
115    'user_analytics_code': '',
116    'global_analytics_code': 'UA-17997319-1',
117    'commit': '88245884',
118}
119
120# For sphinx >=1.8 we can use html_baseurl to set the canonical URL.
121# https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-html_baseurl
122if version_info >= (1, 8):
123    if not globals().get('html_baseurl'):
124        html_baseurl = context['canonical_url']
125    context['canonical_url'] = None
126
127
128
129
130
131if 'html_context' in globals():
132    for key in context:
133        if key not in html_context:
134            html_context[key] = context[key]
135else:
136    html_context = context
137
138# Add custom RTD extension
139if 'extensions' in globals():
140    # Insert at the beginning because it can interfere
141    # with other extensions.
142    # See https://github.com/rtfd/readthedocs.org/pull/4054
143    extensions.insert(0, "readthedocs_ext.readthedocs")
144else:
145    extensions = ["readthedocs_ext.readthedocs"]
146
147# Add External version warning banner to the external version documentation
148if 'branch' == 'external':
149    extensions.insert(1, "readthedocs_ext.external_version_warning")
150    readthedocs_vcs_url = 'None'
151    readthedocs_build_url = 'https://readthedocs.org/projects/rtd-staticfiles/builds/22271574/'
152
153project_language = 'en'
154
155# User's Sphinx configurations
156language_user = globals().get('language', None)
157latex_engine_user = globals().get('latex_engine', None)
158latex_elements_user = globals().get('latex_elements', None)
159
160# Remove this once xindy gets installed in Docker image and XINDYOPS
161# env variable is supported
162# https://github.com/rtfd/readthedocs-docker-images/pull/98
163latex_use_xindy = False
164
165chinese = any([
166    language_user in ('zh_CN', 'zh_TW'),
167    project_language in ('zh_CN', 'zh_TW'),
168])
169
170japanese = any([
171    language_user == 'ja',
172    project_language == 'ja',
173])
174
175if chinese:
176    latex_engine = latex_engine_user or 'xelatex'
177
178    latex_elements_rtd = {
179        'preamble': '\\usepackage[UTF8]{ctex}\n',
180    }
181    latex_elements = latex_elements_user or latex_elements_rtd
182elif japanese:
183    latex_engine = latex_engine_user or 'platex'
184
185# Make sure our build directory is always excluded
186exclude_patterns = globals().get('exclude_patterns', [])
187exclude_patterns.extend(['_build'])