예제 #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
예제 #2
0
파일: conf.py 프로젝트: aidandan/libearth
 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))
예제 #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)
예제 #4
0
파일: sage_autodoc.py 프로젝트: bukzor/sage
 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)
예제 #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))
예제 #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))
예제 #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)
예제 #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))
예제 #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)