diff --git a/CHANGES b/CHANGES index 909f451fa..4c560b13c 100644 --- a/CHANGES +++ b/CHANGES @@ -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 diff --git a/sphinx/directives.py b/sphinx/directives.py index ae57c01ea..f8c542e82 100644 --- a/sphinx/directives.py +++ b/sphinx/directives.py @@ -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: diff --git a/sphinx/ext/autodoc.py b/sphinx/ext/autodoc.py index c9ce05a7a..e4ec8b02f 100644 --- a/sphinx/ext/autodoc.py +++ b/sphinx/ext/autodoc.py @@ -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':