conf.py

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