mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2026-09-03 20:52:55 -05:00
Autodoc can document classes as functions now if explicitly
marked with `autofunction`.
This commit is contained in:
@@ -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
@@ -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'):
|
||||
|
||||
Reference in New Issue
Block a user