Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correctly specify the source path to a logo to copy_asset_file #1746

Merged
merged 3 commits into from
May 27, 2024

Conversation

Cadair
Copy link
Contributor

@Cadair Cadair commented Mar 22, 2024

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.

Copy link
Collaborator

@drammock drammock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks correct to me, but hopefully @12rambau has time to look too, as I think he wrote much of the logic for handling light/dark logos. If not, I'll merge later this week.

@@ -78,4 +78,4 @@ def copy_logo_images(app: Sphinx, exception=None) -> None:
f"The {kind} logo path '{path_image}' looks like a Sphinx template; "
"please provide a static logo image."
)
copy_asset_file(path_image, staticdir)
copy_asset_file(str(Path(app.srcdir) / path_image), staticdir)
Copy link
Collaborator

@drammock drammock Mar 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

on second look, I'm not sure this is correct. If the logo path is supposed to be relative to conf.py then shouldn't this be:

Suggested change
copy_asset_file(str(Path(app.srcdir) / path_image), staticdir)
copy_asset_file(str(Path(app.confdir) / path_image), staticdir)

(docs: https://www.sphinx-doc.org/en/master/extdev/appapi.html#sphinx-runtime-information)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe the reason is that it's already referencing (Path(app.srcdir) / path_image) on line 73:

        if not (Path(app.srcdir) / path_image).exists():

We likely want to use a variable and reuse it to make sure there is no inconsistencies.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and copy_asset_file(path_image, staticdir) was wrong as afaict, this was referencing path relative to CWD, and just silently do nothing if the source does not exist.

@trallard trallard added the kind: enhancement New feature or request label Apr 2, 2024
@Carreau
Copy link
Collaborator

Carreau commented May 21, 2024

I've pushed an extra commit. As the code on line 73 was checking existence with respect srcdir, I think this is self-coherent, I think that wether we need to use srcdir, or confdir is a separate conversation.

@Carreau
Copy link
Collaborator

Carreau commented May 21, 2024

srcdir, or confdir

(we can potentially loop on both/warn/deprecate the wrong one).

Copy link

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  src/pydata_sphinx_theme
  logo.py
  translator.py
Project Total  

This report was generated by python-coverage-comment-action

@Carreau
Copy link
Collaborator

Carreau commented May 27, 2024

Ok, let's get that in, if we want to change from srcdir ton confdir we'll do that later.

@Carreau Carreau merged commit 541950a into pydata:main May 27, 2024
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Variable html_theme_options:logo incompatible with Sphinx _static Logic
4 participants