Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: use autoapi templates from ansys-sphinx-theme #662

Merged
merged 20 commits into from
Sep 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ instance/

# Sphinx documentation
doc/_build/
doc/source/autoapi/
doc/source/api/

# PyBuilder
.pybuilder/
Expand Down
2 changes: 1 addition & 1 deletion doc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ help:
# Customized clean due to examples gallery
clean:
rm -rf $(BUILDDIR)/*
find . -type d -name "_autosummary" -exec rm -rf {} +
find . -type d -name "api" -exec rm -rf {} +

# Create PDF
pdf:
Expand Down
2 changes: 1 addition & 1 deletion doc/make.bat
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ goto build-examples-py

:clean
rmdir /s /q %BUILDDIR% > /NUL 2>&1
for /d /r %SOURCEDIR% %%d in (_autosummary) do @if exist "%%d" rmdir /s /q "%%d"
for /d /r %SOURCEDIR% %%d in (api) do @if exist "%%d" rmdir /s /q "%%d"
goto end

:help
Expand Down
15 changes: 0 additions & 15 deletions doc/source/_autoapi_templates/index.rst

This file was deleted.

31 changes: 23 additions & 8 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
"""Sphinx documentation configuration file."""
from datetime import datetime
import os
from pathlib import Path

from ansys_sphinx_theme import (
ansys_favicon,
ansys_logo_white,
ansys_logo_white_cropped,
get_autoapi_templates_dir_relative_path,
get_version_match,
latex,
pyansys_logo_black,
Expand Down Expand Up @@ -63,18 +65,15 @@

# Sphinx extensions
extensions = [
"autoapi.extension",
"sphinx.ext.autodoc",
"sphinx_autodoc_typehints",
"sphinx.ext.autosummary",
"numpydoc",
"sphinx.ext.intersphinx",
"sphinx_copybutton",
"nbsphinx",
"myst_parser",
"jupyter_sphinx",
"sphinx_design",
"sphinx_jinja",
"autoapi.extension",
"numpydoc",
]

# Intersphinx mapping
Expand Down Expand Up @@ -112,7 +111,6 @@
# type, unless multiple values are being returned"
}


# static path
html_static_path = ["_static"]

Expand All @@ -138,17 +136,19 @@
# Configuration for Sphinx autoapi
autoapi_type = "python"
autoapi_dirs = ["../../src/ansys"]
autoapi_root = "api"
autoapi_options = [
"members",
"undoc-members",
"show-inheritance",
"show-module-summary",
"special-members",
]
autoapi_template_dir = "_autoapi_templates"
autoapi_template_dir = get_autoapi_templates_dir_relative_path(Path(__file__))
RobPasMue marked this conversation as resolved.
Show resolved Hide resolved
suppress_warnings = ["autoapi.python_import_resolution"]
exclude_patterns = ["_autoapi_templates/index.rst"]
autoapi_python_use_implicit_namespaces = True
autoapi_keep_files = True
autoapi_render_in_single_page = ["class", "enum", "exception"]
RobPasMue marked this conversation as resolved.
Show resolved Hide resolved

# Examples gallery customization
nbsphinx_execute = "always"
Expand Down Expand Up @@ -216,6 +216,7 @@
]

# -- Declare the Jinja context -----------------------------------------------
exclude_patterns = []
BUILD_API = True if os.environ.get("BUILD_API", "true") == "true" else False
if not BUILD_API:
exclude_patterns.append("autoapi")
Expand All @@ -231,3 +232,17 @@
"build_examples": BUILD_EXAMPLES,
},
}


def prepare_jinja_env(jinja_env) -> None:
"""
Customize the jinja env.

Notes
-----
See https://jinja.palletsprojects.com/en/3.0.x/api/#jinja2.Environment
"""
jinja_env.globals["project_name"] = project


autoapi_prepare_jinja_env = prepare_jinja_env
4 changes: 2 additions & 2 deletions doc/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ PyAnsys Geometry is a Python client library for the Ansys Geometry service.
and how to interact with them programmatically.

+++
.. button-link:: autoapi/index.html
.. button-link:: api/index.html
:color: secondary
:expand:
:outline:
Expand Down Expand Up @@ -117,7 +117,7 @@ PyAnsys Geometry is a Python client library for the Ansys Geometry service.
getting_started/index
user_guide/index
{% if build_api %}
autoapi/index
api/index
{% endif %}
{% if build_examples %}
examples
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ tests = [
"vtk==9.2.6",
]
doc = [
"ansys-sphinx-theme==0.10.6",
"ansys-sphinx-theme==0.11.0",
"docker==6.1.3",
"ipyvtklink==0.2.3",
"jupyter_sphinx==0.4.0",
Expand All @@ -84,7 +84,7 @@ doc = [
"pyvista[trame]==0.42.1",
"requests==2.31.0",
"sphinx==7.2.5",
"sphinx-autoapi==2.1.1",
"sphinx-autoapi @ git+https://github.com/jorgepiloto/sphinx-autoapi@feat/single-page-option",
"sphinx-autodoc-typehints==1.24.0",
"sphinx-copybutton==0.5.2",
"sphinx_design==0.5.0",
Expand Down