Search results shows up with Please activate JavaScript ... error
We have been facing issue with one of the repo where even if javascript is enabled it shows the warning as well as results.
Is this a known issue? If yes, what is is recommended fix? If not, then can any one suggest a fix.
Not sure why you are seeing this. I don't see it. Which browser? Does the same happen when you use a private window (no extensions)?
Its safari Version 16.2 (18614.3.7.1.5). Also it happens in private window.
Do you see it here? https://www.statsmodels.org/stable/search.html?q=ARMAX
No. Also it happens only in a specific repo and other repo is working fine. I checked the conf.py and version its the same.
It does not happen in local but in gitlab pages
I have also encountered this problem. After my testing, I found that the issue does not occur when using Sphinx version less than 6.0. Should sphinx-material consider compatibility with the new version of Sphinx🤣?
yes, it got fixed after i downgraded to 5.3
This indeed looks like a bug in this theme, in combination with a newer Sphinx version. It's visible also in the docs of this theme itself, and it shows up when using support for multiple versions of the docs:
- No warning in the default version: https://bashtage.github.io/sphinx-material/search.html?q=help
- Warning visible in the
develversion: https://bashtage.github.io/sphinx-material/devel/search.html?q=help
It indeed doesn't show up for statsmodels, probably because it uses the JS file version switching rather than the conf.py method: https://bashtage.github.io/sphinx-material/devel/customization.html#using-a-javascript-file.
The problematic fallback code lives here: https://github.com/bashtage/sphinx-material/blob/0d31923e0fb08e85027c3e7f03d12673209872e3/sphinx_material/sphinx_material/search.html#L8. My JS foo is very weak, so not sure how Sphinx 6.x changes could affect that code.
Looks like the issue is that Sphinx 5.0 and later no longer ship jQuery. Installing sphinxcontrib-jquery made the problem disappear.
The issue can be fixed without adding a jQuery dependency by overriding your project's search page template.
Here's one possible solution with a noscript tag.
_templates/search.html:
{%- extends "basic/search.html" %}
{% block body %}
<h1 id="search-documentation">{{ _('Search') }}</h1>
<noscript>
<div id="fallback" class="admonition warning">
<p>
{% trans %}Please activate JavaScript to enable the search
functionality.{% endtrans %}
</p>
</div>
</noscript>
{% if search_performed %}
<h2>{{ _('Search Results') }}</h2>
{% if not search_results %}
<p>{{ _('Your search did not match any documents. Please make sure that all words are spelled correctly and that you\'ve selected enough categories.') }}</p>
{% endif %}
{% endif %}
<div id="search-results">
{% if search_results %}
<ul>
{% for href, caption, context in search_results %}
<li><a href="{{ pathto(item.href) }}">{{ caption }}</a>
<div class="context">{{ context|e }}</div>
</li>
{% endfor %}
</ul>
{% endif %}
</div>
{% endblock %}
(modified from https://github.com/bashtage/sphinx-material/blob/0d31923e0fb08e85027c3e7f03d12673209872e3/sphinx_material/sphinx_material/search.html)
// that is, if you don't need the other place where jQuery is used AFAICS - version dropdown; could be replaced too I guess https://github.com/search?q=repo%3Abashtage%2Fsphinx-material%20%24(&type=code