Skip to content

Commit ef3447b

Browse files
jorgepilotoRobPasMueRevathyvenugopal162
authored
doc: use autoapi templates from ansys-sphinx-theme (#662)
Co-authored-by: Roberto Pastor Muela <37798125+RobPasMue@users.noreply.github.com> Co-authored-by: Revathyvenugopal162 <revathy.venugopal@ansys.com> Co-authored-by: Revathy Venugopal <104772255+Revathyvenugopal162@users.noreply.github.com>
1 parent 0928754 commit ef3447b

File tree

7 files changed

+30
-30
lines changed

7 files changed

+30
-30
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ instance/
7676

7777
# Sphinx documentation
7878
doc/_build/
79-
doc/source/autoapi/
79+
doc/source/api/
8080

8181
# PyBuilder
8282
.pybuilder/

doc/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ help:
2222
# Customized clean due to examples gallery
2323
clean:
2424
rm -rf $(BUILDDIR)/*
25-
find . -type d -name "_autosummary" -exec rm -rf {} +
25+
find . -type d -name "api" -exec rm -rf {} +
2626

2727
# Create PDF
2828
pdf:

doc/make.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ goto build-examples-py
3838

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

4444
:help

doc/source/_autoapi_templates/index.rst

Lines changed: 0 additions & 15 deletions
This file was deleted.

doc/source/conf.py

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
"""Sphinx documentation configuration file."""
22
from datetime import datetime
33
import os
4+
from pathlib import Path
45

56
from ansys_sphinx_theme import (
67
ansys_favicon,
78
ansys_logo_white,
89
ansys_logo_white_cropped,
10+
get_autoapi_templates_dir_relative_path,
911
get_version_match,
1012
latex,
1113
pyansys_logo_black,
@@ -63,18 +65,15 @@
6365

6466
# Sphinx extensions
6567
extensions = [
66-
"autoapi.extension",
67-
"sphinx.ext.autodoc",
68-
"sphinx_autodoc_typehints",
69-
"sphinx.ext.autosummary",
70-
"numpydoc",
7168
"sphinx.ext.intersphinx",
7269
"sphinx_copybutton",
7370
"nbsphinx",
7471
"myst_parser",
7572
"jupyter_sphinx",
7673
"sphinx_design",
7774
"sphinx_jinja",
75+
"autoapi.extension",
76+
"numpydoc",
7877
]
7978

8079
# Intersphinx mapping
@@ -112,7 +111,6 @@
112111
# type, unless multiple values are being returned"
113112
}
114113

115-
116114
# static path
117115
html_static_path = ["_static"]
118116

@@ -138,17 +136,19 @@
138136
# Configuration for Sphinx autoapi
139137
autoapi_type = "python"
140138
autoapi_dirs = ["../../src/ansys"]
139+
autoapi_root = "api"
141140
autoapi_options = [
142141
"members",
143142
"undoc-members",
144143
"show-inheritance",
145144
"show-module-summary",
146145
"special-members",
147146
]
148-
autoapi_template_dir = "_autoapi_templates"
147+
autoapi_template_dir = get_autoapi_templates_dir_relative_path(Path(__file__))
149148
suppress_warnings = ["autoapi.python_import_resolution"]
150-
exclude_patterns = ["_autoapi_templates/index.rst"]
151149
autoapi_python_use_implicit_namespaces = True
150+
autoapi_keep_files = True
151+
autoapi_render_in_single_page = ["class", "enum", "exception"]
152152

153153
# Examples gallery customization
154154
nbsphinx_execute = "always"
@@ -216,6 +216,7 @@
216216
]
217217

218218
# -- Declare the Jinja context -----------------------------------------------
219+
exclude_patterns = []
219220
BUILD_API = True if os.environ.get("BUILD_API", "true") == "true" else False
220221
if not BUILD_API:
221222
exclude_patterns.append("autoapi")
@@ -231,3 +232,17 @@
231232
"build_examples": BUILD_EXAMPLES,
232233
},
233234
}
235+
236+
237+
def prepare_jinja_env(jinja_env) -> None:
238+
"""
239+
Customize the jinja env.
240+
241+
Notes
242+
-----
243+
See https://jinja.palletsprojects.com/en/3.0.x/api/#jinja2.Environment
244+
"""
245+
jinja_env.globals["project_name"] = project
246+
247+
248+
autoapi_prepare_jinja_env = prepare_jinja_env

doc/source/index.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ PyAnsys Geometry is a Python client library for the Ansys Geometry service.
5959
and how to interact with them programmatically.
6060

6161
+++
62-
.. button-link:: autoapi/index.html
62+
.. button-link:: api/index.html
6363
:color: secondary
6464
:expand:
6565
:outline:
@@ -117,7 +117,7 @@ PyAnsys Geometry is a Python client library for the Ansys Geometry service.
117117
getting_started/index
118118
user_guide/index
119119
{% if build_api %}
120-
autoapi/index
120+
api/index
121121
{% endif %}
122122
{% if build_examples %}
123123
examples

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ tests = [
7070
"vtk==9.2.6",
7171
]
7272
doc = [
73-
"ansys-sphinx-theme==0.10.6",
73+
"ansys-sphinx-theme==0.11.0",
7474
"docker==6.1.3",
7575
"ipyvtklink==0.2.3",
7676
"jupyter_sphinx==0.4.0",
@@ -84,7 +84,7 @@ doc = [
8484
"pyvista[trame]==0.42.1",
8585
"requests==2.31.0",
8686
"sphinx==7.2.5",
87-
"sphinx-autoapi==2.1.1",
87+
"sphinx-autoapi @ git+https://github.com/jorgepiloto/sphinx-autoapi@feat/single-page-option",
8888
"sphinx-autodoc-typehints==1.24.0",
8989
"sphinx-copybutton==0.5.2",
9090
"sphinx_design==0.5.0",

0 commit comments

Comments
 (0)