Source code for docs.conf

# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

# -- Path setup --------------------------------------------------------------

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
import os
import sys
sys.path.append(os.path.abspath("./ext"))
sys.path.insert(0, os.path.abspath('../'))


# -- Project information -----------------------------------------------------
from typing import Any, List

project = 'Tuxemon'
copyright = '2015-2021, William Edwards'
author = 'William Edwards'

# The full version, including alpha/beta/rc tags
release = 'alpha'


# -- General configuration ---------------------------------------------------

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
    'sphinx.ext.autodoc',
    'sphinx.ext.todo',
    'sphinx.ext.viewcode',
    'sphinx.ext.githubpages',
    'sphinx.ext.napoleon',
    'script_documenter',
]

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']


# -- Options for HTML output ----------------------------------------------

# The theme to use for HTML and HTML Help pages.  See the documentation for
# a list of builtin themes.
#
html_theme = 'sphinx_rtd_theme'

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']

autodoc_typehints = "description"

napoleon_numpy_docstring = False

napoleon_custom_sections = [
    "Script usage",
    ("Script parameters", "params_style")
]


# Apidoc call to generate automatic reference docs. Taken from
# https://github.com/readthedocs/readthedocs.org/issues/1139#issuecomment-398083449
[docs]def run_apidoc(_: Any) -> None: ignore_paths: List[str] = [] argv = [ "-f", "-e", "-M", "-o", "autogen", ".." ] + ignore_paths # Sphinx 1.7+ from sphinx.ext import apidoc apidoc.main(argv)
[docs]def setup(app: Any) -> None: app.connect('builder-inited', run_apidoc)
########################################################################### # auto-created readthedocs.org specific configuration # ########################################################################### # # The following code was added during an automated build on readthedocs.org # It is auto created and injected for every build. The result is based on the # conf.py.tmpl file found in the readthedocs.org codebase: # https://github.com/rtfd/readthedocs.org/blob/main/readthedocs/doc_builder/templates/doc_builder/conf.py.tmpl # # Note: this file shouldn't rely on extra dependencies. import importlib import sys import os.path # Borrowed from six. PY3 = sys.version_info[0] == 3 string_types = str if PY3 else basestring from sphinx import version_info # Get suffix for proper linking to GitHub # This is deprecated in Sphinx 1.3+, # as each page can have its own suffix if globals().get('source_suffix', False): if isinstance(source_suffix, string_types): SUFFIX = source_suffix elif isinstance(source_suffix, (list, tuple)): # Sphinx >= 1.3 supports list/tuple to define multiple suffixes SUFFIX = source_suffix[0] elif isinstance(source_suffix, dict): # Sphinx >= 1.8 supports a mapping dictionary for multiple suffixes SUFFIX = list(source_suffix.keys())[0] # make a ``list()`` for py2/py3 compatibility else: # default to .rst SUFFIX = '.rst' else: SUFFIX = '.rst' # Add RTD Static Path. Add to the end because it overwrites previous files. if not 'html_static_path' in globals(): html_static_path = [] if os.path.exists('_static'): html_static_path.append('_static') # Define this variable in case it's not defined by the user. # It defaults to `alabaster` which is the default from Sphinx. # https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-html_theme html_theme = globals().get('html_theme', 'alabaster') #Add project information to the template context. context = { 'html_theme': html_theme, 'current_version': "latest", 'version_slug': "latest", 'MEDIA_URL': "https://media.readthedocs.org/", 'STATIC_URL': "https://assets.readthedocs.org/static/", 'PRODUCTION_DOMAIN': "readthedocs.org", 'proxied_static_path': "/_/static/", 'versions': [ ("latest", "/en/latest/"), ("stable", "/en/stable/"), ], 'downloads': [ ], 'subprojects': [ ], 'slug': 'tuxemon', 'name': u'Tuxemon', 'rtd_language': u'en', 'programming_language': u'py', 'canonical_url': '', 'analytics_code': 'None', 'single_version': False, 'conf_py_path': '/docs/', 'api_host': 'https://readthedocs.org', 'github_user': 'Tuxemon', 'proxied_api_host': '/_', 'github_repo': 'Tuxemon', 'github_version': 'development', 'display_github': True, 'bitbucket_user': 'None', 'bitbucket_repo': 'None', 'bitbucket_version': 'development', 'display_bitbucket': False, 'gitlab_user': 'None', 'gitlab_repo': 'None', 'gitlab_version': 'development', 'display_gitlab': False, 'READTHEDOCS': True, 'using_theme': (html_theme == "default"), 'new_theme': (html_theme == "sphinx_rtd_theme"), 'source_suffix': SUFFIX, 'ad_free': False, 'docsearch_disabled': False, 'user_analytics_code': '', 'global_analytics_code': 'UA-17997319-1', 'commit': 'e147cd3c', } # For sphinx >=1.8 we can use html_baseurl to set the canonical URL. # https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-html_baseurl if version_info >= (1, 8): if not globals().get('html_baseurl'): html_baseurl = context['canonical_url'] context['canonical_url'] = None if 'html_context' in globals(): for key in context: if key not in html_context: html_context[key] = context[key] else: html_context = context # Add custom RTD extension if 'extensions' in globals(): # Insert at the beginning because it can interfere # with other extensions. # See https://github.com/rtfd/readthedocs.org/pull/4054 extensions.insert(0, "readthedocs_ext.readthedocs") else: extensions = ["readthedocs_ext.readthedocs"] # Add External version warning banner to the external version documentation if 'tag' == 'external': extensions.insert(1, "readthedocs_ext.external_version_warning") readthedocs_vcs_url = 'None' readthedocs_build_url = 'https://readthedocs.org/projects/tuxemon/builds/22018311/' project_language = 'en' # User's Sphinx configurations language_user = globals().get('language', None) latex_engine_user = globals().get('latex_engine', None) latex_elements_user = globals().get('latex_elements', None) # Remove this once xindy gets installed in Docker image and XINDYOPS # env variable is supported # https://github.com/rtfd/readthedocs-docker-images/pull/98 latex_use_xindy = False chinese = any([ language_user in ('zh_CN', 'zh_TW'), project_language in ('zh_CN', 'zh_TW'), ]) japanese = any([ language_user == 'ja', project_language == 'ja', ]) if chinese: latex_engine = latex_engine_user or 'xelatex' latex_elements_rtd = { 'preamble': '\\usepackage[UTF8]{ctex}\n', } latex_elements = latex_elements_user or latex_elements_rtd elif japanese: latex_engine = latex_engine_user or 'platex' # Make sure our build directory is always excluded exclude_patterns = globals().get('exclude_patterns', []) exclude_patterns.extend(['_build'])