Esempio n. 1
0
def test_isdescriptor(app):
    from target.functions import func
    from target.methods import Base

    assert inspect.isdescriptor(Base.prop) is True  # property of class
    assert inspect.isdescriptor(Base().prop) is False  # property of instance
    assert inspect.isdescriptor(Base.meth) is True  # method of class
    assert inspect.isdescriptor(Base().meth) is True  # method of instance
    assert inspect.isdescriptor(func) is True  # function
Esempio n. 2
0
 def can_document_member(cls, member, membername, isattr, parent):
     isdatadesc = isdescriptor(member) and not \
                  isinstance(member, cls.method_types) and not \
                  type(member).__name__ in ("type", "method_descriptor")
     return isdatadesc or (not isinstance(parent, ModuleDocumenter)
                           and not inspect.isroutine(member)
                           and not isinstance(member, class_types))
Esempio n. 3
0
 def can_document_member(cls, member, membername, isattr, parent):
     # "isdescriptor(member) and not isinstance(member, (FunctionType, BuiltinFunctionType))"
     # is true for public cython attributes of a class. But in this case, the doc string is None,
     # and so we would not include it into the documentation.
     return (isdescriptor(member) and not
             isinstance(member, (FunctionType, BuiltinFunctionType))
             and (hasattr(member,'__doc__') and member.__doc__ is not None)) \
            or (not isinstance(parent, ModuleDocumenter) and isattr)
Esempio n. 4
0
 def can_document_member(cls, member, membername, isattr, parent):
     # "isdescriptor(member) and not isinstance(member, (FunctionType, BuiltinFunctionType))"
     # is true for public cython attributes of a class. But in this case, the doc string is None,
     # and so we would not include it into the documentation.
     return (isdescriptor(member) and not
             isinstance(member, (FunctionType, BuiltinFunctionType))
             and (hasattr(member,'__doc__') and member.__doc__ is not None)) \
            or (not isinstance(parent, ModuleDocumenter) and isattr)
Esempio n. 5
0
 def can_document_member(cls, member, membername, isattr, parent):
     non_attr_types = cls.method_types + class_types + \
         (MethodDescriptorType,)
     isdatadesc = isdescriptor(member) and not \
         isinstance(member, non_attr_types) and not \
         type(member).__name__ == "instancemethod"
     # That last condition addresses an obscure case of C-defined
     # methods using a deprecated type in Python 3, that is not
     # otherwise exported anywhere by Python
     return isdatadesc or (not isinstance(parent, ModuleDocumenter) and
                           not inspect.isroutine(member) and
                           not isinstance(member, class_types))
 def can_document_member(cls, member, membername, isattr, parent):
     non_attr_types = cls.method_types + class_types + \
         (MethodDescriptorType,)
     isdatadesc = isdescriptor(member) and not \
         isinstance(member, non_attr_types) and not \
         type(member).__name__ == "instancemethod"
     # That last condition addresses an obscure case of C-defined
     # methods using a deprecated type in Python 3, that is not otherwise
     # exported anywhere by Python
     return isdatadesc or (not isinstance(parent, ModuleDocumenter) and
                           not inspect.isroutine(member) and
                           not isinstance(member, class_types))
Esempio n. 7
0
 def can_document_member(cls, member, membername, isattr, parent):
     isdatadesc = isdescriptor(member) and not \
                  isinstance(member, cls.method_types)
     return isdatadesc or \
            (isattr and not isinstance(parent, ModuleDocumenter))
Esempio n. 8
0
 def can_document_member(cls, member, membername, isattr, parent):
     return (isdescriptor(member) and not
             isinstance(member, (FunctionType, BuiltinFunctionType))) \
            or (not isinstance(parent, ModuleDocumenter) and isattr)
Esempio n. 9
0
 def can_document_member(cls, member, membername, isattr, parent):
     isdatadesc = isdescriptor(member) and not \
                  isinstance(member, cls.method_types)
     return isdatadesc or \
            (isattr and not isinstance(parent, ModuleDocumenter))
Esempio n. 10
0
 def can_document_member(cls, member, membername, isattr, parent):
     return (isdescriptor(member) and not
             isinstance(member, (FunctionType, BuiltinFunctionType))) \
            or (not isinstance(parent, ModuleDocumenter) and isattr)