From f00d2113281aacba3b59337c68221e33a33ef7d1 Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Thu, 29 Aug 2024 10:42:58 +0100 Subject: [PATCH] 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 --- openstackdocstheme/page_context.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/openstackdocstheme/page_context.py b/openstackdocstheme/page_context.py index 4e37ecca..7c7d8ab1 100644 --- a/openstackdocstheme/page_context.py +++ b/openstackdocstheme/page_context.py @@ -16,11 +16,11 @@ import os.path import subprocess import time +import sphinx from sphinx.util import logging from . import version - LOG = logging.getLogger(__name__) _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 # 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) if not os.path.exists(src_file):