Getting started#

Sphinx is a Python documentation generator for creating documentation. If you are new to using Sphinx, see Sphinx Getting Started.

This section explains how to install the Ansys Sphinx theme and then set up your Sphinx file to use this theme to generate your documentation.


Ansys sphinx theme build on top of pydata sphinx theme. The theme requires the following dependencies:

Optional dependencies#

Ansys Sphinx theme includes optional dependencies for autoapi documentation. To utilize sphinx-autoapi with custom templates provided by the theme, you need to install the following dependencies:

An example page demonstrating autoapi rendering with the Ansys sphinx theme template can be found found on the API Reference page of the PyAnsys Geometry documentation.

Install the theme#

Install the Ansys Sphinx theme with:

pip install ansys-sphinx-theme

For installing the optional dependencies, use:

pip install ansys-sphinx-theme[autoapi]

Modify the file#

To use this theme, modify your Sphinx file:

html_theme = "ansys_sphinx_theme"

Consider using the for this repository:

"""Sphinx documentation configuration file."""

from datetime import datetime
import os

from github import Github
from import LaTeXBuilder

LaTeXBuilder.supported_image_types = ["image/png", "image/pdf", "image/svg+xml"]

from ansys_sphinx_theme import (

# Project information
project = "ansys_sphinx_theme"
copyright = f"(c) {} ANSYS, Inc. All rights reserved"
author = "ANSYS, Inc."
release = version = __version__
cname = os.getenv("DOCUMENTATION_CNAME", "")

# use the default ansys logo
html_logo = ansys_logo_black
html_theme = "ansys_sphinx_theme"

# In the html_context dictionary in
html_context = {
    "github_user": "ansys",
    "github_repo": "ansys-sphinx-theme",
    "github_version": "main",
    "doc_path": "doc/source",

# specify the location of your github repo
html_theme_options = {
    "github_url": "",
    "contact_mail": "",
    "use_edit_page_button": True,
    "additional_breadcrumbs": [
        ("PyAnsys", ""),
    "external_links": [
            "url": "",
            "name": "Changelog",
    "switcher": {
        "json_url": f"https://{cname}/versions.json",
        "version_match": get_version_match(__version__),
    "use_meilisearch": {
        "api_key": os.getenv("MEILISEARCH_PUBLIC_API_KEY", ""),
        "index_uids": {
            f"ansys-sphinx-theme-v{convert_version_to_pymeilisearch(__version__)}": "ansys-sphinx-theme",  # noqa: E501

html_short_title = html_title = "Ansys Sphinx Theme"

# Sphinx extensions
extensions = [

# Intersphinx mapping
intersphinx_mapping = {
    "python": ("", None),
    # kept here as an example
    # "scipy": ("", None),
    # "numpy": ("", None),
    # "matplotlib": ("", None),
    # "pandas": ("", None),
    # "pyvista": ("", None),

# numpydoc configuration
numpydoc_show_class_members = False
numpydoc_xref_param_type = True

# Consider enabling numpydoc validation. See:
numpydoc_validate = True
numpydoc_validation_checks = {
    "GL06",  # Found unknown section
    "GL07",  # Sections are in the wrong order.
    "GL08",  # The object does not have a docstring
    "GL09",  # Deprecation warning should precede extended summary
    "GL10",  # reST directives {directives} must be followed by two colons
    "SS01",  # No summary found
    "SS02",  # Summary does not start with a capital letter
    # "SS03", # Summary does not end with a period
    "SS04",  # Summary contains heading whitespaces
    # "SS05", # Summary must start with infinitive verb, not third person
    "RT02",  # The first line of the Returns section should contain only the
    # type, unless multiple values are being returned"

# Favicon
html_favicon = ansys_favicon

# static path
html_static_path = ["_static"]

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

# The suffix(es) of source filenames.
source_suffix = ".rst"

# The master toctree document.
master_doc = "index"

# additional logos for the latex coverpage
latex_additional_files = [watermark, ansys_logo_white, ansys_logo_white_cropped]

# change the preamble of latex with customized title page
# variables are the title of pdf, watermark
latex_elements = {"preamble": latex.generate_preamble(html_title)}

# Not found page
notfound_context = {
    "body": generate_404(),

notfound_no_urls_prefix = True