mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Compile the right-aligned rellinks into a list that is iterated
over at template rendering time.
This commit is contained in:
parent
4623a3369c
commit
02d8c50b50
@ -358,6 +358,12 @@ class StandaloneHTMLBuilder(Builder):
|
|||||||
|
|
||||||
self.relations = self.env.collect_relations()
|
self.relations = self.env.collect_relations()
|
||||||
|
|
||||||
|
rellinks = []
|
||||||
|
if self.config.html_use_index:
|
||||||
|
rellinks.append(('genindex', 'General Index', 'I', 'index'))
|
||||||
|
if self.config.html_use_modindex:
|
||||||
|
rellinks.append(('modindex', 'Global Module Index', 'M', 'modules'))
|
||||||
|
|
||||||
self.globalcontext = dict(
|
self.globalcontext = dict(
|
||||||
project = self.config.project,
|
project = self.config.project,
|
||||||
release = self.config.release,
|
release = self.config.release,
|
||||||
@ -365,12 +371,11 @@ class StandaloneHTMLBuilder(Builder):
|
|||||||
last_updated = self.last_updated,
|
last_updated = self.last_updated,
|
||||||
copyright = self.config.copyright,
|
copyright = self.config.copyright,
|
||||||
style = self.config.html_style,
|
style = self.config.html_style,
|
||||||
use_modindex = self.config.html_use_modindex,
|
|
||||||
use_index = self.config.html_use_index,
|
|
||||||
use_opensearch = self.config.html_use_opensearch,
|
use_opensearch = self.config.html_use_opensearch,
|
||||||
docstitle = self.config.html_title,
|
docstitle = self.config.html_title,
|
||||||
shorttitle = self.config.html_short_title,
|
shorttitle = self.config.html_short_title,
|
||||||
show_sphinx = self.config.html_show_sphinx,
|
show_sphinx = self.config.html_show_sphinx,
|
||||||
|
rellinks = rellinks,
|
||||||
builder = self.name,
|
builder = self.name,
|
||||||
parents = [],
|
parents = [],
|
||||||
logo = logo,
|
logo = logo,
|
||||||
@ -383,21 +388,24 @@ class StandaloneHTMLBuilder(Builder):
|
|||||||
# find out relations
|
# find out relations
|
||||||
prev = next = None
|
prev = next = None
|
||||||
parents = []
|
parents = []
|
||||||
|
rellinks = self.globalcontext['rellinks'][:]
|
||||||
related = self.relations.get(docname)
|
related = self.relations.get(docname)
|
||||||
titles = self.env.titles
|
titles = self.env.titles
|
||||||
if related and related[1]:
|
|
||||||
try:
|
|
||||||
prev = {'link': self.get_relative_uri(docname, related[1]),
|
|
||||||
'title': self.render_partial(titles[related[1]])['title']}
|
|
||||||
except KeyError:
|
|
||||||
# the relation is (somehow) not in the TOC tree, handle that gracefully
|
|
||||||
prev = None
|
|
||||||
if related and related[2]:
|
if related and related[2]:
|
||||||
try:
|
try:
|
||||||
next = {'link': self.get_relative_uri(docname, related[2]),
|
next = {'link': self.get_relative_uri(docname, related[2]),
|
||||||
'title': self.render_partial(titles[related[2]])['title']}
|
'title': self.render_partial(titles[related[2]])['title']}
|
||||||
|
rellinks.append((related[2], next['title'], 'N', 'next'))
|
||||||
except KeyError:
|
except KeyError:
|
||||||
next = None
|
next = None
|
||||||
|
if related and related[1]:
|
||||||
|
try:
|
||||||
|
prev = {'link': self.get_relative_uri(docname, related[1]),
|
||||||
|
'title': self.render_partial(titles[related[1]])['title']}
|
||||||
|
rellinks.append((related[1], prev['title'], 'P', 'previous'))
|
||||||
|
except KeyError:
|
||||||
|
# the relation is (somehow) not in the TOC tree, handle that gracefully
|
||||||
|
prev = None
|
||||||
while related and related[0]:
|
while related and related[0]:
|
||||||
try:
|
try:
|
||||||
parents.append(
|
parents.append(
|
||||||
@ -427,6 +435,7 @@ class StandaloneHTMLBuilder(Builder):
|
|||||||
title = title,
|
title = title,
|
||||||
meta = meta,
|
meta = meta,
|
||||||
body = body,
|
body = body,
|
||||||
|
rellinks = rellinks,
|
||||||
sourcename = sourcename,
|
sourcename = sourcename,
|
||||||
toc = self.render_partial(self.env.get_toc_for(docname))['fragment'],
|
toc = self.render_partial(self.env.get_toc_for(docname))['fragment'],
|
||||||
# only display a TOC if there's more than one item to show
|
# only display a TOC if there's more than one item to show
|
||||||
|
@ -8,22 +8,12 @@
|
|||||||
<div class="related">
|
<div class="related">
|
||||||
<h3>Navigation</h3>
|
<h3>Navigation</h3>
|
||||||
<ul>
|
<ul>
|
||||||
{%- if use_index %}
|
{%- for rellink in rellinks %}
|
||||||
<li class="right" style="margin-right: 10px"><a href="{{ pathto('genindex') }}" title="General Index" accesskey="I">index</a></li>
|
<li class="right" {% if loop.first %}style="margin-right: 10px"{% endif %}>
|
||||||
{%- endif %}
|
<a href="{{ pathto(rellink[0]) }}" title="{{ rellink[1]|striptags }}"
|
||||||
{%- if use_modindex %}
|
accesskey="{{ rellink[2] }}">{{ rellink[3] }}</a>
|
||||||
<li class="right"><a href="{{ pathto('modindex') }}" title="Global Module Index" accesskey="M">modules</a>{{ reldelim2 }}</li>
|
{%- if not loop.first %}{{ reldelim2 }}{% endif %}</li>
|
||||||
{%- endif %}
|
{%- endfor %}
|
||||||
{%- if next %}
|
|
||||||
<li class="right"><a href="{{ next.link|e }}" title="{{ next.title|striptags }}" accesskey="N">next</a>{{ reldelim2 }}</li>
|
|
||||||
{%- endif %}
|
|
||||||
{%- if prev %}
|
|
||||||
<li class="right"><a href="{{ prev.link|e }}" title="{{ prev.title|striptags }}" accesskey="P">previous</a>{{ reldelim2 }}</li>
|
|
||||||
{%- endif %}
|
|
||||||
{%- if builder == 'web' %}
|
|
||||||
<li class="right"><a href="{{ pathto('settings') }}"
|
|
||||||
title="Customize your viewing settings" accesskey="S">settings</a> |</li>
|
|
||||||
{%- endif %}
|
|
||||||
{%- block rootrellink %}
|
{%- block rootrellink %}
|
||||||
<li><a href="{{ pathto('index') }}">{{ shorttitle }}</a>{{ reldelim1 }}</li>
|
<li><a href="{{ pathto('index') }}">{{ shorttitle }}</a>{{ reldelim1 }}</li>
|
||||||
{%- endblock %}
|
{%- endblock %}
|
||||||
|
Loading…
Reference in New Issue
Block a user