readthedocs / sphinx_rtd_theme

Sphinx theme from Read the Docs
https://sphinx-rtd-theme.readthedocs.io/
MIT License
4.81k stars 1.74k forks source link

Search not working in 1.2.0 in environments without web access #1434

Closed tmct closed 2 months ago

tmct commented 1 year ago

Problem

Hi,

When I upgrade to 1.2.0, the "search" feature stops working in airgapped environments. When a search is initiated, it "spins" but does not finish.

Also observed: 1) on load, the webpage tries to access https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js upon load, and this fails in environments with no internet access, as expected 2) "Uncaught ReferenceError: jQuery is not defined" happens when you initiate a search

Reproducible Project

Cannot share, sorry - but it shouldn't matter

Error Logs/Results

See above

Expected Results

Search completes as expected

Environment Info

benjaoming commented 1 year ago

@tmct we forced the version of sphinxcontrib-jquery to exclude 3.0.0 because there were incoming reports that jQuery wasn't loaded in local builds because of an SRI integrity check. See: https://github.com/readthedocs/sphinx_rtd_theme/issues/1420

If you can force-feed pip sphinxcontrib-jquery==3.0.0, you should be able to serve an airgapped build.

This will be finally fixed by a new version of sphinxcontrib-jquery: https://github.com/sphinx-contrib/jquery/pull/14

tmct commented 1 year ago

Thanks very much! I'll keep an eye on that sphinxcontrib-jquery change.

benjaoming commented 1 year ago

@tmct you can also try reinstalling now, that should give you sphinxcontrib-jquery==4.1 which has resolved the issue generally.

gherceg commented 1 year ago

@benjaoming we are experiencing a similar issue, but after upgrading sphinxcontrib-jquery to 4.1 (with sphinx==6.1.3 and sphinx-rtd-theme==1.2), the "Uncaught ReferenceError: jQuery is not defined" error still occurs when using the search bar.

benjaoming commented 1 year ago

@gherceg thanks for the feedback!! do you have a build log, a link to the documentation and/or a git repo that I can have a look at?

gherceg commented 1 year ago

Yeah of course. commcare-hq is the repository, and the docs are here, but notably that docs build is still running sphinxcontrib-jquery==2.0.0, with the same versions for sphinx and sphinx-rtd-theme mentioned above.

benjaoming commented 1 year ago

@gherceg ah! I recognize this issue. Default setups aren't affect by this: We removed html_theme_path from the injected default configuration for Sphinx projects on Read the Docs (because this setting breaks stuff), but very old instructions mentioned to define html_theme_path, so that's probably where you originally got it into your own conf.py. The setting unfortunately switches off the theme's ability to automatically enable the sphinxcontrib-jquery extension, so you either have to enable the extension manually or remove html_theme_path from conf.py. Since it's unnecessary to have this setting, you can just remove it as suggested in https://github.com/dimagi/commcare-hq/pull/32760 :+1:

(after multiple edits: I think it makes sense now, but LMK if there's something unclear)

humitos commented 3 months ago

Is this still an issue? If so, can you point us to a live project hitting this issue (or instructions to reproduce it) ?

LGouellec commented 3 months ago

Try https://lgouellec.github.io/streamiz/index.html, Search "Branch" in the search tab, it "spins" but does not finish. Same for any other words.

humitos commented 3 months ago

@LGouellec what version of the theme are you using? what's the version of Sphinx itself? Can you try using the latest version of the theme?

LGouellec commented 3 months ago

I tried the last one 2.0.0, but without effects

https://github.com/LGouellec/streamiz/blob/master/.github/workflows/gh-pages.yml

humitos commented 3 months ago

@LGouellec the error in the browser's console says: Uncaught ReferenceError: jQuery is not defined. So, I think 2.0.0 is not being installed correctly. What's the output of the build process? Is this one https://github.com/LGouellec/streamiz/actions/runs/10357412706/job/28669387744?

LGouellec commented 3 months ago

@humitos Yes it's this one, full raw logs available here : https://productionresultssa16.blob.core.windows.net/actions-results/30612698-4096-4adc-bf39-e74cb39f2037/workflow-job-run-ef53817e-be1e-5b9f-8d47-e63fd9dfbe04/logs/job/job-logs.txt?rsct=text%2Fplain&se=2024-08-13T22%3A56%3A16Z&sig=Jb7RxTBKatInP8gQ10cAPBnX%2FACCLlw80n1z7RpFuM8%3D&ske=2024-08-14T07%3A52%3A48Z&skoid=ca7593d4-ee42-46cd-af88-8b886a2f84eb&sks=b&skt=2024-08-13T19%3A52%3A48Z&sktid=398a6654-997b-47e9-b12b-9515b896b4de&skv=2024-05-04&sp=r&spr=https&sr=b&st=2024-08-13T22%3A46%3A11Z&sv=2024-05-04

humitos commented 3 months ago

I can't open that URL, AuthenticationFailed

LGouellec commented 3 months ago

0_build-and-deploy.txt

humitos commented 3 months ago

From that build output, everything looks correct to me:

2024-08-12T18:35:05.9826720Z   Downloading sphinx_rtd_theme-2.0.0-py2.py3-none-any.whl.metadata (4.4 kB)
2024-08-12T18:35:06.0110510Z   Downloading sphinxcontrib_jquery-4.1-py2.py3-none-any.whl.metadata (2.6 kB)

I'm not sure why it's not working. If you provide a minimal reproducible example, we can debug further. However, I still think it's a problem in your environment/configuration.

humitos commented 3 months ago

I notice that you don't have the theme added as an extension in https://github.com/LGouellec/streamiz/blob/master/docs/conf.py#L33 as our documentation mentions https://sphinx-rtd-theme.readthedocs.io/en/stable/installing.html. Can you try that?

LGouellec commented 3 months ago

@humitos ,

I have added the extension and now it works ! Thank you for your support.