conf.py

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