conf.py

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