-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Config to add JS/CSS to all generated HTML pages #9115
Comments
My thought:
|
BTW, a similar thing happens if there is I'm not sure if this should be a separate issue. |
It's a different topic. And it was already posted as #8139. |
Thanks for sharing your thoughts @tk0miya! I think adding something like |
This new method in the `Sphinx` object allows extensions to communicate to Sphinx that it's preferred to include HTML assets in all the pages. However, it's extensions developers' responsability to follow this config and decide whether or not include the assets required. Extensions developers' can check `Sphinx.html_assets_in_all_pages` together with any other logic they may have to decide if the assets will be included in the rendered page or not. Closes sphinx-doc#9115
This new method in the `Sphinx` object allows extensions to communicate to Sphinx that it's preferred to include HTML assets in all the pages. However, it's extensions developers' responsability to follow this config and decide whether or not include the assets required. Extensions developers' can check `Sphinx.html_assets_in_all_pages` together with any other logic they may have to decide if the assets will be included in the rendered page or not. Closes sphinx-doc#9115
@tk0miya I opened a PR with a proposal. Let's see if that's something similar to what you had in mind. Let me know 😄 |
Sphinx v4.1.0 will include `Sphinx.registry.html_assets_policy` that defines the policy to whether include or not HTML assets in pages where the extension is not used. This PR makes usage of this policy to decide if sphinx-tabs assets should be included or not in the page that's being rendered. Reference: sphinx-doc/sphinx#9115
Sphinx v4.1.0 will include `Sphinx.registry.html_assets_policy` that defines the policy to whether include or not HTML assets in pages where the extension is not used. This PR makes usage of this policy to decide if sphinx-tabs assets should be included or not in the page that's being rendered. Reference: sphinx-doc/sphinx#9115
…sets Sphinx v4.1.0 will include `Sphinx.registry.html_assets_policy` that defines the policy to whether include or not HTML assets in pages where the extension is not used. This PR makes usage of this policy to decide if sphinx-tabs assets should be included or not in the page that's being rendered. Reference: sphinx-doc/sphinx#9115
Is your feature request related to a problem? Please describe.
After #8631 was merged, JS/CSS files for MathJax are only added to those pages that contains math formulas. This is not a problem unless you want to embed the content of one of those pages where the JS/CSS are included from a different page.
This problem is clear on my extension
sphinx-hoverxref
that shows a tooltip with the content of the linked page when hovering over a link. Example: if you hover on "tooltip with Mathjax" in https://sphinx-hoverxref.readthedocs.io/en/sphinx-35/usage.html#tooltip-with-mathjax you won't see the MathJax rendered properly inside the tooltipand an error in the console "Not triggering MathJax because it is not defined". This is because MathJax is not included in
usage.html
page but it's included in target page (mathjax.html
)Note that I'm mentioning the problem only with MathJax for now since it's a known extension that it's using this new feature, but this applies to all the extension that start including the JS/CSS only on pages where the extension is present
Describe the solution you'd like
I think a config to force the old behavior that includes all the JS/CSS in all the pages could work. I know this has some drawbacks, but as far is optional, I think it's good.
Describe alternatives you've considered
sphinx-hoverxref
uses an endpoint from Read the Docs' API to get the content to embed in the tooltip. We are discussing if it's possible to return"extras": ["mathjax.js", "mathjax.css"]
together with the content to be included so the JS client knows it has to include these assets before rendering the content. See Embed: design doc for new embed API readthedocs/readthedocs.org#8039 (comment)Additional context
Reference: #8631 (comment)
Downstream issue: readthedocs/sphinx-hoverxref#119
The text was updated successfully, but these errors were encountered: