diff options
Diffstat (limited to 'paste/docsupport')
| -rw-r--r-- | paste/docsupport/extract.py | 17 | ||||
| -rw-r--r-- | paste/docsupport/metadata.py | 9 |
2 files changed, 22 insertions, 4 deletions
diff --git a/paste/docsupport/extract.py b/paste/docsupport/extract.py index effd509..e0836df 100644 --- a/paste/docsupport/extract.py +++ b/paste/docsupport/extract.py @@ -115,10 +115,12 @@ class MethodExtractor(Extractor): def extract(self): if not self.obj.__doc__: return - sig = self.make_sig(self.obj) + sig = self.make_sig() self.context.writekey('def %s(%s)' % (self.obj.func_name, sig), monospace=False) self.context.writedoc(self.obj.__doc__) + if self.get_attr('proxy'): + self.context.writedoc(self.get_attr('proxy').__doc__) if getattr(self.obj, 'returns', None): returns = self.obj.returns if isinstance(returns, str): @@ -126,8 +128,10 @@ class MethodExtractor(Extractor): self.context.extract(self.obj.returns) self.context.endkey() - def make_sig(self, func): - args, varargs, varkw, defaults = inspect.getargspec(func) + def make_sig(self): + proxy = self.get_attr('proxy') + args, varargs, varkw, defaults = inspect.getargspec( + proxy or self.obj) sig = [] args.reverse() for arg in args: @@ -143,6 +147,13 @@ class MethodExtractor(Extractor): sig.append('**%s' % varkw) return ', '.join(sig) + def get_attr(self, attr): + if not getattr(self.obj, attr, None): + return None + value = getattr(self.obj, attr) + if isinstance(value, str): + value = self.obj.func_globals[value] + return value ############################################################ ## Context diff --git a/paste/docsupport/metadata.py b/paste/docsupport/metadata.py index aa8879b..2677a0a 100644 --- a/paste/docsupport/metadata.py +++ b/paste/docsupport/metadata.py @@ -1,8 +1,12 @@ +# @@: There are too many imports here; this shouldn't have much +# overhead except during extraction, but everything in this +# module has to be imported regardless. import sys import copy import types import inspect from itertools import count +from paste.util import import_string from paste.util.classinit import ClassInitMeta from paste.util.classinstance import classinstancemethod @@ -30,7 +34,10 @@ class DocItem(object): stack = None def get_object(self, name): - return getattr(sys.modules[self.call_module_name], name) + if '.' in name: + return import_string.eval_import(name) + else: + return getattr(sys.modules[self.call_module_name], name) def writeto(self, context): raise NotImplementedError |
