executablebooks / sphinx-tabs

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

Conflict with pydata-sphinx-theme #180

Closed K20shores closed 9 months ago

K20shores commented 9 months ago

Describe the bug

context When I do use this package with pydata-sphinx-theme, the version switcher for that project does not work.

expectation I expected both packages to work without affecting each other.

bug But instead adding sphinx_tabs.tabs to the extensions, without even using a tab, the version switcher for that package no longer works. I filed an issue on that repository, but I figured it might be useful to have this tracked here as well.

problem This is a problem for people wanting use this package with pydata-sphinx-theme

Reproduce the bug

Just follow the steps listed in this issue

List your environment

No response

welcome[bot] commented 9 months ago

Thanks for opening your first issue here! Engagement like this is essential for open source projects! :hugs:
If you haven't done so already, check out EBP's Code of Conduct. Also, please try to follow the issue template as it helps other community members to contribute more effectively.
If your issue is a feature request, others may react to it, to raise its prominence (see Feature Voting).
Welcome to the EBP community! :tada:

foster999 commented 9 months ago

Thanks for this, what do you mean by version switcher?

K20shores commented 9 months ago

Thanks for this, what do you mean by version switcher?

Here's an example from the theme home page. There's a dropdown you can choose to see document version.

Screenshot 2023-10-05 at 11 53 25 AM

For whatever reason, sphinx tabs prevents something from loading. I'm not positive, but I believe there is a script added to the page which makes a get request for the switcher URL. I don't quite understand how this extension would prevent that, but of the extensions we use in my project, disabling the tabs is the only one that allowed our switcher to show.

mathpl commented 9 months ago

I got the same issue and with a little bit of debugging I think I understand the area of the code that's problematic, I'm not quite sure how to properly solve it as I don't have much experience developing for sphinx. I'll put a PR up with what fixes it for me so you can have a look.

The gist of it is commenting this line https://github.com/executablebooks/sphinx-tabs/blob/v3.4.1/sphinx_tabs/tabs.py#L333 fixes it. Removing https://github.com/executablebooks/sphinx-tabs/blob/v3.4.1/sphinx_tabs/tabs.py#L361 altogether also fixes it.

pydata-sphinx-theme does something a bit unusual with its JS, it's added as inline code without a filename. See: https://github.com/pydata/pydata-sphinx-theme/blob/main/src/pydata_sphinx_theme/__init__.py#L261-L274. It does appear to be supported by sphinx however.

mathpl commented 9 months ago

Proposed fix: https://github.com/executablebooks/sphinx-tabs/pull/181

foster999 commented 9 months ago

Fixed in the latest release, thanks @mathpl 🥳