Skip to content

Commit

Permalink
Fix srcdir usage as a string for compatibility with Sphinx v8
Browse files Browse the repository at this point in the history
Closes #457
  • Loading branch information
AWhetter committed Jun 22, 2024
1 parent 52043a8 commit d2a9675
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 30 deletions.
34 changes: 4 additions & 30 deletions autoapi/extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import os
import shutil
from typing import Dict, Tuple
import warnings

import sphinx
from sphinx.util.console import colorize
Expand Down Expand Up @@ -45,14 +44,6 @@
"""Caches a module's parse results for use in viewcode."""


class RemovedInAutoAPI3Warning(DeprecationWarning):
"""Indicates something that will be removed in sphinx-autoapi v3."""


if "PYTHONWARNINGS" not in os.environ:
warnings.filterwarnings("default", category=RemovedInAutoAPI3Warning)


def _normalise_autoapi_dirs(autoapi_dirs, srcdir):
normalised_dirs = []

Expand All @@ -72,15 +63,6 @@ def run_autoapi(app):
if not app.config.autoapi_dirs:
raise ExtensionError("You must configure an autoapi_dirs setting")

if app.config.autoapi_include_summaries is not None:
warnings.warn(
"autoapi_include_summaries has been replaced by "
"the show-module-summary AutoAPI option\n",
RemovedInAutoAPI3Warning,
)
if app.config.autoapi_include_summaries:
app.config.autoapi_options.append("show-module-summary")

own_page_level = app.config.autoapi_own_page_level
if own_page_level not in _VALID_PAGE_LEVELS:
raise ValueError(f"Invalid autoapi_own_page_level '{own_page_level}")
Expand All @@ -94,22 +76,14 @@ def run_autoapi(app):
"Please check your `autoapi_dirs` setting."
)

template_dir = app.config.autoapi_template_dir
if template_dir and not os.path.isabs(template_dir):
template_dir = os.path.join(app.srcdir, app.config.autoapi_template_dir)

normalized_root = os.path.normpath(
os.path.join(app.srcdir, app.config.autoapi_root)
)
url_root = os.path.join("/", app.config.autoapi_root)

template_dir = app.config.autoapi_template_dir
if template_dir and not os.path.isabs(template_dir):
if not os.path.isdir(template_dir):
template_dir = os.path.join(app.srcdir, app.config.autoapi_template_dir)
elif app.srcdir != os.getcwd():
warnings.warn(
"autoapi_template_dir will be expected to be "
"relative to the Sphinx source directory instead of "
"relative to where sphinx-build is run\n",
RemovedInAutoAPI3Warning,
)
sphinx_mapper_obj = Mapper(
app, template_dir=template_dir, dir_root=normalized_root, url_root=url_root
)
Expand Down
1 change: 1 addition & 0 deletions docs/changes/+7e9094d4.removal
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Removed autoapi_include_summaries option. This was supposed to have been retired in v3
1 change: 1 addition & 0 deletions docs/changes/457.removal
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Removed ability for autoapi_template_dir to be relative to cwd. This was supposed to have been retired in v3

0 comments on commit d2a9675

Please sign in to comment.