Skip to content

Commit 541950a

Browse files
authored
Correctly specify the source path to a logo to copy_asset_file (#1746)
I think this fixes #1385, I think that bug report is expecting to be able to pass a logo in the docs/_static directory but according to the docs here: https://pydata-sphinx-theme.readthedocs.io/en/stable/user_guide/branding.html#different-logos-for-light-and-dark-mode the path should be relative to conf.py. I think the actual bug is that we were not passing the correct source to the sphinx copy function which exits silently (for some reason) if the source does not exist.
1 parent aabe57d commit 541950a

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/pydata_sphinx_theme/logo.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ def copy_logo_images(app: Sphinx, exception=None) -> None:
6363
warning = partial(maybe_warn, app)
6464
logo = get_theme_options_dict(app).get("logo", {})
6565
staticdir = Path(app.builder.outdir) / "_static"
66+
assert staticdir.is_absolute()
6667
for kind in ["light", "dark"]:
6768
path_image = logo.get(f"image_{kind}")
6869
if not path_image or isurl(path_image):
@@ -71,12 +72,14 @@ def copy_logo_images(app: Sphinx, exception=None) -> None:
7172
# file already exists in static dir e.g. because a theme has
7273
# bundled the logo and installed it there
7374
continue
74-
if not (Path(app.srcdir) / path_image).exists():
75+
full_logo_path = Path(app.srcdir) / path_image
76+
assert full_logo_path.is_absolute()
77+
if not full_logo_path.exists():
7578
warning(f"Path to {kind} image logo does not exist: {path_image}")
7679
# Ensure templates cannot be passed for logo path to avoid security vulnerability
7780
if path_image.lower().endswith("_t"):
7881
raise ExtensionError(
7982
f"The {kind} logo path '{path_image}' looks like a Sphinx template; "
8083
"please provide a static logo image."
8184
)
82-
copy_asset_file(path_image, staticdir)
85+
copy_asset_file(str(full_logo_path), staticdir)

0 commit comments

Comments
 (0)