Fix class constructor signature, and class name display for members.

This commit is contained in:
Georg Brandl 2008-04-12 21:23:35 +00:00
parent a3aabab9f2
commit a011d3ae6c
3 changed files with 13 additions and 2 deletions

View File

@ -6,7 +6,7 @@ Changes in trunk
create a target and no output.
* sphinx.ext.autodoc: Don't check ``__module__`` for explicitly given
members.
members. Remove "self" in class constructor argument list.
* sphinx.environment: Don't swallow TOC entries when resolving subtrees.
@ -16,6 +16,9 @@ Changes in trunk
* sphinx.directives: Allow giving multiple options in a ``cmdoption``
directive.
* sphinx.directives: Fix display of class members without explicit
class name given.
* sphinx.roles: Fix referencing glossary terms with explicit targets.
* sphinx.builder, sphinx.environment: Gracefully handle some exception

View File

@ -140,12 +140,16 @@ def parse_py_signature(signode, sig, desctype, env):
if env.currclass:
if classname and classname.startswith(env.currclass):
fullname = classname + name
# class name is given again in the signature
classname = classname[len(env.currclass):].lstrip('.')
add_module = False
elif classname:
# class name is given in the signature, but different
fullname = env.currclass + '.' + classname + name
else:
# class name is not given in the signature
fullname = env.currclass + '.' + name
add_module = False
else:
fullname = classname and classname + name or name
@ -384,7 +388,7 @@ def desc_directive(desctype, arguments, options, content, lineno,
subnode = addnodes.desc_content()
# needed for automatic qualification of members
clsname_set = False
if desctype == 'class' and names:
if desctype in ('class', 'exception') and names:
env.currclass = names[0]
clsname_set = True
elif desctype in ('method', 'attribute') and clsname and not env.currclass:

View File

@ -125,6 +125,10 @@ def generate_rst(what, name, members, undoc, add_content, document, lineno,
try:
if what == 'class':
args = inspect.formatargspec(*inspect.getargspec(todoc.__init__))
if args[1:7] == 'self, ':
args = '(' + args[7:]
elif args == '(self)':
args = '()'
elif what in ('function', 'method'):
args = inspect.formatargspec(*inspect.getargspec(todoc))
if what == 'method':