summaryrefslogtreecommitdiff
path: root/paste/docsupport
diff options
context:
space:
mode:
authorianb <devnull@localhost>2005-05-21 22:23:34 +0000
committerianb <devnull@localhost>2005-05-21 22:23:34 +0000
commit6f64b195e132851718e5b32a7d2be8f3c989cf87 (patch)
tree87f7e3cc657db990371c56273c7a1bbfbd1d4495 /paste/docsupport
parentf739c94f1af2b50694a0d3c38ef36d4e3b8d1b97 (diff)
downloadpaste-6f64b195e132851718e5b32a7d2be8f3c989cf87.tar.gz
Added documentation to configmiddleware; tweaked documentation extractor for lazy attributes (string references)
Diffstat (limited to 'paste/docsupport')
-rw-r--r--paste/docsupport/extract.py17
-rw-r--r--paste/docsupport/metadata.py9
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