-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Override versions.html template for specific RTD functionality #4234
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
Conversation
Sphinx RTD theme uses a `versions.html` template to generate the version menu if `READTHEDOCS` variable is True. Since this is something specific to Read the Docs and that variable is going to be removed soon from the theme, we are overriding this template to maintain our current functionality. Also, the static content generated in this menu is removed to avoid showing invalid links/data in case the AJAX fails for any reason. If this happen, the menu just won't show any information.
3110434 to
16ea4f4
Compare
| html_context = context | ||
|
|
||
| # Add custom RTD templates | ||
| if using_rtd_theme: |
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.
Overriding the templates only when using our own theme, but what would happen with derivated themes?
They will have the content of the versions.html that comes from our sphinx_rtd_theme instead of this one.
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 is a good question. Maybe through some Sphinx internals we can determine if the theme in use extends our theme at some point? This sounds like a hard and error prone thing to determine though.
Ultimately, this might be a really good reason to keep this logic in our theme. The work required to replicate if READTHEDOCS is going to be substantial. Even if removing READTHEDOCS from our theme is technically correct, leaving it is the right thing to do.
|
This overrides works in the community and the corporate site without modification. |
agjohnson
left a comment
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 implementation looks great, but I think you've raised another good reason to keep this logic in our theme.
|
I don't think this is a reason to not have this logic live outside the RTD theme. I think a reasonable approach would be:
I think that gets everything we want, unless I'm mistaken? |
|
@ericholscher replacing the The only problem that I see there is that the default content of that block is only valid for Read the Docs, then the user from outside RTD will need to override the template and use an empty block. Just to be clear, is people building docs with
What about the other way around of what I proposed in readthedocs/sphinx_rtd_theme#578? Instead of having a With the above proposal, we will have:
What do you think? |
|
@humitos why can't we just allow people building outside of RTD to use their own |
|
I think maybe we should have a quick call about this to discuss. I think there are a number of competing priorities here, and it might be easier this way :) |
| else: | ||
| html_context = context | ||
|
|
||
| # Add custom RTD templates |
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.
We were talking to move this code into the extra_context block and use it in the corporate site.
|
I'm closing this as stale. I suppose that before we find a good way to do this we will end up having APIv3 with a flyout rendered via a JSON response. |
Sphinx RTD theme uses a
versions.htmltemplate to generate the version menu ifREADTHEDOCSvariable is True. Since this is something specific to Read the Docs and that variable is going to be removed soon from the theme, we are overriding this template to maintain our current functionality.Also, the static content generated in this menu is removed to avoid showing invalid links/data in case the AJAX fails for any reason. If this happen, the menu just won't show any information.
Related readthedocs/sphinx_rtd_theme#578