Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
Add search.html
Browse files Browse the repository at this point in the history
  • Loading branch information
kwankyu committed Aug 1, 2022
1 parent 1274718 commit e5b1f7e
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 24 deletions.
70 changes: 70 additions & 0 deletions src/doc/common/templates-furo/search.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
{#-
The search page template modified from theme/basic/search.html
-#}
{% extends "page.html" %}

{%- block regular_scripts -%}
{{ super() }}
<script src="{{ pathto('_static/searchtools.js', 1) }}"></script>
<script src="{{ pathto('_static/language_data.js', 1) }}"></script>
{%- endblock regular_scripts-%}

{%- block htmltitle -%}
<title>{{ _("Search") }} - {{ docstitle }}</title>
{%- endblock htmltitle -%}

{% block scripts -%}
{{ super() }}
<script src="{{ pathto('searchindex.js', 1) }}"></script>
{%- endblock scripts %}

{% block content %}
<h1 id="search-documentation">{{ _('Search') }}</h1>
{% block scriptwarning %}
<noscript>
<div class="admonition warning">
<p>
{% trans %}Please activate JavaScript to enable the search
functionality.{% endtrans %}
</p>
</div>
</noscript>
{% endblock %}
{% block searchtext %}
<p>
{% trans %}Searching for multiple words only shows matches that contain
all words.{% endtrans %}
</p>
<p>
{% trans %}Note also that you can also call "search_src(...)"
in Sage to search Sage's source code.{% endtrans %}
</p>
{% endblock %}
{% block searchbox %}
<form action="" method="get">
<input type="text" name="q" aria-labelledby="search-documentation" value="" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
<input type="submit" value="{{ _('search') }}" />
<span id="search-progress" style="padding-left: 10px"></span>
</form>
{% endblock %}
{% block searchresults %}
{% if search_performed %}
<h2>{{ _('Search Results') }}</h2>
{% if not search_results %}
<p>{{ _('Your search did not match any documents.') }}</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 %}
{% endblock %}

Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{#-

This is a sidebar brand html modified from Furo's default theme/furo/sidebar/brand.html

The sidebar brand template modified from theme/furo/sidebar/brand.html
-#}
<a class="sidebar-brand{% if logo %} centered{% endif %}" href="{% if refsub %}{{ reference_root }}{% else %}{{ documentation_root }}{% endif %}">
{% block brand_content %}
Expand Down
43 changes: 22 additions & 21 deletions src/sage_docbuild/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,17 @@
import sys
import os
import sphinx

from sage.env import SAGE_DOC_SRC, SAGE_DOC, THEBE_DIR, PPLPY_DOCS, MATHJAX_DIR
from sage.misc.latex_macros import sage_mathjax_macros
import sage.version
from sage.misc.sagedoc import extlinks
import sphinx.ext.intersphinx as intersphinx
import dateutil.parser
import sage.version

from sphinx import highlighting
import sphinx.ext.intersphinx as intersphinx
from IPython.lib.lexers import IPythonConsoleLexer, IPyLexer

from sage.misc.sagedoc import extlinks
from sage.env import SAGE_DOC_SRC, SAGE_DOC, THEBE_DIR, PPLPY_DOCS, MATHJAX_DIR
from sage.misc.latex_macros import sage_mathjax_macros
from sage.features import PythonModule

# General configuration
# ---------------------
Expand Down Expand Up @@ -240,26 +241,24 @@ def set_intersphinx_mappings(app, config):
# Add any paths that contain custom themes here, relative to this directory.
html_theme_path = [os.path.join(SAGE_DOC_SRC, "common", "themes")]

if importlib.util.find_spec("furo") is not None:
if PythonModule("furo").is_present():
# Sphinx theme "furo" does not permit an extension. Do not attempt to make
# a "sage-furo" theme.
html_theme = "furo"

# Theme options are theme-specific and customize the look and feel of
# a theme further. For a list of options available for each theme,
# see the documentation.
html_theme_options = {
# Hide project’s name in the sidebar of the documentation;
# the logo is enough.
# https://pradyunsg.me/furo/customisation/#sidebar-hide-name
"sidebar_hide_name": False,
# Change accent (used for stylising links, sidebar’s content etc)
"light_css_variables": {
"color-brand-primary": "#0f0fff",
"color-brand-content": "#0f0fff",
},
# Add sage logo to sidebar
# https://pradyunsg.me/furo/customisation/logo/#different-logos-for-light-and-dark-mode
"light_logo": "logo_sagemath_black.svg",
"dark_logo": "logo_sagemath.svg",
}

# The name of the Pygments (syntax highlighting) style to use. NOTE: This
# The name of the Pygments (syntax highlighting) style to use. This
# overrides a HTML theme's corresponding setting.
pygments_style = "sphinx"
pygments_dark_style = "monokai"
Expand All @@ -269,15 +268,17 @@ def set_intersphinx_mappings(app, config):
html_css_files = [
'custom-furo.css',
]
# A list of paths that contain extra templates (or templates that overwrite
# builtin/theme-specific templates). Relative paths are taken as relative
# to the configuration directory.
templates_path = [os.path.join(SAGE_DOC_SRC, 'common', 'templates-furo')] + templates_path
else:
# Sage default HTML theme. We use a custom theme to set a Pygments style,
# stylesheet, and insert MathJax macros. See the directory
# doc/common/themes/sage-classic/ for files comprising the custom theme.
# Sage default Sphinx theme.
#
# See the directory doc/common/themes/sage-classic/ for files comprising
# the custom theme.
html_theme = "sage-classic"

# Theme options are theme-specific and customize the look and feel of
# a theme further. For a list of options available for each theme,
# see the documentation.
html_theme_options = {}

# HTML style sheet NOTE: This overrides a HTML theme's corresponding
Expand Down

0 comments on commit e5b1f7e

Please sign in to comment.