diff options
| author | mitsuhiko <devnull@localhost> | 2009-01-17 01:21:47 +0100 |
|---|---|---|
| committer | mitsuhiko <devnull@localhost> | 2009-01-17 01:21:47 +0100 |
| commit | 25bcacb4a61db2f265bf8bf38db1cd7cb0ff5abe (patch) | |
| tree | 18b45cdbcbfbb5fbcb1f7e6fca9ed8141f37a7ab /sphinx | |
| parent | 93f4b73b3cdfeb58c8f9e3c7670b5b43c06619be (diff) | |
| download | sphinx-25bcacb4a61db2f265bf8bf38db1cd7cb0ff5abe.tar.gz | |
Autodoc can document classes as functions now if explicitly
marked with `autofunction`.
Diffstat (limited to 'sphinx')
| -rw-r--r-- | sphinx/ext/autodoc.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/sphinx/ext/autodoc.py b/sphinx/ext/autodoc.py index d0512f2b..79443859 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'): |
