Anonymous avatar Anonymous committed 9a17c02

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

Comments (0)

Files changed (3)

   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.
 
 * 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

sphinx/directives.py

     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
 
     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:

sphinx/ext/autodoc.py

     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':
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.