Commits

Georg Brandl committed 684d36c

Remove "group" identifier from get_index() entries; let the template figure that out.

  • Participants
  • Parent commits 5925727

Comments (0)

Files changed (5)

sphinx/domains/__init__.py

         Return entries for the index given by *name*.  If *docnames* is given,
         restrict to entries referring to these docnames.
 
-        XXX document return format
+        The return value is a tuple of ``(content, collapse)``, where *collapse*
+        is a boolean that determines if sub-entries should start collapsed (for
+        output formats that support collapsing sub-entries).
+
+        *content* is a sequence of ``(letter, entries)`` tuples, where *letter*
+        is the "heading" for the given *entries*, usually the starting letter.
+
+        *entries* is a sequence of single entries, where a single entry is a
+        sequence ``[name, subtype, docname, anchor, extra, qualifier, descr]``.
+        The items in this sequence have the following meaning:
+
+        - `name` -- the name of the index entry to be displayed
+        - `subtype` -- sub-entry related type:
+          0 -- normal entry
+          1 -- entry with sub-entries
+          2 -- sub-entry
+        - `docname` -- docname where the entry is located
+        - `anchor` -- anchor for the entry within `docname`
+        - `extra` -- extra info for the entry
+        - `qualifier` -- qualifier for the description
+        - `descr` -- description for the entry
+
+        Qualifier and description are not rendered e.g. in LaTeX output.
         """
         return [], False
 

sphinx/domains/python.py

         # sort out collapsable modules
         prev_modname = ''
         num_toplevels = 0
-        current_group = 0 # collapse group
         for modname, (docname, synopsis, platforms, deprecated) in modules:
             if docnames and docname not in docnames:
                 continue
                     entries[-1][1] = 1
                 elif not prev_modname.startswith(package):
                     # submodule without parent in list, add dummy entry
-                    current_group += 1
-                    entries.append([stripped + package, 1, current_group,
-                                    '', '', '', '', ''])
-                grouptype = 2
+                    entries.append([stripped + package, 1, '', '', '', '', ''])
+                subtype = 2
             else:
                 num_toplevels += 1
-                current_group += 1
-                grouptype = 0
+                subtype = 0
 
             qualifier = deprecated and _('Deprecated') or ''
-            entries.append([stripped + modname, grouptype, current_group,
-                            docname, 'module-' + stripped + modname,
-                            platforms, qualifier, synopsis])
+            entries.append([stripped + modname, subtype, docname,
+                            'module-' + stripped + modname, platforms,
+                            qualifier, synopsis])
             prev_modname = modname
 
         # apply heuristics when to collapse modindex at page load:

sphinx/themes/basic/domainindex.html

 {% endblock %}
 {% block body %}
 
+   {%- set curr_group = 0 %}
+
    <h1>{{ indextitle }}</h1>
 
    <div class="modindex-jumpbox">
      <tr class="pcap"><td></td><td>&nbsp;</td><td></td></tr>
      <tr class="cap"><td></td><td><a name="cap-{{ letter }}">
            <strong>{{ letter }}</strong></a></td><td></td></tr>
-     {%- for (name, grouptype, group, page, anchor, extra, qualifier, description)
+     {%- for (name, grouptype, page, anchor, extra, qualifier, description)
              in entries %}
-     <tr{% if grouptype == 2 %} class="cg-{{ cgroup }}"{% endif %}>
+     {%- if grouptype == 1 %}{% set curr_group = curr_group + 1 %}{% endif %}
+     <tr{% if grouptype == 2 %} class="cg-{{ curr_group }}"{% endif %}>
        <td>{% if grouptype == 1 -%}
-         <img src="{{ pathto('_static/minus.png', 1) }}" id="toggle-{{ group }}"
+         <img src="{{ pathto('_static/minus.png', 1) }}" id="toggle-{{ curr_group }}"
               class="toggler" style="display: none" alt="-" />
            {%- endif %}</td>
        <td>{% if grouptype == 2 %}&nbsp;&nbsp;&nbsp;{% endif %}

sphinx/writers/latex.py

                     ret.append('\\indexspace\n')
                 ret.append('\\bigletter{%s}\n' % letter)
                 for entry in entries:
-                    if not entry[4]:
+                    if not entry[3]:
                         continue
-                    ret.append('\\item {\\texttt{%s}}, \\pageref{%s}' %
-                               (self.encode(entry[0]), entry[4]))
+                    ret.append('\\item {\\texttt{%s}}' % self.encode(entry[0]))
+                    if entry[4]:
+                        # add "extra" info
+                        ret.append(' \\emph{(%s)}' % self.encode(entry[4]))
+                    ret.append(', \\pageref{%s}' % self.idescape(entry[3]))
             ret.append('\\end{theindex}\n')
 
         ret = []
             try:
                 next = node.parent[parindex+1]
                 if isinstance(next, nodes.section):
+                    # postpone the label until after the sectioning command
                     self.next_section_target = node['refid']
                     return
             except IndexError:

tests/test_build_latex.py

             stdout, stderr = p.communicate()
             if p.returncode != 0:
                 print stdout
+                print stderr
                 del app.cleanup_trees[:]
-                assert False, 'latex exited with error'
+                assert False, 'latex exited with return code %s' % p.returncode
     finally:
         os.chdir(cwd)