Commits

stephan preeker  committed b9dffe9

generated documentation now works for all handlers docs are ordered.

  • Participants
  • Parent commits fd75ec2

Comments (0)

Files changed (2)

File piston/doc.py

 import inspect, handler
 
 from piston.handler import typemapper
+from piston.handler import handler_tracker
 
 from django.core.urlresolvers import get_resolver, get_callable, get_script_prefix
 from django.shortcuts import render_to_response
     """
     docs = [ ]
 
-    for handler, (model, anonymous) in typemapper.iteritems():
+    for handler in handler_tracker: 
         docs.append(generate_doc(handler))
-        
+
+    def _compare(doc1, doc2): 
+       #handlers and their anonymous counterparts are put next to each other.
+       name1 = doc1.name.replace("Anonymous", "")
+       name2 = doc2.name.replace("Anonymous", "")
+       return cmp(name1, name2)    
+ 
+    docs.sort(_compare)
+       
     return render_to_response('documentation.html', 
         { 'docs': docs }, RequestContext(request))

File piston/handler.py

 from django.core.exceptions import ObjectDoesNotExist, MultipleObjectsReturned
 
 typemapper = { }
+handler_tracker = [ ]
 
 class HandlerMetaClass(type):
     """
         if hasattr(new_cls, 'model'):
             typemapper[new_cls] = (new_cls.model, new_cls.is_anonymous)
         
+        if name not in ('BaseHandler', 'AnonymousBaseHandler'):
+            handler_tracker.append(new_cls)
+
         return new_cls
 
 class BaseHandler(object):