executablebooks / sphinx-tabs

Tabbed views for Sphinx
https://sphinx-tabs.readthedocs.io
MIT License
263 stars 67 forks source link

`sphinx-tabs` assets are not removed from pages where `tabs` aren't being used #184

Open peytondmurray opened 8 months ago

peytondmurray commented 8 months ago

Describe the bug

I was in the process of investigating another issue, and I think sphinx-tabs assets are not currently being removed from pages that they should be in v3.4.4. Here's the result of a debugging session:

image

As you can see, the path in context["css_files"] check here is not quite right. path is of type PosixPath, and the only thing contained in context["css_files"] are objects of type sphinx.builders.html._assets._CascadingStyleSheet. If I check the HTML built by sphinx, I can see that the tabs.css is included, confirming the bug:

image

I think what we want here is

if path.suffix == ".css" and path in [Path(f.filename) for f in context["css_files"]]:

Reproduce the bug

I've updated the minimal working example to use the most recent version of sphinx-tabs: https://github.com/peytondmurray/minimalsphinx/tree/per-page-css

List your environment

No response