summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormitsuhiko <devnull@localhost>2009-02-01 20:51:16 +0100
committermitsuhiko <devnull@localhost>2009-02-01 20:51:16 +0100
commitafbab8de96e7771f8d5d1fde8f3ba9909b649372 (patch)
tree5fee5e4093da976c189611f8acb4c1b8be6eea45
parentcca9de484189cbf76b47a18831993a9bc077bbf1 (diff)
parent25bcacb4a61db2f265bf8bf38db1cd7cb0ff5abe (diff)
downloadsphinx-afbab8de96e7771f8d5d1fde8f3ba9909b649372.tar.gz
Merge
-rw-r--r--CHANGES3
-rw-r--r--sphinx/ext/autodoc.py13
2 files changed, 15 insertions, 1 deletions
diff --git a/CHANGES b/CHANGES
index 4b28899b..3ef35a5e 100644
--- a/CHANGES
+++ b/CHANGES
@@ -86,6 +86,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.
diff --git a/sphinx/ext/autodoc.py b/sphinx/ext/autodoc.py
index 3ca92e86..a817e343 100644
--- a/sphinx/ext/autodoc.py
+++ b/sphinx/ext/autodoc.py
@@ -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'):