merge with 0.6

This commit is contained in:
Georg Brandl 2009-10-25 11:27:05 +01:00
commit 2df42c5cb3
5 changed files with 33 additions and 5 deletions

View File

@ -38,6 +38,8 @@ Release 1.0 (in development)
Release 0.6.4 (in development) Release 0.6.4 (in development)
============================== ==============================
* Fix the handling of non-data descriptors in autodoc.
Release 0.6.3 (Sep 03, 2009) Release 0.6.3 (Sep 03, 2009)
============================ ============================

View File

@ -35,6 +35,7 @@ included, please mail to `the Google group
* MyHDL: http://www.myhdl.org/doc/0.6/ * MyHDL: http://www.myhdl.org/doc/0.6/
* NetworkX: http://networkx.lanl.gov/ * NetworkX: http://networkx.lanl.gov/
* NOC: http://trac.nocproject.org/trac/wiki/NocGuide * NOC: http://trac.nocproject.org/trac/wiki/NocGuide
* nose: http://somethingaboutorange.com/mrl/projects/nose/
* NumPy: http://docs.scipy.org/doc/numpy/reference/ * NumPy: http://docs.scipy.org/doc/numpy/reference/
* ObjectListView: http://objectlistview.sourceforge.net/python * ObjectListView: http://objectlistview.sourceforge.net/python
* Open ERP: http://doc.openerp.com/ * Open ERP: http://doc.openerp.com/

View File

@ -971,10 +971,10 @@ class MethodDocumenter(ClassLevelDocumenter):
""" """
objtype = 'method' objtype = 'method'
member_order = 50 member_order = 50
priority = 0
@classmethod @classmethod
def can_document_member(cls, member, membername, isattr, parent): def can_document_member(cls, member, membername, isattr, parent):
# other attributes are recognized via the module analyzer
return inspect.isroutine(member) and \ return inspect.isroutine(member) and \
not isinstance(parent, ModuleDocumenter) not isinstance(parent, ModuleDocumenter)
@ -1017,11 +1017,18 @@ class AttributeDocumenter(ClassLevelDocumenter):
objtype = 'attribute' objtype = 'attribute'
member_order = 60 member_order = 60
# must be higher than the MethodDocumenter, else it will recognize
# some non-data descriptors as methods
priority = 10
method_types = (FunctionType, BuiltinFunctionType, MethodType)
@classmethod @classmethod
def can_document_member(cls, member, membername, isattr, parent): def can_document_member(cls, member, membername, isattr, parent):
return (isdescriptor(member) and not isdatadesc = isdescriptor(member) and not \
isinstance(member, (FunctionType, BuiltinFunctionType))) \ isinstance(member, cls.method_types)
or (not isinstance(parent, ModuleDocumenter) and isattr) return isdatadesc or \
(isattr and not isinstance(parent, ModuleDocumenter))
def document_members(self, all_members=False): def document_members(self, all_members=False):
pass pass

View File

@ -392,7 +392,7 @@ span.eqno {
div.document, div.document,
div.documentwrapper, div.documentwrapper,
div.bodywrapper { div.bodywrapper {
margin: 0; margin: 0 !important;
width: 100%; width: 100%;
} }

View File

@ -379,6 +379,7 @@ def test_generate():
options.exclude_members = set(['excludemeth']) options.exclude_members = set(['excludemeth'])
assert_processes(should, 'class', 'Class') assert_processes(should, 'class', 'Class')
should.extend([('attribute', 'test_autodoc.Class.prop'), should.extend([('attribute', 'test_autodoc.Class.prop'),
('attribute', 'test_autodoc.Class.descr'),
('attribute', 'test_autodoc.Class.attr'), ('attribute', 'test_autodoc.Class.attr'),
('attribute', 'test_autodoc.Class.docattr'), ('attribute', 'test_autodoc.Class.docattr'),
('attribute', 'test_autodoc.Class.udocattr')]) ('attribute', 'test_autodoc.Class.udocattr')])
@ -427,6 +428,10 @@ def test_generate():
('method', 'test_autodoc.Outer.Inner.meth')], ('method', 'test_autodoc.Outer.Inner.meth')],
'class', 'Outer', all_members=True) 'class', 'Outer', all_members=True)
# test descriptor docstrings
assert_result_contains(' Descriptor instance docstring.',
'attribute', 'test_autodoc.Class.descr')
# test generation for C modules (which have no source file) # test generation for C modules (which have no source file)
directive.env.currmodule = 'time' directive.env.currmodule = 'time'
assert_processes([('function', 'time.asctime')], 'function', 'asctime') assert_processes([('function', 'time.asctime')], 'function', 'asctime')
@ -445,6 +450,17 @@ class CustomEx(Exception):
def f(self): def f(self):
"""Exception method.""" """Exception method."""
class CustomDataDescriptor(object):
"""Descriptor class docstring."""
def __init__(self, doc):
self.__doc__ = doc
def __get__(self, obj, type=None):
if obj is None:
return self
return 42
class Base(object): class Base(object):
def inheritedmeth(self): def inheritedmeth(self):
"""Inherited function.""" """Inherited function."""
@ -452,6 +468,8 @@ class Base(object):
class Class(Base): class Class(Base):
"""Class to document.""" """Class to document."""
descr = CustomDataDescriptor("Descriptor instance docstring.")
def meth(self): def meth(self):
"""Function.""" """Function."""