-
Notifications
You must be signed in to change notification settings - Fork 326
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
MNT: more flexible static #1221
Conversation
it's 1:30 at my place so way to late for a complete answer, I'll review the comments you made in the PR. |
OK, so I will try and make the path logic relative to conf (which its not with this change). But I think thats relatively easy while still allowing subdirectories. |
24c7fe4
to
5d8e580
Compare
OK, finally got to dig into this properly: https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-html_logo
So the change in 0.13.0 to "logo/image_light" seems in this spirit - the image Is copied to Our difficulty, is that we would like the logo to be in the theme that inherits from pydata-sphinx-theme, and gets copied from |
In case it's helpful, here how we set a default logo in the jupyterhub theme (which inherits from this theme) I ran into the same problem you did, and my solution was just to be lazy and put the logo image directly under static, but if we could find a more principled way around this that would be great |
5d8e580
to
3041d0a
Compare
yes, thats super helpful - we could probably do all the same defaulting for matplotlib and save all the client projects from specifying the logo at all. |
@choldgraf I guess your method of setting the path to the theme static and having pydata-sphinx-theme copy from there is fine. I feel the way proposed here is OK as well - let sphinx copy the theme static to build/html/_static and then let pydata-sphinx-theme only copy the file across if it needs to (or error if it can't find it). Certainly it will make our |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me - just one quick suggestion to make it clear when this might happen in the comments
src/pydata_sphinx_theme/__init__.py
Outdated
@@ -1166,6 +1166,9 @@ def copy_logo_images(app: Sphinx, exception=None) -> None: | |||
path_image = logo.get(f"image_{kind}") | |||
if not path_image or isurl(path_image): | |||
continue | |||
if (staticdir / Path(path_image).name).exists(): | |||
# file already exists in static dir |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# file already exists in static dir | |
# file already exists in static dir | |
# e.g., because a theme has already bundled it there |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Slight edit, but general idea is the same:
# file already exists in static dir e.g. because a theme has
# bundled the logo and installed it there
3041d0a
to
df586d2
Compare
df586d2
to
988fde0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thanks!
EDIT:
In mpl-sphinx-theme, we provide
static/logo.svg
which gets copied to_build/html/_static/logo.svg
.#1132 changed the behaviour of "logo" config option to do what sphinx's html_logo does, which is just copy the logo file from a relative path (relative to the conf.py) into
_static
, and raised a warning if the file did not exist. So:would copy to
_build/html/_static/logo2.svg
,_build/html/_static/logo_dark.svg
.However, because we provide the logo as part of the theme payload, its "source" never exists - it gets copied directly into
_static/logo2.svg
. The PR here checks if that file exists, and doesn't warn if it already there. We specify that file in theconf.py
aswhich makes the links work properly in
setup_logo_path
. Unfortunately we cannot check for the existence of_build/html/_static/logo2.svg
insetup_logo_path
, because the build directory has not been populated yet.