Resolve Sphinx 8.x warnings

Resolve the following warning:

  RemovedInSphinx90Warning: Sphinx 9 will drop support for representing
  paths as strings. Use "pathlib.Path" or "os.fspath" instead.

Change-Id: Ica6524895e38e1e54ae3207a1e58a97f53481a12
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This commit is contained in:
Stephen Finucane 2024-08-29 10:42:58 +01:00
parent fe883a4de1
commit f00d211328

View File

@ -16,11 +16,11 @@ import os.path
import subprocess import subprocess
import time import time
import sphinx
from sphinx.util import logging from sphinx.util import logging
from . import version from . import version
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
_timeint = int(os.environ.get('SOURCE_DATE_EPOCH', time.time())) _timeint = int(os.environ.get('SOURCE_DATE_EPOCH', time.time()))
@ -80,7 +80,12 @@ def _get_last_updated(app, pagename):
# Strip the prefix from the filename so the git command recognizes # Strip the prefix from the filename so the git command recognizes
# the file as part of the current repository. # the file as part of the current repository.
src_file = full_src_file[len(str(app.builder.env.srcdir)) :].lstrip('/') if sphinx.version_info >= (7, 0):
src_file = str(full_src_file.relative_to(app.builder.env.srcdir))
else: # Sphinx < 7.0
src_file = full_src_file[len(str(app.builder.env.srcdir)) :].lstrip(
'/'
)
candidates.append(src_file) candidates.append(src_file)
if not os.path.exists(src_file): if not os.path.exists(src_file):