File tree Expand file tree Collapse file tree 2 files changed +11
-5
lines changed
src/ansys_sphinx_theme/extension Expand file tree Collapse file tree 2 files changed +11
-5
lines changed Original file line number Diff line number Diff line change
1
+ fix: `` autoapi `` relative directory path wrt `` tox `` env
Original file line number Diff line number Diff line change 23
23
"""Module containing an extension for creating Sphinx AutoAPI templates for the Ansys Sphinx Theme.""" # noqa: E501
24
24
25
25
import os
26
+ from pathlib import Path
26
27
from typing import Any , Dict
27
28
28
29
from sphinx .application import Sphinx
@@ -79,11 +80,15 @@ def prepare_jinja_env(jinja_env) -> None:
79
80
app .config ["autoapi_member_order" ] = autoapi .get ("member_order" , "bysource" )
80
81
81
82
# HACK: The ``autoapi_dirs`` should be given as a relative path to the conf.py.
82
- relative_autoapi_dir = os .path .relpath (
83
- autoapi .get ("directory" , "src/ansys" ), start = str (app .confdir / "conf.py" )
84
- )
85
- app .config ["autoapi_dirs" ] = [relative_autoapi_dir ]
86
- print (f"AutoAPI directories: { app .config ['autoapi_dirs' ]} " )
83
+ autoapi_dir = autoapi .get ("directory" , "src/ansys" )
84
+ # assume the docs are in doc/source directory
85
+ root_dir = Path (app .srcdir ).resolve ().parent .parent
86
+ path_to_autoapi_dir = (root_dir / autoapi_dir ).resolve ()
87
+ if path_to_autoapi_dir .exists ():
88
+ relative_autoapi_dir = os .path .relpath (path_to_autoapi_dir , start = app .srcdir )
89
+ else :
90
+ relative_autoapi_dir = autoapi_dir
91
+ app .config ["autoapi_dirs" ] = [str (relative_autoapi_dir )]
87
92
88
93
89
94
def setup (app : Sphinx ) -> Dict [str , Any ]:
You can’t perform that action at this time.
0 commit comments