Commits

Anonymous committed 521a48b

Finally I understood how the index is supposed to be generated.
So now it works (more) correctly

Comments (0)

Files changed (1)

sphinx/builders/pdf.py

                 pass
 
 def genindex_nodes(genindexentries):
-    #pprint(genindexentries)
-    def entrytext(entry):
-        txt=[]
-        for item in entry[1:][0]:
-            txt.append("`%s <%s>`_"%(item[0],item[1][0]))
-            if len(item[1]) > 1:
-                for i,extra in enumerate(item[1][1:]):
-                    txt[-1]+=' `[%d] <%s>`_ '%(i+1,extra)
-            print '------------'
-            print "genindex:",txt[-1]
-            print '------------'
-            txt[-1]+='\n\n'
-        return txt
+    pprint(genindexentries)
+    output=['DUMMY','=====','','','INDEX','=====','']
 
-    output=['DUMMY','=====','','','INDEX','=====','']
-    for i in genindexentries:
-        title,entries=i
-        output.append('**%s**'%title)
-        output.append('')
-        for entry in entries:
-            pprint (entry)
-            output.append('\\'.join(entry[0]))
-            output.append('    '+'\n    '.join(entrytext(entry[1])))
+    for key, entries in genindexentries:
+        output.append('.. cssclass:: heading3\n\n%s\n\n'%key) # initial
+        for entryname, (links, subitems) in entries:
+            if links:
+                output.append('`%s <%s>`_'%(entryname,links[0]))
+                for i,link in enumerate(links[1:]):
+                    print '<a href="%s">[%s]</a>'%(link,i)
+            else:
+                output.append(entryname)
+            if subitems:
+                for subentryname, subentrylinks in subitems:
+                    output.append('    `%s <%s>`_'%(subentryname,subentrylinks[0]))
+                    for i,link in enumerate(subentrylinks[1:]):
+                        output.append(' `[%s] <%s>`_'%(i,link))
+                    output.append('')
+            output.append('')
 
     doctree = docutils.core.publish_doctree('\n'.join(output))
     return doctree[1]