Skip to content

Can't find bootstrap or popper in the HTML #176

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

Closed
choldgraf opened this issue May 8, 2020 · 14 comments
Closed

Can't find bootstrap or popper in the HTML #176

choldgraf opened this issue May 8, 2020 · 14 comments

Comments

@choldgraf
Copy link
Collaborator

choldgraf commented May 8, 2020

Maybe I am just being silly, but in the latest version of the theme I can't figure out where popperjs or bootstrapjs is actually loaded. They are there in the pandas docs, but they aren't in the pydata-sphinx-theme. Is there something clever going on that loads these in another fashion?

I realized this because I was trying to add a tooltip to one of my pages, but the function is not defined in the current pydata-sphinx-theme, while it is defined in the pandas docs.

@jorisvandenbossche
Copy link
Member

@hoetmaaiers
Copy link
Collaborator

Correct. This is the webpack way of telling what to include in the final bundle. This could also be done for other type of assets, e.g. css.

@choldgraf
Copy link
Collaborator Author

choldgraf commented May 11, 2020

Thanks for that explanation - makes sense to me. However, it doesn't explain why we have some bootstrap functions in an earlier version of the theme, but we do not have them in a new version of the theme.

Try running $("div").tooltip in:

Tooltips should be a bootstrap feature that relies on popper, but I believe both are in our webpack bundle, right?

@jorisvandenbossche
Copy link
Member

I indeed see the same difference. Running that in the browser console gives undefined for the latest pydata theme docs.

(you are running into this while writing an extension that uses javascript?)

@choldgraf
Copy link
Collaborator Author

well specifically I use tooltips in the sphinx-book-theme, and they don't work anymore :-)

@jorisvandenbossche
Copy link
Member

With https://pydata-sphinx-theme.readthedocs.io/en/v0.2.1/ it still works (I enabled some older versions on readthedocs for easier comparison), so it's probably due to #167

@choldgraf would it be possible to include something small here in the demo docs that uses a tooltip? Or does it need a custom layout?

@choldgraf
Copy link
Collaborator Author

nah it'd be easy - I think it's literally just calling $("some-selector").tooltip() on an element and it will add a tooltip to it (they are pretty nifty!)

@hoetmaaiers
Copy link
Collaborator

I am able to fix this (PR coming up), but I now the following error:

jquery.js:2 Uncaught TypeError: $.getQueryParameters is not a function in doctools..js

After Googling, this issue seems related: sphinx-doc/sphinx#1676.

@choldgraf
Copy link
Collaborator Author

ah so the issue there is double-loading of jQuery?

@jorisvandenbossche
Copy link
Member

And then they say Python packaging is a mess .. ;)

@hoetmaaiers
Copy link
Collaborator

Haha, I'm afraid this is due to a Python package ;).

JQuery is loaded via Sphinx, the same way doctools.js and other Sphinx related scripts are loaded. Somehow this conflicts with the popper.js initialisation not being able to hook into this jQuery instance.

It is harder then I thought to solve. Will look into this further...
The javascript loaded by Sphinx, can we influence this in any way?

@jorisvandenbossche
Copy link
Member

But it's still the javascript inside the python package that is the problem, not the python code! 😃

The javascript loaded by Sphinx, can we influence this in any way?

I am wondering, does the order matter here? We could ensure our js (which included popper) is loaded first, before the sphinx js? (now it is the other way around)

@hoetmaaiers
Copy link
Collaborator

I am unsure if the order is the solution.
A solution would be to load jQuery via Webpack (this does solve the popper thing). By doing this doctools.js breaks, so loading doctools also via Webpack would be necessary.

I look into this somewhat further to figure out maybe loading a different kind of module might solve this instance problem.

@jorisvandenbossche
Copy link
Member

This should be closed by #179

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants