mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Output each accesskey only once, regardless of the number of relbars.
This commit is contained in:
parent
d31f68be58
commit
af102a2579
@ -26,6 +26,15 @@ def _tobool(val):
|
||||
return val.lower() in ('true', '1', 'yes', 'on')
|
||||
return bool(val)
|
||||
|
||||
def accesskey(context, key):
|
||||
"""Helper to output each access key only once."""
|
||||
if '_accesskeys' not in context:
|
||||
context.vars['_accesskeys'] = {}
|
||||
if key not in context.vars['_accesskeys']:
|
||||
context.vars['_accesskeys'][key] = 1
|
||||
return 'accesskey="%s"' % key
|
||||
return ''
|
||||
|
||||
|
||||
class BuiltinTemplateLoader(TemplateBridge, BaseLoader):
|
||||
"""
|
||||
@ -64,6 +73,7 @@ class BuiltinTemplateLoader(TemplateBridge, BaseLoader):
|
||||
extensions=extensions)
|
||||
self.environment.filters['tobool'] = _tobool
|
||||
self.environment.globals['debug'] = contextfunction(pformat)
|
||||
self.environment.globals['accesskey'] = contextfunction(accesskey)
|
||||
if use_i18n:
|
||||
self.environment.install_gettext_translations(builder.translator)
|
||||
|
||||
|
@ -12,14 +12,14 @@
|
||||
{%- for rellink in rellinks %}
|
||||
<li class="right" {% if loop.first %}style="margin-right: 10px"{% endif %}>
|
||||
<a href="{{ pathto(rellink[0]) }}" title="{{ rellink[1]|striptags }}"
|
||||
accesskey="{{ rellink[2] }}">{{ rellink[3] }}</a>
|
||||
{{ accesskey(rellink[2]) }}>{{ rellink[3] }}</a>
|
||||
{%- if not loop.first %}{{ reldelim2 }}{% endif %}</li>
|
||||
{%- endfor %}
|
||||
{%- block rootrellink %}
|
||||
<li><a href="{{ pathto(master_doc) }}">{{ shorttitle|e }}</a>{{ reldelim1 }}</li>
|
||||
{%- endblock %}
|
||||
{%- for parent in parents %}
|
||||
<li><a href="{{ parent.link|e }}" accesskey="U">{{ parent.title }}</a>{{ reldelim1 }}</li>
|
||||
<li><a href="{{ parent.link|e }}" {% if loop.last %}{{ accesskey("U") }}{% endif %}>{{ parent.title }}</a>{{ reldelim1 }}</li>
|
||||
{%- endfor %}
|
||||
{%- block relbaritems %} {% endblock %}
|
||||
</ul>
|
||||
|
Loading…
Reference in New Issue
Block a user