Andrey Popp avatar Andrey Popp committed ba9a367

sort http routing table index by path

Comments (0)

Files changed (1)

httpdomain/sphinxcontrib/httpdomain.py

 
     def generate(self, docnames=None):
         content = {}
-        for method, routes in self.domain.routes.iteritems():
-            for path, info in routes.iteritems():
-                letter = path.split('/', 2)
-                try:
-                    first_letter = letter[1]
-                except IndexError:
-                    first_letter = letter[0]
-                entries = content.setdefault('/' + first_letter, [])
-                entries.append([
-                    method.upper() + ' ' + path, 0, info[0],
-                    http_resource_anchor(method, path), '', '', info[1]
-                ])
+        items = ((method, path, info)
+            for method, routes in self.domain.routes.iteritems()
+            for path, info in routes.iteritems())
+        items = sorted(items, key=lambda item: item[1])
+        for method, path, info in items:
+            letter = path.split('/', 2)
+            try:
+                first_letter = letter[1]
+            except IndexError:
+                first_letter = letter[0]
+            entries = content.setdefault('/' + first_letter, [])
+            entries.append([
+                method.upper() + ' ' + path, 0, info[0],
+                http_resource_anchor(method, path), '', '', info[1]
+            ])
         content = content.items()
         content.sort(key=lambda (k, v): k)
         return (content, True)
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.