text: # 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
  
  import os
  from typing import TYPE_CHECKING
  
  if TYPE_CHECKING:
      import sphinx.application
  
  # -- Project information ---------------------------------------------------------------
  
  project = "MESSAGEix-GLOBIOM tools"
  copyright = "2020–2022, IIASA Energy, Climate, and Environment (ECE) Program"
  author = "IIASA Energy, Climate, and Environment (ECE) Program"
  
  
  # -- 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.autosummary",
      "sphinx.ext.extlinks",
      "sphinx.ext.intersphinx",
      "sphinx.ext.napoleon",
      "sphinx.ext.todo",
      "sphinx.ext.viewcode",
  ]
  
  # Add any paths that contain templates here, relative to this directory.
  templates_path = ["_template"]
  
  # 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"]
  
  
  def setup(app: "sphinx.application.Sphinx") -> None:
      """Copied from pytest's conf.py to enable intersphinx references to these."""
      app.add_crossref_type(
          "fixture",
          "fixture",
          objname="built-in fixture",
          indextemplate="pair: %s; fixture",
      )
  
  
  # -- 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"
  
  # A list of CSS files.
  html_css_files = ["custom.css"]
  
  # The name of an image file (relative to this directory) to place at the top of the
  # sidebar.
  html_logo = "_static/logo-white.png"
  
  # 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"]
  
  # -- Options for sphinx.ext.autosummary ------------------------------------------------
  
  autosummary_generate = True
  
  
  # -- Options for sphinx.ext.extlinks ---------------------------------------------------
  
  extlinks = {
      "issue": ("https://github.com/iiasa/message-ix-models/issue/%s", "GH #"),
      "pull": ("https://github.com/iiasa/message-ix-models/pull/%s", "PR #"),
  }
  
  
  # -- Options for sphinx.ext.intersphinx ------------------------------------------------
  
  # For message-data, see: https://docs.readthedocs.io/en/stable/guides
  # /intersphinx.html#intersphinx-with-private-projects
  _token = os.environ.get("RTD_TOKEN_MESSAGE_DATA", "")
  
  intersphinx_mapping = {
      "genno": ("https://genno.readthedocs.io/en/stable", None),
      "ixmp": ("https://docs.messageix.org/projects/ixmp/en/latest/", None),
      "message-ix": ("https://docs.messageix.org/en/latest/", None),
      "m-data": (
          f"https://{_token}:@docs.messageix.org/projects/models-internal/en/latest/",
          None,
      ),
      "pandas": ("https://pandas.pydata.org/pandas-docs/stable/", None),
      "pytest": ("https://docs.pytest.org/en/stable/", None),
      "python": ("https://docs.python.org/3/", None),
      "sdmx": ("https://sdmx1.readthedocs.io/en/stable/", None),
  }
  