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# 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': "regular-404-page",
 94    'version_slug': "regular-404-page",
 95    'MEDIA_URL': "https://media.readthedocs.org/",
 96    'STATIC_URL': "https://assets.readthedocs.org/static/",
 97    'PRODUCTION_DOMAIN': "readthedocs.org",
 98    'proxied_static_path': "/_/static/",
 99    'versions': [
100    ("latest", "/en/latest/"),
101    ("4.0", "/en/4.0/"),
102    ("2.0", "/en/2.0/"),
103    ("yaml-v2", "/en/yaml-v2/"),
104    ("use-requirements-from-submodule", "/en/use-requirements-from-submodule/"),
105    ("use-py2", "/en/use-py2/"),
106    ("use-image-5.0rc1", "/en/use-image-5.0rc1/"),
107    ("use-apt", "/en/use-apt/"),
108    ("unicode-filename", "/en/unicode-filename/"),
109    ("d--branch", "/en/d--branch/"),
110    ("ubuntu-22.04", "/en/ubuntu-22.04/"),
111    ("typlog-theme", "/en/typlog-theme/"),
112    ("timetestlarge", "/en/timetestlarge/"),
113    ("timetest", "/en/timetest/"),
114    ("timeout", "/en/timeout/"),
115    ("throw-exception", "/en/throw-exception/"),
116    ("test-py-37", "/en/test-py-37/"),
117    ("test-pr-builder", "/en/test-pr-builder/"),
118    ("test-paths-with-spaces", "/en/test-paths-with-spaces/"),
119    ("testing-image", "/en/testing-image/"),
120    ("testing-activate-version", "/en/testing-activate-version/"),
121    ("test-code-injection-2", "/en/test-code-injection-2/"),
122    ("test-code-injection", "/en/test-code-injection/"),
123    ("test-agj-foo", "/en/test-agj-foo/"),
124    ("tag-v2", "/en/tag-v2/"),
125    ("tag-v1", "/en/tag-v1/"),
126    ("sudo-commands", "/en/sudo-commands/"),
127    ("submodule-not-found", "/en/submodule-not-found/"),
128    ("submodule-https-scheme", "/en/submodule-https-scheme/"),
129    ("submodule-git-scheme", "/en/submodule-git-scheme/"),
130    ("sphinx.yaml", "/en/sphinx.yaml/"),
131    ("sphinx-tabs", "/en/sphinx-tabs/"),
132    ("sphinx-latest", "/en/sphinx-latest/"),
133    ("sphinx-fork", "/en/sphinx-fork/"),
134    ("sphinx.ext.duration", "/en/sphinx.ext.duration/"),
135    ("sphinx-es-suggest", "/en/sphinx-es-suggest/"),
136    ("sphinx-5.x", "/en/sphinx-5.x/"),
137    ("sphinx-3.x", "/en/sphinx-3.x/"),
138    ("sphinx2", "/en/sphinx2/"),
139    ("sphinx-1.8", "/en/sphinx-1.8/"),
140    ("sphinx-1.7", "/en/sphinx-1.7/"),
141    ("sphinx-1.6", "/en/sphinx-1.6/"),
142    ("search-with-old-sphinx-and-theme", "/en/search-with-old-sphinx-and-theme/"),
143    ("rust", "/en/rust/"),
144    ("run-rust", "/en/run-rust/"),
145    ("rtd-sphinx-ext", "/en/rtd-sphinx-ext/"),
146    ("robots-txt", "/en/robots-txt/"),
147    ("requirements-not-found", "/en/requirements-not-found/"),
148    ("regular-404-page", "/en/regular-404-page/"),
149    ("pypy3.5", "/en/pypy3.5/"),
150    ("pygments-custom-lexer-apex", "/en/pygments-custom-lexer-apex/"),
151    ("py3.9", "/en/py3.9/"),
152    ("py3.8", "/en/py3.8/"),
153    ("py3.5", "/en/py3.5/"),
154    ("py3.11", "/en/py3.11/"),
155    ("py3.10", "/en/py3.10/"),
156    ("pr-visual-diff", "/en/pr-visual-diff/"),
157    ("poetry-asdf", "/en/poetry-asdf/"),
158    ("poetry", "/en/poetry/"),
159    ("pelican", "/en/pelican/"),
160    ("path-with-plus", "/en/path-with-plus/"),
161    ("no-config-file", "/en/no-config-file/"),
162    ("nbsphinx-3d-plot", "/en/nbsphinx-3d-plot/"),
163    ("multiple-source-suffix", "/en/multiple-source-suffix/"),
164    ("meta-tags", "/en/meta-tags/"),
165    ("mamba", "/en/mamba/"),
166    ("main", "/en/main/"),
167    ("jsdoc-autoapi", "/en/jsdoc-autoapi/"),
168    ("jsdoc", "/en/jsdoc/"),
169    ("japanese-pdf", "/en/japanese-pdf/"),
170    ("invalid-submodules", "/en/invalid-submodules/"),
171    ("install-pytorch", "/en/install-pytorch/"),
172    ("install-aiohttp", "/en/install-aiohttp/"),
173    ("image", "/en/image/"),
174    ("huge-build-output", "/en/huge-build-output/"),
175    ("hide-me", "/en/hide-me/"),
176    ("git-submodules-invalid", "/en/git-submodules-invalid/"),
177    ("git-submodules", "/en/git-submodules/"),
178    ("git-lfs-build-jobs", "/en/git-lfs-build-jobs/"),
179    ("git-lfs", "/en/git-lfs/"),
180    ("file-with-apostrophe", "/en/file-with-apostrophe/"),
181    ("expose-env-pip-error", "/en/expose-env-pip-error/"),
182    ("explicit-flyout-placement", "/en/explicit-flyout-placement/"),
183    ("environment-variables", "/en/environment-variables/"),
184    ("docsify-ads", "/en/docsify-ads/"),
185    ("docsify", "/en/docsify/"),
186    ("datetime", "/en/datetime/"),
187    ("custom-404-page", "/en/custom-404-page/"),
188    ("conda-satisfied-skip-solve", "/en/conda-satisfied-skip-solve/"),
189    ("conda-pin-common-deps", "/en/conda-pin-common-deps/"),
190    ("conda-env-py3.7", "/en/conda-env-py3.7/"),
191    ("conda-env-no-py-pinned", "/en/conda-env-no-py-pinned/"),
192    ("conda-env", "/en/conda-env/"),
193    ("code-injection-3", "/en/code-injection-3/"),
194    ("c-dependencies", "/en/c-dependencies/"),
195    ("build-tools-update-2", "/en/build-tools-update-2/"),
196    ("build-tools-mamba", "/en/build-tools-mamba/"),
197    ("build-tools-conda", "/en/build-tools-conda/"),
198    ("build-tools", "/en/build-tools/"),
199    ("build-os-error-message", "/en/build-os-error-message/"),
200    ("build-jobs-spaces-in-command", "/en/build-jobs-spaces-in-command/"),
201    ("build-jobs-multiline", "/en/build-jobs-multiline/"),
202    ("build-jobs", "/en/build-jobs/"),
203    ("build-internals", "/en/build-internals/"),
204    ("build-commands-env-vars", "/en/build-commands-env-vars/"),
205    ("build-commands", "/en/build-commands/"),
206    ("be-default", "/en/be-default/"),
207    ("another-matching-branch", "/en/another-matching-branch/"),
208    ("annotated-tag", "/en/annotated-tag/"),
209    ("all-formats", "/en/all-formats/"),
210    ("alabaster-theme", "/en/alabaster-theme/"),
211    ("agj-test-pr", "/en/agj-test-pr/"),
212    ("agj-rtd-tf-example", "/en/agj-rtd-tf-example/"),
213    ],
214    'downloads': [ 
215    ],
216    'subprojects': [ 
217    ],
218    'slug': 'test-builds',
219    'name': u'test-builds',
220    'rtd_language': u'en',
221    'programming_language': u'words',
222    'canonical_url': 'https://test-builds.readthedocs.io/en/latest/',
223    'analytics_code': 'UA-12341234-1',
224    'single_version': False,
225    'conf_py_path': '/docs/',
226    'api_host': 'https://readthedocs.org',
227    'github_user': 'readthedocs',
228    'proxied_api_host': '/_',
229    'github_repo': 'test-builds',
230    'github_version': 'regular-404-page',
231    'display_github': True,
232    'bitbucket_user': 'None',
233    'bitbucket_repo': 'None',
234    'bitbucket_version': 'regular-404-page',
235    'display_bitbucket': False,
236    'gitlab_user': 'None',
237    'gitlab_repo': 'None',
238    'gitlab_version': 'regular-404-page',
239    'display_gitlab': False,
240    'READTHEDOCS': True,
241    'using_theme': (html_theme == "default"),
242    'new_theme': (html_theme == "sphinx_rtd_theme"),
243    'source_suffix': SUFFIX,
244    'ad_free': False,
245    'docsearch_disabled': False,
246    'user_analytics_code': 'UA-12341234-1',
247    'global_analytics_code': None,
248    'commit': '2e12660b',
249}
250
251# For sphinx >=1.8 we can use html_baseurl to set the canonical URL.
252# https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-html_baseurl
253if version_info >= (1, 8):
254    if not globals().get('html_baseurl'):
255        html_baseurl = context['canonical_url']
256    context['canonical_url'] = None
257
258
259
260
261
262if 'html_context' in globals():
263    
264    html_context.update(context)
265    
266else:
267    html_context = context
268
269# Add custom RTD extension
270if 'extensions' in globals():
271    # Insert at the beginning because it can interfere
272    # with other extensions.
273    # See https://github.com/rtfd/readthedocs.org/pull/4054
274    extensions.insert(0, "readthedocs_ext.readthedocs")
275else:
276    extensions = ["readthedocs_ext.readthedocs"]
277
278# Add External version warning banner to the external version documentation
279if 'branch' == 'external':
280    extensions.insert(1, "readthedocs_ext.external_version_warning")
281    readthedocs_vcs_url = 'None'
282    readthedocs_build_url = 'https://readthedocs.org/projects/test-builds/builds/17925757/'
283
284project_language = 'en'
285
286# User's Sphinx configurations
287language_user = globals().get('language', None)
288latex_engine_user = globals().get('latex_engine', None)
289latex_elements_user = globals().get('latex_elements', None)
290
291# Remove this once xindy gets installed in Docker image and XINDYOPS
292# env variable is supported
293# https://github.com/rtfd/readthedocs-docker-images/pull/98
294latex_use_xindy = False
295
296chinese = any([
297    language_user in ('zh_CN', 'zh_TW'),
298    project_language in ('zh_CN', 'zh_TW'),
299])
300
301japanese = any([
302    language_user == 'ja',
303    project_language == 'ja',
304])
305
306if chinese:
307    latex_engine = latex_engine_user or 'xelatex'
308
309    latex_elements_rtd = {
310        'preamble': '\\usepackage[UTF8]{ctex}\n',
311    }
312    latex_elements = latex_elements_user or latex_elements_rtd
313elif japanese:
314    latex_engine = latex_engine_user or 'platex'
315
316# Make sure our build directory is always excluded
317exclude_patterns = globals().get('exclude_patterns', [])
318exclude_patterns.extend(['_build'])