conf.py

  1# -*- coding: utf-8 -*-
  2
  3# Default settings
  4project = 'Test Builds'
  5extensions = [
  6    'sphinx_autorun',
  7    'notfound.extension',
  8]
  9
 10latex_engine = 'xelatex'  # allow us to build Unicode chars
 11
 12
 13# Include all your settings here
 14html_theme = 'sphinx_rtd_theme'
 15
 16
 17
 18
 19###########################################################################
 20#          auto-created readthedocs.org specific configuration            #
 21###########################################################################
 22
 23
 24#
 25# The following code was added during an automated build on readthedocs.org
 26# It is auto created and injected for every build. The result is based on the
 27# conf.py.tmpl file found in the readthedocs.org codebase:
 28# https://github.com/rtfd/readthedocs.org/blob/main/readthedocs/doc_builder/templates/doc_builder/conf.py.tmpl
 29#
 30# Note: this file shouldn't rely on extra dependencies.
 31
 32import importlib
 33import sys
 34import os.path
 35
 36# Borrowed from six.
 37PY3 = sys.version_info[0] == 3
 38string_types = str if PY3 else basestring
 39
 40from sphinx import version_info
 41
 42# Get suffix for proper linking to GitHub
 43# This is deprecated in Sphinx 1.3+,
 44# as each page can have its own suffix
 45if globals().get('source_suffix', False):
 46    if isinstance(source_suffix, string_types):
 47        SUFFIX = source_suffix
 48    elif isinstance(source_suffix, (list, tuple)):
 49        # Sphinx >= 1.3 supports list/tuple to define multiple suffixes
 50        SUFFIX = source_suffix[0]
 51    elif isinstance(source_suffix, dict):
 52        # Sphinx >= 1.8 supports a mapping dictionary for multiple suffixes
 53        SUFFIX = list(source_suffix.keys())[0]  # make a ``list()`` for py2/py3 compatibility
 54    else:
 55        # default to .rst
 56        SUFFIX = '.rst'
 57else:
 58    SUFFIX = '.rst'
 59
 60# Add RTD Static Path. Add to the end because it overwrites previous files.
 61if not 'html_static_path' in globals():
 62    html_static_path = []
 63if os.path.exists('_static'):
 64    html_static_path.append('_static')
 65
 66# Define this variable in case it's not defined by the user.
 67# It defaults to `alabaster` which is the default from Sphinx.
 68# https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-html_theme
 69html_theme = globals().get('html_theme', 'alabaster')
 70
 71#Add project information to the template context.
 72context = {
 73    'html_theme': html_theme,
 74    'current_version': "custom-404-page",
 75    'version_slug': "custom-404-page",
 76    'MEDIA_URL': "https://media.readthedocs.org/",
 77    'STATIC_URL': "https://assets.readthedocs.org/static/",
 78    'PRODUCTION_DOMAIN': "readthedocs.org",
 79    'proxied_static_path': "/_/static/",
 80    'versions': [
 81    ("latest", "/en/latest/"),
 82    ("stable", "/en/stable/"),
 83    ("4.0", "/en/4.0/"),
 84    ("2.0", "/en/2.0/"),
 85    ("yaml-v2", "/en/yaml-v2/"),
 86    ("wormhole", "/en/wormhole/"),
 87    ("use-requirements-from-submodule", "/en/use-requirements-from-submodule/"),
 88    ("use-py2", "/en/use-py2/"),
 89    ("use-apt", "/en/use-apt/"),
 90    ("update-conda-startup", "/en/update-conda-startup/"),
 91    ("unicode-filename", "/en/unicode-filename/"),
 92    ("d--branch", "/en/d--branch/"),
 93    ("ubuntu-22.04", "/en/ubuntu-22.04/"),
 94    ("ubuntu-20.04-python-3.9", "/en/ubuntu-20.04-python-3.9/"),
 95    ("ubuntu-20.04", "/en/ubuntu-20.04/"),
 96    ("typlog-theme", "/en/typlog-theme/"),
 97    ("timetestlarge", "/en/timetestlarge/"),
 98    ("timetest", "/en/timetest/"),
 99    ("timeout", "/en/timeout/"),
100    ("throw-exception", "/en/throw-exception/"),
101    ("test-ubuntu-20.04", "/en/test-ubuntu-20.04/"),
102    ("test-paths-with-spaces", "/en/test-paths-with-spaces/"),
103    ("test-parent-path-error", "/en/test-parent-path-error/"),
104    ("testing-activate-version", "/en/testing-activate-version/"),
105    ("test-auto-cancel", "/en/test-auto-cancel/"),
106    ("template-config-file", "/en/template-config-file/"),
107    ("sudo-commands", "/en/sudo-commands/"),
108    ("submodule-not-found", "/en/submodule-not-found/"),
109    ("submodule-https-scheme", "/en/submodule-https-scheme/"),
110    ("submodule-git-scheme", "/en/submodule-git-scheme/"),
111    ("staticrypt", "/en/staticrypt/"),
112    ("sphinx-tectonic-pdf", "/en/sphinx-tectonic-pdf/"),
113    ("sphinx-tabs", "/en/sphinx-tabs/"),
114    ("sphinx-multipage-html", "/en/sphinx-multipage-html/"),
115    ("sphinx-mkdocstrings", "/en/sphinx-mkdocstrings/"),
116    ("sphinx-latest", "/en/sphinx-latest/"),
117    ("sphinx-hoverxref", "/en/sphinx-hoverxref/"),
118    ("sphinx.ext.duration", "/en/sphinx.ext.duration/"),
119    ("sphinx-es-suggest", "/en/sphinx-es-suggest/"),
120    ("sphinx-docs-zundler", "/en/sphinx-docs-zundler/"),
121    ("sphinx-conf-nonstandard", "/en/sphinx-conf-nonstandard/"),
122    ("sphinx-awesome", "/en/sphinx-awesome/"),
123    ("sphinx-7.0.x", "/en/sphinx-7.0.x/"),
124    ("sphinx6.x-default", "/en/sphinx6.x-default/"),
125    ("sphinx5.x-default-confpy", "/en/sphinx5.x-default-confpy/"),
126    ("sphinx-5.x", "/en/sphinx-5.x/"),
127    ("sphinx-1.8", "/en/sphinx-1.8/"),
128    ("skip-build-command-pr-test3", "/en/skip-build-command-pr-test3/"),
129    ("skip-build-command-pr-test2", "/en/skip-build-command-pr-test2/"),
130    ("skip-build-command", "/en/skip-build-command/"),
131    ("singlehtml", "/en/singlehtml/"),
132    ("shot-scraper", "/en/shot-scraper/"),
133    ("search-with-old-sphinx-and-theme", "/en/search-with-old-sphinx-and-theme/"),
134    ("search-special-chars", "/en/search-special-chars/"),
135    ("rust-1.70", "/en/rust-1.70/"),
136    ("rust", "/en/rust/"),
137    ("robots-txt", "/en/robots-txt/"),
138    ("requirements-not-found", "/en/requirements-not-found/"),
139    ("regular-404-page", "/en/regular-404-page/"),
140    ("recommonmark", "/en/recommonmark/"),
141    ("readthedocs-docs-build-commands", "/en/readthedocs-docs-build-commands/"),
142    ("python-system-packages", "/en/python-system-packages/"),
143    ("python-setuptools-package", "/en/python-setuptools-package/"),
144    ("pypy3.5", "/en/pypy3.5/"),
145    ("pygments-custom-lexer-apex", "/en/pygments-custom-lexer-apex/"),
146    ("py3.9", "/en/py3.9/"),
147    ("py3.8", "/en/py3.8/"),
148    ("py3.11", "/en/py3.11/"),
149    ("py3.10", "/en/py3.10/"),
150    ("pr-visual-diff", "/en/pr-visual-diff/"),
151    ("pr-test-git-clone-test", "/en/pr-test-git-clone-test/"),
152    ("pr-test", "/en/pr-test/"),
153    ("pr-readthedocs_output", "/en/pr-readthedocs_output/"),
154    ("pr-js-client", "/en/pr-js-client/"),
155    ("pr-homepage-edition", "/en/pr-homepage-edition/"),
156    ("pr-docusaurus", "/en/pr-docusaurus/"),
157    ("poetry-asdf", "/en/poetry-asdf/"),
158    ("poetry", "/en/poetry/"),
159    ("pelican", "/en/pelican/"),
160    ("pdf-rinohtype", "/en/pdf-rinohtype/"),
161    ("pdf-cmd-fail", "/en/pdf-cmd-fail/"),
162    ("pdf-build-jobs", "/en/pdf-build-jobs/"),
163    ("old-output-directory", "/en/old-output-directory/"),
164    ("no-pr-build", "/en/no-pr-build/"),
165    ("no-html-theme-defined", "/en/no-html-theme-defined/"),
166    ("no-conf-py", "/en/no-conf-py/"),
167    ("no-config-file", "/en/no-config-file/"),
168    ("nbsphinx-3d-plot", "/en/nbsphinx-3d-plot/"),
169    ("multiple-source-suffix", "/en/multiple-source-suffix/"),
170    ("monorepo", "/en/monorepo/"),
171    ("mkdocs-python-tags", "/en/mkdocs-python-tags/"),
172    ("mkdocs-pdf", "/en/mkdocs-pdf/"),
173    ("mkdocs-material", "/en/mkdocs-material/"),
174    ("mkdocs-htmlzip", "/en/mkdocs-htmlzip/"),
175    ("mkdocs-config-at-root", "/en/mkdocs-config-at-root/"),
176    ("mkdocs", "/en/mkdocs/"),
177    ("meta-tags", "/en/meta-tags/"),
178    ("manual-integrations", "/en/manual-integrations/"),
179    ("manual-integration-docsify", "/en/manual-integration-docsify/"),
180    ("mamba", "/en/mamba/"),
181    ("jupyter-book", "/en/jupyter-book/"),
182    ("jsdoc-autoapi", "/en/jsdoc-autoapi/"),
183    ("jsdoc", "/en/jsdoc/"),
184    ("japanese-pdf", "/en/japanese-pdf/"),
185    ("invalid-submodules", "/en/invalid-submodules/"),
186    ("invalid-docker-image", "/en/invalid-docker-image/"),
187    ("install-setuptools", "/en/install-setuptools/"),
188    ("humitos-patch-2", "/en/humitos-patch-2/"),
189    ("huge-build-output", "/en/huge-build-output/"),
190    ("htmldir", "/en/htmldir/"),
191    ("git-submodules-invalid", "/en/git-submodules-invalid/"),
192    ("git-submodules", "/en/git-submodules/"),
193    ("git-lfs-build-jobs", "/en/git-lfs-build-jobs/"),
194    ("furo", "/en/furo/"),
195    ("file-with-apostrophe", "/en/file-with-apostrophe/"),
196    ("expose-env-pip-error", "/en/expose-env-pip-error/"),
197    ("explicit-flyout-placement", "/en/explicit-flyout-placement/"),
198    ("envvar-config-file", "/en/envvar-config-file/"),
199    ("environment-variables", "/en/environment-variables/"),
200    ("docusaurus", "/en/docusaurus/"),
201    ("docsify-ads", "/en/docsify-ads/"),
202    ("docsify", "/en/docsify/"),
203    ("datetime", "/en/datetime/"),
204    ("d2lbook", "/en/d2lbook/"),
205    ("custom-404-page", "/en/custom-404-page/"),
206    ("conda-pin-common-deps", "/en/conda-pin-common-deps/"),
207    ("conda-env-py3.7", "/en/conda-env-py3.7/"),
208    ("conda-env-no-py-pinned", "/en/conda-env-no-py-pinned/"),
209    ("conda-env", "/en/conda-env/"),
210    ("c-dependencies", "/en/c-dependencies/"),
211    ("build-tools-mamba", "/en/build-tools-mamba/"),
212    ("build-tools-conda", "/en/build-tools-conda/"),
213    ("build-tools", "/en/build-tools/"),
214    ("build-os-error-message", "/en/build-os-error-message/"),
215    ("build-latest-python-3.8", "/en/build-latest-python-3.8/"),
216    ("build-jobs-spaces-in-command", "/en/build-jobs-spaces-in-command/"),
217    ("build-jobs-post-build", "/en/build-jobs-post-build/"),
218    ("build-jobs-multiline", "/en/build-jobs-multiline/"),
219    ("build-jobs-diff-exit", "/en/build-jobs-diff-exit/"),
220    ("build-jobs", "/en/build-jobs/"),
221    ("build-internals", "/en/build-internals/"),
222    ("build-image", "/en/build-image/"),
223    ("build-commands-multiline", "/en/build-commands-multiline/"),
224    ("build-commands-env-vars", "/en/build-commands-env-vars/"),
225    ("build-commands", "/en/build-commands/"),
226    ("branch-with-slashes", "/en/branch-with-slashes/"),
227    ("bare-commands", "/en/bare-commands/"),
228    ("another-matching-branch", "/en/another-matching-branch/"),
229    ("annotated-tag", "/en/annotated-tag/"),
230    ("all-formats-build-jobs", "/en/all-formats-build-jobs/"),
231    ("all-formats-build-commands", "/en/all-formats-build-commands/"),
232    ("all-formats", "/en/all-formats/"),
233    ("alabaster-theme", "/en/alabaster-theme/"),
234    ],
235    'downloads': [ 
236    ],
237    'subprojects': [ 
238    ],
239    'slug': 'test-builds',
240    'name': u'test-builds',
241    'rtd_language': u'en',
242    'programming_language': u'words',
243    'canonical_url': '',
244    'analytics_code': 'UA-12341234-1',
245    'single_version': False,
246    'conf_py_path': '/docs/',
247    'api_host': 'https://readthedocs.org',
248    'github_user': 'readthedocs',
249    'proxied_api_host': '/_',
250    'github_repo': 'test-builds',
251    'github_version': 'custom-404-page',
252    'display_github': True,
253    'bitbucket_user': 'None',
254    'bitbucket_repo': 'None',
255    'bitbucket_version': 'custom-404-page',
256    'display_bitbucket': False,
257    'gitlab_user': 'None',
258    'gitlab_repo': 'None',
259    'gitlab_version': 'custom-404-page',
260    'display_gitlab': False,
261    'READTHEDOCS': True,
262    'using_theme': (html_theme == "default"),
263    'new_theme': (html_theme == "sphinx_rtd_theme"),
264    'source_suffix': SUFFIX,
265    'ad_free': False,
266    'docsearch_disabled': False,
267    'user_analytics_code': 'UA-12341234-1',
268    'global_analytics_code': None,
269    'commit': '866fe945',
270}
271
272# For sphinx >=1.8 we can use html_baseurl to set the canonical URL.
273# https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-html_baseurl
274if version_info >= (1, 8):
275    if not globals().get('html_baseurl'):
276        html_baseurl = context['canonical_url']
277    context['canonical_url'] = None
278
279
280
281
282
283if 'html_context' in globals():
284    for key in context:
285        if key not in html_context:
286            html_context[key] = context[key]
287else:
288    html_context = context
289
290# Add custom RTD extension
291if 'extensions' in globals():
292    # Insert at the beginning because it can interfere
293    # with other extensions.
294    # See https://github.com/rtfd/readthedocs.org/pull/4054
295    extensions.insert(0, "readthedocs_ext.readthedocs")
296else:
297    extensions = ["readthedocs_ext.readthedocs"]
298
299# Add External version warning banner to the external version documentation
300if 'branch' == 'external':
301    extensions.insert(1, "readthedocs_ext.external_version_warning")
302    readthedocs_vcs_url = 'None'
303    readthedocs_build_url = 'https://readthedocs.org/projects/test-builds/builds/21970889/'
304
305project_language = 'en'
306
307# User's Sphinx configurations
308language_user = globals().get('language', None)
309latex_engine_user = globals().get('latex_engine', None)
310latex_elements_user = globals().get('latex_elements', None)
311
312# Remove this once xindy gets installed in Docker image and XINDYOPS
313# env variable is supported
314# https://github.com/rtfd/readthedocs-docker-images/pull/98
315latex_use_xindy = False
316
317chinese = any([
318    language_user in ('zh_CN', 'zh_TW'),
319    project_language in ('zh_CN', 'zh_TW'),
320])
321
322japanese = any([
323    language_user == 'ja',
324    project_language == 'ja',
325])
326
327if chinese:
328    latex_engine = latex_engine_user or 'xelatex'
329
330    latex_elements_rtd = {
331        'preamble': '\\usepackage[UTF8]{ctex}\n',
332    }
333    latex_elements = latex_elements_user or latex_elements_rtd
334elif japanese:
335    latex_engine = latex_engine_user or 'platex'
336
337# Make sure our build directory is always excluded
338exclude_patterns = globals().get('exclude_patterns', [])
339exclude_patterns.extend(['_build'])