diff options
| author | ianb <devnull@localhost> | 2005-05-22 06:25:16 +0000 |
|---|---|---|
| committer | ianb <devnull@localhost> | 2005-05-22 06:25:16 +0000 |
| commit | 3a50de28d713b61aab14bc5b2219b226b4e058b8 (patch) | |
| tree | 27e7fd726bb617b082c04f1996571866c682bfdc /paste/docsupport | |
| parent | 4426ea904aa4c6788d939814b0270d61a92ab67a (diff) | |
| download | paste-3a50de28d713b61aab14bc5b2219b226b4e058b8.tar.gz | |
Added documentation to httpexceptions, and a special extractor for HTTPException subclasses
Diffstat (limited to 'paste/docsupport')
| -rw-r--r-- | paste/docsupport/extract.py | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/paste/docsupport/extract.py b/paste/docsupport/extract.py index e0836df..4e2efe3 100644 --- a/paste/docsupport/extract.py +++ b/paste/docsupport/extract.py @@ -5,6 +5,7 @@ import textwrap import findmodules from paste.docsupport import metadata from paste.util.classinit import ClassInitMeta +from paste.httpexceptions import HTTPException extractors = [] @@ -12,10 +13,14 @@ class Extractor(object): __metaclass__ = ClassInitMeta match_type = None + match_level = None def __classinit__(cls, new_attrs): if cls.__bases__ != (object,): - extractors.append(cls) + if cls.match_level is None: + extractors.append(cls) + else: + extractors.insert(cls.match_level, cls) def __init__(self, obj, context): self.obj = obj @@ -46,7 +51,7 @@ class ModuleExtractor(Extractor): class ClassExtractor(Extractor): - match_type = type + match_type = (type, types.ClassType) def extract(self): self.context.writeheader(self.context.last_name, type='Class') @@ -155,6 +160,20 @@ class MethodExtractor(Extractor): value = self.obj.func_globals[value] return value +class HTTPExtractor(Extractor): + + match_level = 0 + + def extract(self): + self.context.writekey(self.obj.__name__) + self.context.write('%s %s\n' % (self.obj.code, self.obj.title)) + self.context.endkey() + + def applies(cls, obj, context): + return (isinstance(obj, types.ClassType) + and issubclass(obj, HTTPException)) + applies = classmethod(applies) + ############################################################ ## Context ############################################################ |
