Commits

Georg Brandl committed a70a990

#523: fixes for qthelp index.

  • Participants
  • Parent commits 19275b6

Comments (0)

Files changed (2)

File sphinx/builders/qthelp.py

 
 
 _idpattern = re.compile(
-    r'(?P<title>.+) (\((?P<id>[\w\.]+)( (?P<descr>\w+))?\))$')
+    r'(?P<title>.+) (\((class in )?(?P<id>[\w\.]+)( (?P<descr>\w+))?\))$')
 
 
 # Qt Help Collection Project (.qhcp).
 
         # keywords
         keywords = []
-        index = self.env.create_index(self)
+        index = self.env.create_index(self, group_entries=False)
         for (key, group) in index:
             for title, (refs, subitems) in group:
                 keywords.extend(self.build_keywords(title, refs, subitems))

File sphinx/environment.py

 
         return rewrite_needed
 
-    def create_index(self, builder, _fixre=re.compile(r'(.*) ([(][^()]*[)])')):
+    def create_index(self, builder, group_entries=True,
+                     _fixre=re.compile(r'(.*) ([(][^()]*[)])')):
         """Create the real index from the collected index entries."""
         new = {}
 
         newlist = new.items()
         newlist.sort(key=keyfunc)
 
-        # fixup entries: transform
-        #   func() (in module foo)
-        #   func() (in module bar)
-        # into
-        #   func()
-        #     (in module foo)
-        #     (in module bar)
-        oldkey = ''
-        oldsubitems = None
-        i = 0
-        while i < len(newlist):
-            key, (targets, subitems) = newlist[i]
-            # cannot move if it has subitems; structure gets too complex
-            if not subitems:
-                m = _fixre.match(key)
-                if m:
-                    if oldkey == m.group(1):
-                        # prefixes match: add entry as subitem of the
-                        # previous entry
-                        oldsubitems.setdefault(m.group(2), [[], {}])[0].\
-                                    extend(targets)
-                        del newlist[i]
-                        continue
-                    oldkey = m.group(1)
-                else:
-                    oldkey = key
-            oldsubitems = subitems
-            i += 1
+        if group_entries:
+            # fixup entries: transform
+            #   func() (in module foo)
+            #   func() (in module bar)
+            # into
+            #   func()
+            #     (in module foo)
+            #     (in module bar)
+            oldkey = ''
+            oldsubitems = None
+            i = 0
+            while i < len(newlist):
+                key, (targets, subitems) = newlist[i]
+                # cannot move if it has subitems; structure gets too complex
+                if not subitems:
+                    m = _fixre.match(key)
+                    if m:
+                        if oldkey == m.group(1):
+                            # prefixes match: add entry as subitem of the
+                            # previous entry
+                            oldsubitems.setdefault(m.group(2), [[], {}])[0].\
+                                        extend(targets)
+                            del newlist[i]
+                            continue
+                        oldkey = m.group(1)
+                    else:
+                        oldkey = key
+                oldsubitems = subitems
+                i += 1
 
         # group the entries by letter
         def keyfunc2((k, v), letters=string.ascii_uppercase + '_'):