diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2006-10-20 18:46:26 +0000 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2006-10-20 18:46:26 +0000 |
commit | 705ee2cfa36b589b7cf8c5bb510d3211013acc8e (patch) | |
tree | 569e036a7f16313e7a799bd442e282e808ce2390 /doc/build/lib/docstring.py | |
parent | da8c6c312af4376d2e2dc67fee92e0ceca5a7ced (diff) | |
download | sqlalchemy-705ee2cfa36b589b7cf8c5bb510d3211013acc8e.tar.gz |
got linking of classes to work. but what a mess the doc code is now.
Diffstat (limited to 'doc/build/lib/docstring.py')
-rw-r--r-- | doc/build/lib/docstring.py | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/doc/build/lib/docstring.py b/doc/build/lib/docstring.py index 8f771c20e..b6879c7ad 100644 --- a/doc/build/lib/docstring.py +++ b/doc/build/lib/docstring.py @@ -2,8 +2,17 @@ import re, types, string, inspect """sucks a module and its contents into a simple documentation object, suitable for pickling""" -class ObjectDoc(object): +allobjects = {} + +class AbstractDoc(object): + def __init__(self, obj): + allobjects[id(obj)] = self + self.id = id(obj) + self.allobjects = allobjects + +class ObjectDoc(AbstractDoc): def __init__(self, obj, functions=None, classes=None): + super(ObjectDoc, self).__init__(obj) self.isclass = isinstance(obj, types.ClassType) or isinstance(obj, types.TypeType) self.name= obj.__name__ functions = functions @@ -52,6 +61,7 @@ class ObjectDoc(object): if self.isclass: self.description = "class " + self.name + self.classname = self.name if hasattr(obj, '__mro__'): l = [] mro = list(obj.__mro__[1:]) @@ -62,6 +72,9 @@ class ObjectDoc(object): del l[l.index(y)] l.insert(0, x) self.description += "(" + string.join([x.__name__ for x in l], ',') + ")" + self._inherits = [(id(x), x.__name__) for x in l] + else: + self._inherits = [] else: self.description = "module " + self.name @@ -82,12 +95,20 @@ class ObjectDoc(object): self.classes = [] for class_ in classes: self.classes.append(ObjectDoc(class_)) - + + def _get_inherits(self): + for item in self._inherits: + if item[0] in self.allobjects: + yield self.allobjects[item[0]] + else: + yield item[1] + inherits = property(_get_inherits) def accept_visitor(self, visitor): visitor.visit_object(self) -class FunctionDoc(object): +class FunctionDoc(AbstractDoc): def __init__(self, func): + super(FunctionDoc, self).__init__(func) argspec = inspect.getargspec(func) argnames = argspec[0] varargs = argspec[1] @@ -110,8 +131,9 @@ class FunctionDoc(object): def accept_visitor(self, visitor): visitor.visit_function(self) -class PropertyDoc(object): +class PropertyDoc(AbstractDoc): def __init__(self, name, prop): + super(PropertyDoc, self).__init__(prop) self.doc = prop.__doc__ self.name = name + " = property()" self.link = name |