1
- """Module for adding the autoapi extension with the theme."""
2
-
3
1
# Copyright (C) 2021 - 2024 ANSYS, Inc. and/or its affiliates.
4
2
# SPDX-License-Identifier: MIT
5
3
#
@@ -44,12 +42,6 @@ def add_autoapi_theme_option(app: Sphinx) -> None:
44
42
if not autoapi :
45
43
return
46
44
47
- # HACK: The ``sphinx_jinja`` and ``sphinx_design`` should be added to the extensions.
48
- required_extensions = ["sphinx_jinja" , "sphinx_design" ]
49
-
50
- for extension in required_extensions :
51
- if extension not in app .config ["extensions" ]:
52
- app .config ["extensions" ].append (extension )
53
45
AUTOAPI_OPTIONS = [
54
46
"members" ,
55
47
"undoc-members" ,
@@ -68,6 +60,7 @@ def add_autoapi_theme_option(app: Sphinx) -> None:
68
60
def prepare_jinja_env (jinja_env ) -> None :
69
61
"""Prepare the Jinja environment for the theme."""
70
62
jinja_env .globals ["project_name" ] = autoapi_project_name
63
+ jinja_env .globals ["autoapi_depth" ] = autoapi .get ("package_depth" , 3 )
71
64
72
65
# Set the autoapi options
73
66
@@ -104,8 +97,12 @@ def setup(app: Sphinx) -> Dict[str, Any]:
104
97
Dict[str, Any]
105
98
A dictionary containing the version and parallel read/write safety flags.
106
99
"""
107
- # HACK: The ``autoapi.extension`` should add here to initialize the extension.
108
- app .setup_extension ("autoapi.extension" )
100
+ # HACK: The ``autoapi.extension``, ``sphinx_design``, and ``sphinx_jinja`` extensions should be
101
+ # added to the Sphinx
102
+ required_extensions = ["sphinx_design" , "sphinx_jinja" , "autoapi.extension" ]
103
+ for extension in required_extensions :
104
+ if extension not in app .config ["extensions" ]:
105
+ app .setup_extension (extension )
109
106
app .connect ("builder-inited" , add_autoapi_theme_option , priority = 400 )
110
107
return {
111
108
"version" : __version__ ,
0 commit comments