Skip to content

Commit 0ad5dac

Browse files
release: Bump version 1.0.9
1 parent 638b34d commit 0ad5dac

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

doc/changelog.d/494.fixed.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
fix: ``autoapi`` relative directory path wrt ``tox`` env

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ build-backend = "flit_core.buildapi"
55
[project]
66
# Check https://flit.readthedocs.io/en/latest/pyproject_toml.html for all available sections
77
name = "ansys-sphinx-theme"
8-
version = "1.0.8"
8+
version = "1.0.9"
99
description = "A theme devised by ANSYS, Inc. for Sphinx documentation."
1010
readme = "README.rst"
1111
requires-python = ">=3.9,<4"

src/ansys_sphinx_theme/extension/autoapi.py

+10-4
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"""Module containing an extension for creating Sphinx AutoAPI templates for the Ansys Sphinx Theme.""" # noqa: E501
2424

2525
import os
26+
from pathlib import Path
2627
from typing import Any, Dict
2728

2829
from sphinx.application import Sphinx
@@ -79,10 +80,15 @@ def prepare_jinja_env(jinja_env) -> None:
7980
app.config["autoapi_member_order"] = autoapi.get("member_order", "bysource")
8081

8182
# 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]
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)]
8692

8793

8894
def setup(app: Sphinx) -> Dict[str, Any]:

0 commit comments

Comments
 (0)