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
[Docs] Replace PNG/ICO images with SVG #2869
Conversation
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 in an interesting approach. LGTM but I've got a few questions.
- Is the sphinx extension only needed to inject multiple favicon tags? Is the manual copying really necessary?
- Have you considered applying something like https://jakearchibald.github.io/svgomg/ as an optimization? As a separate PR maybe.
Hi @webknjaz thank you very much for the review
The extension is also needed to add the correct mime type.
If you inspect the current documentation page you can see that just by using the
I was following the approach I suppose this can be done in a different way, for example, by relying on
Yes no problem, I can investigate optimisers in a separate PR. However, I think it is good to leave the |
FWIW I have an example where this works for me natively without specifying the type: https://ansible-pylibssh.rtfd.io. Although, I haven't checked whether it's cross-browser and it sounds like what you're doing is right. OTOH the right thing to do, as I see it, would be to post an issue (and possibly a solution) on the Sphinx's tracker to avoid maintaining an in-tree extension. Until that happens, it's fine to have it here, of course. Just trying to look out for potential maintenance burden.
Fair enough. I just seem to recall that there were cases where Sphinx would copy stuff on its own, automatically. Although the proposal above would probably sort this out. I've checked what I did in the past and it looks like I've just put the image under
Yeah, maybe run SVGO during the build time even (although this would mean depending on NodeJS or dukpy). |
{ # Version with thicker strokes for better visibility at smaller sizes | ||
"rel": "icon", | ||
"type": "image/svg+xml", | ||
"file": "images/favicon.svg", |
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.
Maybe call the file properly instead of having a comment only in one place?
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.
Hi @webknjaz, I am not sure if I understood correctly your comment.
Do you mean having a "relative_path"
instead of "file"
in the dictionary? That would make sense...
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.
No, I'm talking about the filename. It's not cool that the file is called favicon.svg
and needs a code comment above explaining what it is. This information should be present in a file name, treat it as a variable in code. If the name is self-explanatory, then it'd be useful when checking out the HTML output, or just opening the URL in a browser, or while browsing the repository. A name like favicon
does not give any hint about what the difference is from the other SVG file, nor it points at the relation between this and logo-symbol-only.svg
.
You've added two code comments for each entry. The first one is quite useful because it explains the motivation but this second one has both useful and pointless bits. If a code comment has to include explanations about what the things are, you're probably calling those things wrong names.
@@ -101,8 +104,7 @@ | |||
|
|||
# HTML theme | |||
html_theme = 'furo' | |||
html_logo = "images/logo.png" | |||
html_favicon = "images/favicon.ico" |
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.
Maybe keep it pointing at SVG as a fallback?
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.
Once we agree in a good file structure, I can test this.
I suppose it will work fine, although it might obfuscate the setup for multiple sizes in some browser.
Thank you for the comments guys. I will try to address some of those later today.
That is the tricky part isn't it? 😄 If the project is OK with having just one SVG icon via the default Sphinx mechanism, please let me know and I will change the PR accordingly. In that scenario, which one would you prefer:
(The small version may appear different from the logo when enlarged -- I suppose that can happen when creating shortcuts, pinning to the start-page/speed dial, etc). (The standard logo is less visible/more difficult to be seen in the browsers tab-bar)
Yes, Sphinx will automatically copy everything inside all the directories listed in the |
Yep, this is why I said that you're doing the right thing :)
I actually like having fallbacks. So keep them.
Well, I was thinking about how Sphinx special-cases some of these settings like |
The example that you mentioned is very interesting. I believe that what is happening in the ansible-lint code is a coincidence actually... According to the docs:
So you could have the file in any folder relative to the |
@webknjaz, would the following organisation be fine? docs
├── ...
├── _static
│ ├── icon-small.svg # favicon renamed to be more clear
│ └── icon.svg # the standard icon for the project (logo without the text)
└── images
├── README.rst
├── banner-640x320.svg
├── ... # several SVG files available to be used by the project
├── ... # no `logo-symbol-only.svg` since it is redundant with `_static/icon.svg`
└── logo.svg Do you have a different suggestion? Notes:
|
This change has been previously proposed and agreed upon in pypa#2869. The idea here is to avoid the burden of maintaining an in-tree sphinx extension, now that `sphinx-favicon` is available and covers setuptools use-case.
In this commit the SVG images (logo, banners, etc) were optimised with the help of https://pypi.org/project/scour/. This change has been previously requested/discussed and agreed upon on pypa#2869. The `*editable-inkscape.svg` files are preserved in the original form.
Motivation
As pointed out in #2853 (comment), the best police for usability and the git repo itself is to stick with vectorial images instead of binary files.
Initially I thought that Safari did not support SVG "favicons" but according to a recent article now it does, which make all the main desktop browsers compatible.
Summary of changes
png
images included in therst
files with the equivalentsvg
favicon.svg
andlogo-symbol-only.svg
to better suite the usage.Closes #2867
Pull Request Checklist
changelog.d/
.(See documentation for details)