Skip to content

Commit

Permalink
Trac #33309: Make Sage documentation functional
Browse files Browse the repository at this point in the history
Sage documentation (website) is currently buggy in many ways.

I tried to fix various defects I noticed, including

- links in navigation bar
- index page, which is now in single column
- sage logo link always goes to the sagemath homepage
- `class` names now look ragged right
- long `Bases` for classes now horizontally scrolled
- updated `sage` theme based on the latest `classic` theme of Sphinx
- renamed `sage` theme to `sage-classic` theme (in anticipation of
alternative themes)
- remove unnecessary `sageref` theme; only use `sage` theme
- remove obsolete `python2.inv` hyperlinks database
- added a new `index.html` which is installed right into the root
directory `SAGE_DOC`.
- adjusted colors to increase contrast among elements
- documentation access from jupyter notebook (this undoes #33206)
- search box works (turned off Thebe)

As noted in the last item above, I turned off Thebe here. Work on
reviving Thebe will continue in #33320 (perhaps very slowly).

To cleanly build the new documentation, try
{{{
$ make doc-uninstall && make doc-html && make doc-pdf
}}}

URL: https://trac.sagemath.org/33309
Reported by: klee
Ticket author(s): Kwankyu Lee
Reviewer(s): Tobias Diez, John Palmieri, François Bissey, Steven Trogdon
  • Loading branch information
Release Manager committed Feb 21, 2022
2 parents 7050541 + acecf84 commit 567da5a
Show file tree
Hide file tree
Showing 50 changed files with 852 additions and 912 deletions.
6 changes: 5 additions & 1 deletion src/doc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,11 @@ doc-pdf-other: doc-html-reference
@if [ -z "$(DOCS)" ]; then echo "Error: './sage --docbuild --all-documents' failed"; exit 1; fi
$(MAKE) SAGE_DOCBUILD_OPTS="$(SAGE_DOCBUILD_OPTS) --no-prune-empty-dirs" $(foreach doc, $(wordlist 2, 100, $(DOCS)), doc-pdf--$(subst /,-,$(doc)))

doc-pdf: doc-pdf-reference doc-pdf-other
# website with pdf links
doc-pdf-website:
cd $(SAGE_ROOT) && ./sage --docbuild website html $(SAGE_DOCBUILD_OPTS)

doc-pdf: doc-pdf-reference doc-pdf-other doc-pdf-website

.PHONY: all clean \
doc-html doc-pdf \
Expand Down
Binary file removed src/doc/common/python2.inv
Binary file not shown.
69 changes: 69 additions & 0 deletions src/doc/common/themes/sage-classic/genindex-single.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{#
This is a customized version for Sage documentation theme.

Changes: at line 42, "slice(2)" -> "slice(1)"
#}

{#
basic/genindex-single.html
~~~~~~~~~~~~~~~~~~~~~~~~~~

Template for a "single" page of a split index.

:copyright: Copyright 2007-2022 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
#}
{% macro indexentries(firstname, links) %}
{%- if links -%}
<a href="{{ links[0][1] }}">
{%- if links[0][0] %}<strong>{% endif -%}
{{ firstname|e }}
{%- if links[0][0] %}</strong>{% endif -%}
</a>

{%- for ismain, link in links[1:] -%}
, <a href="{{ link }}">{% if ismain %}<strong>{% endif -%}
[{{ loop.index }}]
{%- if ismain %}</strong>{% endif -%}
</a>
{%- endfor %}
{%- else %}
{{ firstname|e }}
{%- endif %}
{% endmacro %}

{%- extends "layout.html" %}
{% set title = _('Index') %}
{% block body %}

<h1 id="index">{% trans key=key %}Index &ndash; {{ key }}{% endtrans %}</h1>

<table style="width: 100%" class="indextable"><tr>
{%- for column in entries|slice(1) if column %}
<td style="width: 33%; vertical-align: top;"><ul>
{%- for entryname, (links, subitems, _) in column %}
<li>{{ indexentries(entryname, links) }}
{%- if subitems %}
<ul>
{%- for subentryname, subentrylinks in subitems %}
<li>{{ indexentries(subentryname, subentrylinks) }}</li>
{%- endfor %}
</ul>
{%- endif -%}</li>
{%- endfor %}
</ul></td>
{%- endfor %}
</tr></table>

{% endblock %}

{% block sidebarrel %}
<h4>{{ _('Index') }}</h4>
<p>{% for key, dummy in genindexentries -%}
<a href="{{ pathto('genindex-' + key) }}"><strong>{{ key }}</strong></a>
{% if not loop.last %}| {% endif %}
{%- endfor %}</p>

<p><a href="{{ pathto('genindex-all') }}"><strong>{{ _('Full index on one page') }}</strong></a></p>
{{ super() }}
{% endblock %}
47 changes: 47 additions & 0 deletions src/doc/common/themes/sage-classic/genindex-split.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{#
This is a customized version for Sage documentation theme.

Changes: no change
#}

{#
basic/genindex-split.html
~~~~~~~~~~~~~~~~~~~~~~~~~

Template for a "split" index overview page.

:copyright: Copyright 2007-2022 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
#}
{%- extends "layout.html" %}
{% set title = _('Index') %}
{% block body %}

<h1 id="index">{{ _('Index') }}</h1>

<p>{{ _('Index pages by letter') }}:</p>

<div class="genindex-jumpbox">
<p>{% for key, dummy in genindexentries -%}
<a href="{{ pathto('genindex-' + key) }}"><strong>{{ key }}</strong></a>
{% if not loop.last %}| {% endif %}
{%- endfor %}</p>

<p><a href="{{ pathto('genindex-all') }}"><strong>{{ _('Full index on one page') }}</strong>
({{ _('can be huge') }})</a></p>
</div>

{% endblock %}

{% block sidebarrel %}
{% if split_index %}
<h4>Index</h4>
<p>{% for key, dummy in genindexentries -%}
<a href="{{ pathto('genindex-' + key) }}"><strong>{{ key }}</strong></a>
{% if not loop.last %}| {% endif %}
{%- endfor %}</p>

<p><a href="{{ pathto('genindex-all') }}"><strong>{{ _('Full index on one page') }}</strong></a></p>
{% endif %}
{{ super() }}
{% endblock %}
82 changes: 82 additions & 0 deletions src/doc/common/themes/sage-classic/genindex.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
{#
This is a customized version for Sage documentation theme.

Changes: at line 52, "slice(2)" -> "slice(1)"
#}

{#
basic/genindex.html
~~~~~~~~~~~~~~~~~~~

Template for an "all-in-one" index.

:copyright: Copyright 2007-2022 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
#}
{%- extends "layout.html" %}
{% set title = _('Index') %}

{% macro indexentries(firstname, links) %}
{%- if links -%}
<a href="{{ links[0][1] }}">
{%- if links[0][0] %}<strong>{% endif -%}
{{ firstname|e }}
{%- if links[0][0] %}</strong>{% endif -%}
</a>

{%- for ismain, link in links[1:] -%}
, <a href="{{ link }}">{% if ismain %}<strong>{% endif -%}
[{{ loop.index }}]
{%- if ismain %}</strong>{% endif -%}
</a>
{%- endfor %}
{%- else %}
{{ firstname|e }}
{%- endif %}
{% endmacro %}

{% block body %}

<h1 id="index">{{ _('Index') }}</h1>

<div class="genindex-jumpbox">
{% for key, dummy in genindexentries -%}
<a href="#{{ key }}"><strong>{{ key }}</strong></a>
{% if not loop.last %}| {% endif %}
{%- endfor %}
</div>

{%- for key, entries in genindexentries %}
<h2 id="{{ key }}">{{ key }}</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
{%- for column in entries|slice_index(1) if column %}
<td style="width: 33%; vertical-align: top;"><ul>
{%- for entryname, (links, subitems, _) in column %}
<li>{{ indexentries(entryname, links) }}
{%- if subitems %}
<ul>
{%- for subentryname, subentrylinks in subitems %}
<li>{{ indexentries(subentryname, subentrylinks) }}</li>
{%- endfor %}
</ul>
{%- endif -%}</li>
{%- endfor %}
</ul></td>
{%- endfor %}
</tr></table>
{% endfor %}

{% endblock %}

{% block sidebarrel %}
{% if split_index %}
<h4>{{ _('Index') }}</h4>
<p>{% for key, dummy in genindexentries -%}
<a href="{{ pathto('genindex-' + key) }}"><strong>{{ key }}</strong></a>
{% if not loop.last %}| {% endif %}
{%- endfor %}</p>

<p><a href="{{ pathto('genindex-all') }}"><strong>{{ _('Full index on one page') }}</strong></a></p>
{% endif %}
{{ super() }}
{% endblock %}
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
{% extends "basic/layout.html" %}
{% extends "classic/layout.html" %}

{% block rootrellink %}
{% if docstitle.startswith('Sage Documentation') %}
<a href="http://www.sagemath.org"><img src="{{ pathto('_static/logo_sagemath_black.svg', 1) }}" height="28" style="vertical-align: middle" title="Sage Logo"></a>
{% else %}
{% if pathto(master_doc).endswith('.html') %}
<a href="{{ '../' + pathto(master_doc) }}"><img src="{{ pathto('_static/logo_sagemath_black.svg', 1) }}" height="28" style="vertical-align: middle" title="Sage Logo"></a>
<li class="nav-item nav-item-0">
<a href="http://www.sagemath.org"><img src="{{ pathto('_static/logo_sagemath_black.svg', 1) }}" class="sage-logo" title="Sage Logo"></a>
{% if website %}
<a href="index.html">{{ documentation_title|e }}</a>{{ reldelim1 }}
{% else %}
<a href="{{ '../' + pathto(master_doc, 1) + '.html' }}"><img src="{{ pathto('_static/logo_sagemath_black.svg', 1) }}" height="28" style="vertical-align: middle" title="Sage Logo"></a>
<a href="{{ documentation_root }}">{{ documentation_title|e }}</a>{{ reldelim1 }}
{% if refsub %}
<a href="{{ reference_root }}">{{ reference_title|e }}</a>{{ reldelim1 }}
{% endif %}
<a href="{{ pathto(root_doc)|e }}">{{ shorttitle|e }}</a>{{ reldelim1 }}
{% endif %}
{% endif %}
{{ super() }}
</li>
{% endblock %}

{% block extrahead %}
<link rel="icon" href="{{ pathto('_static/sageicon.png', 1) }}" type="image/x-icon" />
<script src="{{ pathto('_static/thebe.js', 1) }}" type="text/javascript"></script>
<script src="{{ pathto('_static/thebe-sage.js', 1) }}" type="text/javascript"></script>
<!-- <script src="{{ pathto('_static/thebe.js', 1) }}" type="text/javascript"></script> -->
<!-- <script src="{{ pathto('_static/thebe-sage.js', 1) }}" type="text/javascript"></script> -->
{% endblock %}

{%- block footer %}
Expand Down Expand Up @@ -107,8 +109,8 @@
{%- endblock %}

<!-- This macro block for the sidebar is heavily borrowed from the basic -->
<!-- theme of Sphinx 0.6.3. In particular, we borrowed from the file -->
<!-- themes/basic/layout.html distributed with Sphinx 0.6.3. -->
<!-- theme of Sphinx. In particular, we borrowed from the file -->
<!-- themes/basic/layout.html distributed with Sphinx. -->
{%- macro sidebar() %}
{%- if not embedded %}{% if not theme_nosidebar|tobool %}
<div class="sphinxsidebar">
Expand Down Expand Up @@ -151,24 +153,24 @@ <h3>{{ _('This Page') }}</h3>
{% include customsidebar %}
{%- endif %}
{%- block sidebarsearch %}
{%- if pagename != "search" %}
<div id="searchbox" style="display: none">
<h3>{{ _('Quick search') }}</h3>
<form class="search" action="{{ pathto('search') }}" method="get">
<input type="text" name="q" size="18" />
<!-- The shading of the "Go" button should be consistent -->
<!-- with the colour of the header and footer. See the file -->
<!-- doc/common/themes/sage/theme.conf for colours used by -->
<!-- the Sage theme. -->
<input type="submit" style="background-color: #B8B9F6" value="{{ _('Go') }}" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
<p class="searchtip" style="font-size: 90%">
{{ _('Enter search terms or a module, class or function name.') }}
</p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
{%- if pagename != "search" and builder != "singlehtml" %}
<div id="searchbox" style="display: none" role="search">
<h3 id="searchlabel">{{ _('Quick search') }}</h3>
<div class="searchformwrapper">
<form class="search" action="{{ pathto('search') }}" method="get">
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
<!-- The shading of the "Go" button should be consistent -->
<!-- with the colour of the header and footer. See the file -->
<!-- doc/common/themes/sage/theme.conf for colours used by -->
<!-- the Sage theme. -->
<input type="submit" style="background-color: #B8B9F6" value="{{ _('Go') }}" />
</form>
<p class="searchtip" style="font-size: 90%">
{{ _('Enter search terms or a module, class or function name.') }}
</p>
</div>
</div>
<script>$('#searchbox').show(0);</script>
{%- endif %}
{%- endblock %}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,49 +4,54 @@

Template for the search page.

:copyright: Copyright 2007-2011 by the Sphinx team, see AUTHORS.
:copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
#}
{% extends "layout.html" %}
{%- extends "layout.html" %}
{% set title = _('Search') %}
{%- block scripts %}
{{ super() }}
<script type="text/javascript" src="{{ pathto('_static/searchtools.js', 1) }}"></script>
<script src="{{ pathto('_static/searchtools.js', 1) }}"></script>
<script src="{{ pathto('_static/language_data.js', 1) }}"></script>
{%- endblock %}
{% block extrahead %}
<script type="text/javascript">
jQuery(function() { Search.loadIndex("{{ pathto('searchindex.js', 1) }}"); });
</script>
<script src="{{ pathto('searchindex.js', 1) }}" defer></script>
{{ super() }}
{% endblock %}
{% block body %}
<h1 id="search-documentation">{{ _('Search') }}</h1>
<div id="fallback" class="admonition warning">
<script type="text/javascript">$('#fallback').hide();</script>
{% 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 %}From here you can search these documents. Enter your search
words into the box below and click "search". Note that the search
function will automatically search for all of the words. Pages
containing fewer words won't appear in the result list.{% endtrans %}
{% 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(...)"
while running Sage to search Sage's source code.{% endtrans %}
</p>
{% endblock %}
{% block searchbox %}
<form action="" method="get">
<input type="text" name="q" value="" />
<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 results.') }}</p>
<p>{{ _('Your search did not match any documents.') }}</p>
{% endif %}
{% endif %}
<div id="search-results">
Expand All @@ -60,4 +65,6 @@ <h2>{{ _('Search Results') }}</h2>
</ul>
{% endif %}
</div>
{% endblock %}
{% endblock %}

File renamed without changes
Loading

0 comments on commit 567da5a

Please sign in to comment.