Closed samscott89 closed 3 years ago
Hi @samscott89, thanks for your PR!
I'm not sure to understand what is the issue that this PR fixes. Could you provide a detailed description and maybe an isolated small example project for this that I can use to reproduce it?
Also, would be good if you can write a test case together on this PR so we are sure that we are not hitting this issue again in the future.
Hi @samscott89, thanks for your PR!
I'm not sure to understand what is the issue that this PR fixes. Could you provide a detailed description and maybe an isolated small example project for this that I can use to reproduce it?
Also, would be good if you can write a test case together on this PR so we are sure that we are not hitting this issue again in the future.
No problem! Hopefully the latest commit does both in one :) The added test fails against main - the add_css_file
(or add_stylesheet
) method adds files in a way which skips the pathto
method.
So any extensions using that method (or any project) ends up with files that aren't fixed.
If I understand correctly, the work done in this PR is replaced by #153 and it's not required anymore. @samscott89 could you please help me testing that PR with your project and letting me know that it works as you expected?
I ran into this myself, and was working on a fix at https://github.com/sphinx-toolbox/sphinx-notfound-page/tree/css-files before I saw this PR.
What happens is:
app.add_css_file("my_style.css"
_static/my_style.css
, but bypasses the modified "pathto" function and so the target doesn't get prefixed with /en/latest/
When visiting a non-existent page under /en/latest
everything works, since the relative target points to the right place.
But if the user tries a page elsewhere (such as https://formate.readthedocs.io/usage.html) the relative target is now wrong, and the browser can't load the stylesheets.
In the Firefox console I see errors like:
Those resources should be loaded from formate.readthedocs.io/en/latest/_static/twemoji.css
, etc.
Hi @domdfcoding! You are right! My solution in #153 does not work for older versions of Sphinx.
an extension adds a css file with
app.add_css_file("my_style.css"
I wrote a test case for this and I opened PR #156 that fixes this problem and should work for all the Sphinx versions. Would you mind giving it a try and let me know if your issue is solved with it?
I was having an issue where stylesheets added with
add_css_file
weren't being handled correctly, since they go through a hardcodedpathto
in sphinx, instead of thectx['pathto']
method.This fixes the issue, but it might also be better fixed upstream in sphinx? I'm not very familiar with the ecosystem, or what sphinx should be doing here.