# 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
import datetime
import shutil
sys.path.insert(0, os.path.abspath("../../cleanlab"))
# doctest setup
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here.
import pathlib
sys.path.insert(0, pathlib.Path(__file__).parents[2].resolve().as_posix())
# Open Graph extension
ogp_site_url = "https://docs.cleanlab.ai"
ogp_image = (
"https://raw.githubusercontent.com/cleanlab/assets/master/cleanlab/clos-preview-card.png"
)
# -- Project information -----------------------------------------------------
project = "cleanlab"
copyright = f"{datetime.datetime.now().year}, Cleanlab Inc."
author = "Cleanlab Inc."
# -- 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.napoleon",
"nbsphinx",
"sphinx.ext.autodoc",
"sphinx.ext.autosectionlabel",
"autodocsumm",
"sphinx.ext.viewcode",
"sphinx.ext.todo",
"sphinx_tabs.tabs",
"sphinx_multiversion",
"sphinx_copybutton",
"sphinxcontrib.katex",
"sphinxcontrib.gtagjs",
"sphinx_jinja",
"sphinx_autodoc_typehints",
"sphinx.ext.doctest",
"sphinxext.opengraph",
]
numpy_show_class_members = True
# Don't add .txt suffix to source files:
html_sourcelink_suffix = ""
# 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"]
autosummary_generate = True
# set the default role of `name` to make cross references
default_role = "py:obj"
# -- Options for apidoc extension ----------------------------------------------
# apidoc_module_dir = "cleanlab/cleanlab"
# -- Options for todo extension ----------------------------------------------
# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = True
# -- Options for Napoleon extension -------------------------------------------
napoleon_google_docstring = False
napoleon_numpy_docstring = True
napoleon_include_init_with_doc = False
napoleon_include_private_with_doc = False
napoleon_include_special_with_doc = True
napoleon_use_admonition_for_examples = False
napoleon_use_admonition_for_notes = False
napoleon_use_admonition_for_references = False
napoleon_use_ivar = False
napoleon_use_param = True
napoleon_use_rtype = False
napoleon_preprocess_types = True
napoleon_type_aliases = None
napoleon_attr_annotations = True
# -- Options for autodoc extension -------------------------------------------
# This value selects what content will be inserted into the main body of an autoclass
# directive
#
# http://www.sphinx-doc.org/en/master/usage/extensions/autodoc.html#directive-autoclass
autoclass_content = "class"
# Default options to an ..autoXXX directive.
autodoc_default_options = {
"autosummary": True,
"members": None,
"inherited-members": None,
"show-inheritance": None,
"special-members": "__call__",
}
# Subclasses should show parent classes docstrings if they don't override them.
autodoc_inherit_docstrings = True
# Order functions displayed by the order of source code
autodoc_member_order = "bysource"
# -- Options for copybutton extension -----------------------------------------
# Strip input prompts when copying code blocks. Supports:
# - Python Repl + continuation prompt
# - Bash prompt
# - ipython + continuation prompt
# - jupyter-console + continuation prompt
copybutton_prompt_text = r">>> |\.\.\. |\$ |In \[\d*\]: | {2,5}\.\.\.: | {5,8}: "
copybutton_prompt_is_regexp = True
# -- Options for katex extension -------------------------------------------
if os.getenv("CI") or shutil.which("katex") is not None:
# requires that the machine have `katex` installed: `npm install -g katex`
katex_prerender = True
# -- Options for gtagjs extension -------------------------------------------
gtagjs_ids = ["G-EV8RVEFX82"]
# -- Variables Setting ---------------------------------------------------
# Determine doc site URL (DOCS_SITE_URL)
# Check if it's running in production repo
if os.getenv("GITHUB_REPOSITORY") == "cleanlab/cleanlab":
DOCS_SITE_URL = "/"
else:
DOCS_SITE_URL = "/cleanlab-docs/"
gh_env_file = os.getenv("GITHUB_ENV")
if gh_env_file is not None:
with open(gh_env_file, "a") as f:
f.write(f"\nDOCS_SITE_URL={DOCS_SITE_URL}") # Set to Environment Var
GITHUB_REPOSITORY_OWNER = os.getenv("GITHUB_REPOSITORY_OWNER") or "cleanlab"
GITHUB_REF_NAME = os.getenv("GITHUB_REF_NAME") or "master"
# Pass additional variables to Jinja templates
html_context = {
"DOCS_SITE_URL": DOCS_SITE_URL,
# Add new tags to RELEASE_VERSIONS before release
# fmt: off
"RELEASE_VERSIONS": [
"v2.7.1",
"v2.7.0",
"v2.6.6",
"v2.6.5",
"v2.6.4",
"v2.6.3",
"v2.6.2",
"v2.6.1",
"v2.6.0",
"v2.5.0",
"v2.4.0",
"v2.3.1",
"v2.3.0",
"v2.2.0",
"v2.1.0",
"v2.0.0",
"v1.0.1",
],
# fmt: on
}
# -- nbsphinx Configuration ---------------------------------------------------
# This is processed by Jinja2 and inserted before each notebook
nbsphinx_prolog = (
"""
{% set docname = env.doc2path(env.docname, base=None) %}
.. raw:: html
"""
)
# Change this to "always" before running in the doc's CI/CD server
if os.getenv("CI"):
nbsphinx_execute = "always"
if os.getenv("SKIP_NOTEBOOKS", "0") != "0":
nbsphinx_execute = "never"
# -- 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 = "furo"
html_favicon = "https://raw.githubusercontent.com/cleanlab/assets/a4483476d449f2f05a4c7cde329e72358099cc07/cleanlab/cleanlab_favicon.svg"
html_title = "cleanlab"
html_logo = (
"https://raw.githubusercontent.com/cleanlab/assets/master/cleanlab/cleanlab_logo_only.png"
)
html_theme_options = {
"footer_icons": [
{
"name": "GitHub",
"url": "https://github.com/cleanlab/cleanlab",
"html": """
""",
"class": "",
},
],
}
# 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"]
html_css_files = ["css/custom.css"]
html_sidebars = {
"**": [
"brand.html",
"sidebar/search.html",
"sidebar/scroll-start.html",
"sidebar/navigation.html",
"sidebar/ethical-ads.html",
"versioning.html",
"sidebar/scroll-end.html",
],
}