Skip to content

Add Sphinx.add_html_assets_in_all_pages#9174

Merged
tk0miya merged 4 commits intosphinx-doc:4.xfrom
humitos:humitos/add-html-assets-in-all-pages
Jul 4, 2021
Merged

Add Sphinx.add_html_assets_in_all_pages#9174
tk0miya merged 4 commits intosphinx-doc:4.xfrom
humitos:humitos/add-html-assets-in-all-pages

Conversation

@humitos
Copy link
Contributor

@humitos humitos commented May 6, 2021

Subject: Add an API to enable including assets in all HTML pages.

Feature or Bugfix

  • Feature

Purpose

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' responsibility to follow this config and decide whether or not to 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.

Relates

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 tk0miya added this to the 4.1.0 milestone May 12, 2021

domain = cast(MathDomain, app.env.get_domain('math'))
if domain.has_equations(pagename):
if app.registry.html_assets_policy == 'always' or domain.has_equations(pagename):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tk0miya I don't like too much how this line is checking for the always policy. Do you have a better suggestion for this?

@Daltz333
Copy link

Daltz333 commented Jul 4, 2021

Any bump on this? This PR is probably the only blocker on my team for migration to Sphinx 4.0

@tk0miya tk0miya merged commit 186bbc1 into sphinx-doc:4.x Jul 4, 2021
@tk0miya
Copy link
Member

tk0miya commented Jul 4, 2021

Merged. Thank you for your work!

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 4, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Config to add JS/CSS to all generated HTML pages

4 participants