mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2026-09-03 20:52:55 -05:00
Fix class constructor signature, and class name display for members.
This commit is contained in:
@@ -6,7 +6,7 @@ Changes in trunk
|
|||||||
create a target and no output.
|
create a target and no output.
|
||||||
|
|
||||||
* sphinx.ext.autodoc: Don't check ``__module__`` for explicitly given
|
* 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.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``
|
* sphinx.directives: Allow giving multiple options in a ``cmdoption``
|
||||||
directive.
|
directive.
|
||||||
|
|
||||||
|
* sphinx.directives: Fix display of class members without explicit
|
||||||
|
class name given.
|
||||||
|
|
||||||
* sphinx.roles: Fix referencing glossary terms with explicit targets.
|
* sphinx.roles: Fix referencing glossary terms with explicit targets.
|
||||||
|
|
||||||
* sphinx.builder, sphinx.environment: Gracefully handle some exception
|
* sphinx.builder, sphinx.environment: Gracefully handle some exception
|
||||||
|
|||||||
@@ -140,12 +140,16 @@ def parse_py_signature(signode, sig, desctype, env):
|
|||||||
if env.currclass:
|
if env.currclass:
|
||||||
if classname and classname.startswith(env.currclass):
|
if classname and classname.startswith(env.currclass):
|
||||||
fullname = classname + name
|
fullname = classname + name
|
||||||
|
# class name is given again in the signature
|
||||||
classname = classname[len(env.currclass):].lstrip('.')
|
classname = classname[len(env.currclass):].lstrip('.')
|
||||||
add_module = False
|
add_module = False
|
||||||
elif classname:
|
elif classname:
|
||||||
|
# class name is given in the signature, but different
|
||||||
fullname = env.currclass + '.' + classname + name
|
fullname = env.currclass + '.' + classname + name
|
||||||
else:
|
else:
|
||||||
|
# class name is not given in the signature
|
||||||
fullname = env.currclass + '.' + name
|
fullname = env.currclass + '.' + name
|
||||||
|
add_module = False
|
||||||
else:
|
else:
|
||||||
fullname = classname and classname + name or name
|
fullname = classname and classname + name or name
|
||||||
|
|
||||||
@@ -384,7 +388,7 @@ def desc_directive(desctype, arguments, options, content, lineno,
|
|||||||
subnode = addnodes.desc_content()
|
subnode = addnodes.desc_content()
|
||||||
# needed for automatic qualification of members
|
# needed for automatic qualification of members
|
||||||
clsname_set = False
|
clsname_set = False
|
||||||
if desctype == 'class' and names:
|
if desctype in ('class', 'exception') and names:
|
||||||
env.currclass = names[0]
|
env.currclass = names[0]
|
||||||
clsname_set = True
|
clsname_set = True
|
||||||
elif desctype in ('method', 'attribute') and clsname and not env.currclass:
|
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:
|
try:
|
||||||
if what == 'class':
|
if what == 'class':
|
||||||
args = inspect.formatargspec(*inspect.getargspec(todoc.__init__))
|
args = inspect.formatargspec(*inspect.getargspec(todoc.__init__))
|
||||||
|
if args[1:7] == 'self, ':
|
||||||
|
args = '(' + args[7:]
|
||||||
|
elif args == '(self)':
|
||||||
|
args = '()'
|
||||||
elif what in ('function', 'method'):
|
elif what in ('function', 'method'):
|
||||||
args = inspect.formatargspec(*inspect.getargspec(todoc))
|
args = inspect.formatargspec(*inspect.getargspec(todoc))
|
||||||
if what == 'method':
|
if what == 'method':
|
||||||
|
|||||||
Reference in New Issue
Block a user