-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Do not assign html_theme_path #9654
Do not assign html_theme_path #9654
Conversation
…ady defined. This pattern overrules the theme's setup(app)
I asked on IRC #sphinx-doc and got this crystal-clear response:
|
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.
I want to mention some things here:
- I don't have a full understanding of this template
conf.py
file - This file is used for all the projects on Read the Docs that uses Sphinx to build their docs (it's appended to their own
conf.py
file) - Touching this file will have a pretty big impact on all those projects
That said, is this change required? What are the benefits of it? I'd not jump into this deep research that involves some risk of breaking people's builds if it's not strongly required for a particular reason 😄
Touching I think it's a bit of a messy situation to not know if For the theme's |
Another note on this: There seems to be an instruction for See: https://sphinx-rtd-theme.readthedocs.io/en/1.0.0/installing.html#installation The instructions mention translations as a reason to include it in |
For Sphinx 6 setups, the theme is now dependent on |
On a local build, I tested that the theme is correctly enabled with a configuration that sets The configuration did not add |
…ttings-template-remove-html_theme_path
…:benjaoming/readthedocs.org into settings-template-remove-html_theme_path
Tested on a local RTD server with tutorial-template -- this project has neither .readthedocs.yaml nor requirements.txt. Its conf.py is minimal.
|
@benjaoming I understand that we need this PR for Sphinx 6.x to work properly with our own theme because we depend on calling My concerns raised in #9654 (review) are still valid. If we want to move forward with these changes, we should make them in a progressive way, starting by making them under a feature flag. Also, in case this change only affect people with Sphinx >6.x, we can add that restriction as well. My point here is to reduce the risk/impact of something that looks like a simple change but affect all the builds for all the projects. |
That is the most urgent part for sure! There have been suggestions to use
Nothing about this is simple, in fact it has already taken a lot of time :) It'd be great to remove this bit-by-bit with a feature flag. I'd like to end up having it completely removed, though. Could launch with a
Deprecation notice *)In order to figure out what is being deprecated and give users the right notice, we need to figure out why |
@benjaoming and I chatted briefly on this one. The big thing is that this issue probably should block a sphinx_rtd_theme 1.2.0 release, as anyone using Sphinx 6 will immediately hit this issue. The effect is JS silently breaking, so our flyout will just stop working -- very easy to miss. A couple more notes:
Me neither 😬 +1 on being careful here. I think this logic was added/removed because Sphinx included rtd_theme as a dependency for a few releases -- without looking, 1.3-2.0? Gating this logic change on Sphinx version seems wise 👍 That might be enough for me, but I'm not opposed to a feature flag too. I'll add: we might want to just ensure Would that make us feel better about this change? I'm not sure exactly what this looks like, but it would be more than relying on Sphinx to do the right thing. Without some additional logic, my guess is there would still be some Sphinx versions that can't find |
My memory is fuzzy here, but for Sphinx releases where sphinx_rtd_theme was not a dependency, Sphinx did not know how to find the theme path. This was likely before we suggested executing the theme as an extension, and so the logic in our theme extension code wouldn't have been used: |
This confuses me a little. We are not currently doing this check, so this will be a new approach, right? I'm just proposing to keep the same code we have now for all the projects except they have a feature flag enabled or they are using Sphinx >= 6: diff --git a/readthedocs/doc_builder/templates/doc_builder/conf.py.tmpl b/readthedocs/doc_builder/templates/doc_builder/conf.py.tmpl
index 05bd3f0e0..fe3ba6734 100644
--- a/readthedocs/doc_builder/templates/doc_builder/conf.py.tmpl
+++ b/readthedocs/doc_builder/templates/doc_builder/conf.py.tmpl
@@ -58,10 +58,10 @@ using_rtd_theme = (
) or 'html_theme' not in globals()
)
if using_rtd_theme:
- theme = importlib.import_module('{{ html_theme_import }}')
html_theme = '{{ html_theme }}'
html_style = None
html_theme_options = {}
+ if ({{ project.has_feature(Feature.OVERWRITE_HTML_THEME_PATH) }} and not sphinx.version_info >= (6, 0, 0)) or sphinx.version_info < (6, 0, 0):
if 'html_theme_path' in globals():
html_theme_path.append(theme.get_html_theme_path())
else:
|
Yes - while it might work, I also find it hacky and potentially having other side-effects. Ideally, we take an approach that can give us less headache in the future. I would prefer what you suggest @humitos , essentially gating the Sphinx version -- it's much more clear what is happening in this case. It also acts as a parameter -- as our knowledge of the issue is more firm and while we might add deprecation announcements or warnings, we can lower our threshold to include Sphinx 5.. and then ultimately eliminate setting |
Correct. Instead of implicitly addressing the Spinx 6 behavior change, we'd explicitly address it. That is, removing Removing this logic when using Sphinx 6 is definitely fine for now, but I do think we'll want a longer term solution here. I'm doubtful we can get away with removing this logic for all Sphinx versions. So, I'd lean towards using Sphinx version as the conditional here I suppose. The problem is that we likely can't remove |
…_SPHINX_HTML_THEME_PATH`, documentation and code comments
If you can describe what are those installation methods, we can probably use Telemetry to track them to eventually communicate with the authors and start deprecating old patterns. We've hit this problem about "avoid moving forward" or "moving forward is so complex" because supporting pretty old stuffs. (note that I don't have a full understanding of the whole situation here --theme, conf.py, installation methods, etc-- but I think we've bitten by this situation multiple times) |
@humitos it's because essentially the same broken config containing It would be really nice if you can see how many conf.py files that contain Such setups won't appear broken before they start building with Sphinx 6 and jQuery is missing -- but in principle they are already broken, the effects are very very insignificant (example is the pilcrow, see this pr) In the code comment, I try to describe this with a link to an example of where this setup originates from: https://github.com/readthedocs/readthedocs.org/pull/9654/files#diff-184ae94fa10f0076a33752ab9d4c4e9fc5081d754a158cd5c3f903637e32c935R64-R79 |
@agjohnson in case you haven't noticed, this PR has been updated. |
The case is anyone setting the |
|
Why limit the amount of telemetry data we're collecting to this? Our telemetry data already stores package versions, it just doesn't store this configuration option, that I could find. With the addition of tracking |
Not meant to limit it - it just seems to be the most important segment, since those are the intersections where we know things will be broken. |
I'm not sure how to track this, since we are already defining it. So, I'm not sure how we can differentiate if it's the user who declared the variable or if it's us. If you have an idea for this, I'm happy to expand our telemetry to save it somehow. |
I don't want to continue sidetracking this issue, we can discuss metrics later. This bug will be one we need to monitor anyways. We can return to metrics collection next.
I wasn't sure either. If we're getting similar values after the configuration is loaded in Sphinx, we could store a copy of the original value of
We can just query this segment in Metabase, we have the data to correlate versions. We're better off with more data collection around builds in general. |
…ttings-template-remove-html_theme_path
Co-authored-by: Anthony <[email protected]>
…:benjaoming/readthedocs.org into settings-template-remove-html_theme_path
# This following legacy behavior will gradually be sliced out until its deprecated and removed. | ||
# Skipped for Sphinx 6+ | ||
# Skipped by internal Feature flag SKIP_SPHINX_HTML_THEME_PATH | ||
# Skipped by all new projects since SKIP_SPHINX_HTML_THEME_PATH's introduction (jan 2023) |
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.
@agjohnson I believe we should also do this, just want to make sure that you have seen it. New projects won't follow strange old install guides, and they are likely on later versions of Sphinx.
Aligned with @agjohnson about merging this now 👍 |
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.
Updates look good to go! We have next steps planned already too, we should get an issue up and in our roadmap for these.
Newer versions of sphinx_rtd_theme require to add sphinx_rtd_theme to the list of extensions. Cf. readthedocs/readthedocs.org#9654 Signed-off-by: Heinrich Schuchardt <[email protected]>
Also bump the copyright year. See readthedocs/readthedocs.org#9654 for relevant info.
I would like to have a second 🧠 and 👀 on this:
sphinx_rtd_theme.setup(app)
and thus the logic there is lostLonger story: readthedocs/sphinx_rtd_theme#1355
For reference, here's the full
sphinx_rtd_theme.setup(app)
which we are not calling AFAICT.https://github.com/readthedocs/sphinx_rtd_theme/blob/20607e85259f5a1885505807f932fc16cdad9449/sphinx_rtd_theme/__init__.py#L41-L72
📚 Documentation previews 📚
docs
): https://docs--9654.org.readthedocs.build/en/9654/dev
): https://dev--9654.org.readthedocs.build/en/9654/