Skip to content
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

Build does not include searchtools.js #832

Closed
csezenoglu opened this issue Oct 16, 2019 · 5 comments
Closed

Build does not include searchtools.js #832

csezenoglu opened this issue Oct 16, 2019 · 5 comments
Labels
Needed: more information A reply from issue author is required Support Support question

Comments

@csezenoglu
Copy link

csezenoglu commented Oct 16, 2019

Problem

When I build my project, search.html file does not include _static/searchtools.js script in the head section. So, I cannot use search in offline mode.

Reproducible Project

Here is head section of search.html file that build in my locale.

  <head>
  <meta charset="utf-8">
  
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  
  <title>Search &mdash; Permanent Magnet Machines 1.0 documentation</title>

  <script type="text/javascript" src="_static/js/modernizr.min.js"></script>
    
  <script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
        <script type="text/javascript" src="_static/jquery.js"></script>
        <script type="text/javascript" src="_static/underscore.js"></script>
        <script type="text/javascript" src="_static/doctools.js"></script>
        <script type="text/javascript" src="_static/language_data.js"></script>
        <script type="text/javascript" src="_static/js\rtd_sphinx_search.min.js"></script>
        <script async="async" type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest.js?config=TeX-AMS-MML_HTMLorMML"></script>
    
    <script type="text/javascript" src="_static/js/theme.js"></script>
  
  <link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
  <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
  <link rel="stylesheet" href="_static/theme_overrides.css" type="text/css" />
  <link rel="stylesheet" href="_static/css\rtd_sphinx_search.min.css" type="text/css" />
    <link rel="index" title="Index" href="genindex.html" />
    <link rel="search" title="Search" href="#" /> 
    </head>

Expected Results

These both method works for me:
1- When I manually enter the searchtools.js in the head section of search.html, it works.
2- When I manually change the search.html file in the theme package in the python lib folder like below, it works.

{#
basic/search.html
~~~~~~~~~~~~~~~~~

Template for the search page.

:copyright: Copyright 2007-2013 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
#}
{%- extends "layout.html" %}
{% set title = _('Search') %}
{%- block scripts %}
    {{ super() }}
    <script type="text/javascript" src="{{ pathto('_static/searchtools.js', 1) }}"></script>
{%- endblock %}
{% block footer %}
  <script type="text/javascript" src="{{ pathto('_static/searchtools.js', 1) }}"></script>
  <script type="text/javascript">
    jQuery(function() { Search.loadIndex("{{ pathto('searchindex.js', 1) }}"); });
  </script>
  {# this is used when loading the search index using $.ajax fails,
     such as on Chrome for documents on localhost #}
  <script type="text/javascript" id="searchindexloader"></script>
  {{ super() }}
{% endblock %}
...

Environment Info

I have just updated all python packages.

@agjohnson
Copy link
Collaborator

More information is probably needed to help diagnose your issue. On the latest commit, I get a _static/searchtools.js as expected.

Can you give more information on what you're doing, what versions you're using, and a minimal reproducible example?

@agjohnson agjohnson added Needed: more information A reply from issue author is required Support Support question labels Oct 18, 2019
@csezenoglu
Copy link
Author

I am not sure how did i fix it. Now, it works. If I'm sure, i will comment it.

@chausner-audeering
Copy link

@csezenoglu Did you ever find out what fixed this? I am running into the same issue with our own Sphinx theme which is based on this one.

@csezenoglu
Copy link
Author

@chausner-audeering I could not remember exactly but could you please try update the theme and delete _build folder and rebuild.

@chausner-audeering
Copy link

chausner-audeering commented Nov 25, 2020

We were able to fix it in our custom theme (which is based on sphinx-rtd-theme). The problem was that

<script type="text/javascript" src="{{ pathto('_static/searchtools.js', 1) }}"></script>

is inside a {%- block scripts %} in search.html but this block was not defined in layout.html of our theme.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needed: more information A reply from issue author is required Support Support question
Projects
None yet
Development

No branches or pull requests

3 participants