Georg Brandl avatar Georg Brandl committed 519855c

Fix bug introduced by relying on quirks of Jinja scoping.

Comments (0)

Files changed (2)

sphinx/jinja2glue.py

         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 '..'
         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)

sphinx/themes/basic/domainindex.html

 {% endblock %}
 {% block body %}
 
-   {%- set curr_group = 0 %}
+   {%- set groupid = idgen() %}
 
    <h1>{{ indextitle }}</h1>
 
    <table class="indextable modindextable" cellspacing="0" cellpadding="2">
    {%- for letter, entries in content %}
      <tr class="pcap"><td></td><td>&nbsp;</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 %}&nbsp;&nbsp;&nbsp;{% endif %}
        {% if page %}<a href="{{ pathto(page) }}#{{ anchor }}">{% endif -%}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.