mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Remove "group" identifier from get_index() entries; let the template figure that out.
This commit is contained in:
@@ -189,7 +189,29 @@ class Domain(object):
|
||||
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
|
||||
|
||||
|
||||
@@ -574,7 +574,6 @@ class PythonDomain(Domain):
|
||||
# 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
|
||||
@@ -601,19 +600,16 @@ class PythonDomain(Domain):
|
||||
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:
|
||||
|
||||
@@ -19,6 +19,8 @@
|
||||
{% endblock %}
|
||||
{% block body %}
|
||||
|
||||
{%- set curr_group = 0 %}
|
||||
|
||||
<h1>{{ indextitle }}</h1>
|
||||
|
||||
<div class="modindex-jumpbox">
|
||||
@@ -33,11 +35,12 @@
|
||||
<tr class="pcap"><td></td><td> </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 %} {% endif %}
|
||||
|
||||
@@ -262,10 +262,13 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
||||
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 = []
|
||||
@@ -968,6 +971,7 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
||||
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:
|
||||
|
||||
@@ -87,7 +87,8 @@ def test_latex(app):
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user