mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fix bug introduced by relying on quirks of Jinja scoping.
This commit is contained in:
@@ -35,6 +35,15 @@ def accesskey(context, key):
|
||||
return 'accesskey="%s"' % key
|
||||
return ''
|
||||
|
||||
class idgen(object):
|
||||
def __init__(self):
|
||||
self.id = 0
|
||||
def current(self):
|
||||
return self.id
|
||||
def next(self):
|
||||
self.id += 1
|
||||
return self.id
|
||||
|
||||
|
||||
class SphinxFileSystemLoader(FileSystemLoader):
|
||||
"""FileSystemLoader subclass that is not so strict about '..'
|
||||
@@ -100,6 +109,7 @@ class BuiltinTemplateLoader(TemplateBridge, BaseLoader):
|
||||
self.environment.filters['tobool'] = _tobool
|
||||
self.environment.globals['debug'] = contextfunction(pformat)
|
||||
self.environment.globals['accesskey'] = contextfunction(accesskey)
|
||||
self.environment.globals['idgen'] = idgen
|
||||
if use_i18n:
|
||||
self.environment.install_gettext_translations(
|
||||
builder.app.translator)
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
{% endblock %}
|
||||
{% block body %}
|
||||
|
||||
{%- set curr_group = 0 %}
|
||||
{%- set groupid = idgen() %}
|
||||
|
||||
<h1>{{ indextitle }}</h1>
|
||||
|
||||
@@ -33,15 +33,14 @@
|
||||
<table class="indextable modindextable" cellspacing="0" cellpadding="2">
|
||||
{%- for letter, entries in content %}
|
||||
<tr class="pcap"><td></td><td> </td><td></td></tr>
|
||||
<tr class="cap"><td></td><td><a name="cap-{{ letter }}">
|
||||
<tr class="cap"><td></td><td><a name="cap-{{ letter }}" id="cap-{{ letter }}">
|
||||
<strong>{{ letter }}</strong></a></td><td></td></tr>
|
||||
{%- for (name, grouptype, page, anchor, extra, qualifier, description)
|
||||
in entries %}
|
||||
{%- if grouptype == 1 %}{% set curr_group = curr_group + 1 %}{% endif %}
|
||||
<tr{% if grouptype == 2 %} class="cg-{{ curr_group }}"{% endif %}>
|
||||
<tr{% if grouptype == 2 %} class="cg-{{ groupid.current() }}"{% endif %}>
|
||||
<td>{% if grouptype == 1 -%}
|
||||
<img src="{{ pathto('_static/minus.png', 1) }}" id="toggle-{{ curr_group }}"
|
||||
class="toggler" style="display: none" alt="-" />
|
||||
<img src="{{ pathto('_static/minus.png', 1) }}" class="toggler"
|
||||
id="toggle-{{ groupid.next() }}" style="display: none" alt="-" />
|
||||
{%- endif %}</td>
|
||||
<td>{% if grouptype == 2 %} {% endif %}
|
||||
{% if page %}<a href="{{ pathto(page) }}#{{ anchor }}">{% endif -%}
|
||||
|
||||
Reference in New Issue
Block a user