diff --git a/_static/css/algolia.css b/_static/css/algolia.css new file mode 100644 index 000000000..851bea22d --- /dev/null +++ b/_static/css/algolia.css @@ -0,0 +1,6 @@ +.wy-nav-side { overflow: visible; } +.wy-side-scroll { overflow: inherit; } + +.algolia-autocomplete { + display: block !important; +} diff --git a/_static/js/algolia.js b/_static/js/algolia.js new file mode 100644 index 000000000..55697a2ba --- /dev/null +++ b/_static/js/algolia.js @@ -0,0 +1,22 @@ + +(function() { + + var doc_version = document.querySelector('meta[name="doc_version"]').getAttribute('content'); + + // Initialize the Algolia search widget + docsearch({ + apiKey: 'c39cb614363a2a156811478bc2d0573b', + indexName: 'godotengine', + inputSelector: '#rtd-search-form input[type=text]', + algoliaOptions: { + facetFilters: ["version:" + (doc_version || 'stable')] + }, + }); + + window.addEventListener('keydown', function(event) { + if (event.key === '/') { + document.querySelector('#rtd-search-form input[type=text]').focus(); + event.preventDefault(); + } + }) +})(); diff --git a/_templates/layout.html b/_templates/layout.html index fdec13a7b..9cafebd1d 100644 --- a/_templates/layout.html +++ b/_templates/layout.html @@ -1,4 +1,9 @@ {% extends "!layout.html" -%} + +{% block extrahead -%} + +{% endblock -%} + {% block linktags -%} {% if godot_inject_language_links -%} diff --git a/conf.py b/conf.py index da86ea59e..d3a6ccf35 100644 --- a/conf.py +++ b/conf.py @@ -61,9 +61,6 @@ ogp_site_name = "Godot Engine documentation" if not os.getenv("SPHINX_NO_GDSCRIPT"): extensions.append("gdscript") -if not os.getenv("SPHINX_NO_SEARCH"): - extensions.append("sphinx_search.extension") - if not os.getenv("SPHINX_NO_DESCRIPTIONS"): extensions.append("godot_descriptions") @@ -189,11 +186,15 @@ html_extra_path = ["robots.txt"] # These paths are either relative to html_static_path # or fully qualified paths (e.g. https://...) html_css_files = [ + 'css/algolia.css', + 'https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.css', "css/custom.css", ] html_js_files = [ "js/custom.js", + ('https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.js', {'defer': 'defer'}), + ('js/algolia.js', {'defer': 'defer'}) ] # Output file base name for HTML help builder diff --git a/requirements.txt b/requirements.txt index f371e894f..66621f88f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -15,6 +15,3 @@ sphinx-notfound-page==0.7.1 # Adds Open Graph tags in the HTML `` tag sphinxext-opengraph==0.4.2 - -# Full-page search UI for RTD: https://readthedocs-sphinx-search.readthedocs.io -readthedocs-sphinx-search==0.1.0