Autodoc can document classes as functions now if explicitly

marked with `autofunction`.
This commit is contained in:
Armin Ronacher
2009-01-17 01:21:47 +01:00
parent a8756fb4b3
commit 9f85317530
2 changed files with 15 additions and 1 deletions
+3
View File
@@ -78,6 +78,9 @@ New features added
- Autodoc now handles inner classes and their methods.
- Autodoc can document classes as functions now if explicitly
marked with `autofunction`.
- There is now a ``Sphinx.add_lexer()`` method to be able to use
custom Pygments lexers easily.
+12 -1
View File
@@ -324,7 +324,18 @@ class RstGenerator(object):
# can never get arguments of a C function or method
getargs = False
if getargs:
argspec = inspect.getargspec(obj)
try:
argspec = inspect.getargspec(obj)
except TypeError:
# if a class should be documented as function (yay duck
# typing) we try to use the constructor signature as function
# signature without the first argument.
try:
argspec = inspect.getargspec(obj.__new__)
except TypeError:
argspec = inspect.getargspec(obj.__init__)
if argspec[0]:
del argspec[0][0]
if what in ('class', 'method', 'staticmethod',
'classmethod') and argspec[0] and \
argspec[0][0] in ('cls', 'self'):