mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fix class constructor signature, and class name display for members.
This commit is contained in:
parent
a3aabab9f2
commit
a011d3ae6c
5
CHANGES
5
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
|
||||
|
@ -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:
|
||||
|
@ -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':
|
||||
|
Loading…
Reference in New Issue
Block a user