Beispiel #1
0
 def format_args(self):
     args = None
     # for classes, the relevant signature is the __init__ method's
     initmeth = self.get_attr(self.object, '__init__', None)
     # classes without __init__ method, default __init__ or
     # __init__ written in C?
     if initmeth is None or initmeth is object.__init__ or not \
            (inspect.ismethod(initmeth) or inspect.isfunction(initmeth) or
             inspect.ismethoddescriptor(initmeth)):
         return None
     argspec = sage_getargspec(initmeth) #inspect.getargspec(initmeth)
     if argspec[0] and argspec[0][0] in ('cls', 'self'):
         del argspec[0][0]
     return inspect.formatargspec(*argspec)
Beispiel #2
0
 def args_on_obj(obj):
     if hasattr(obj, "_sage_argspec_"):
         argspec = obj._sage_argspec_()
     elif inspect.isbuiltin(obj) or inspect.ismethoddescriptor(obj):
         # can never get arguments of a C function or method unless
         # a function to do so is supplied
         if self.env.config.autodoc_builtin_argspec:
             argspec = self.env.config.autodoc_builtin_argspec(obj)
         else:
             return None
     else:
         # The check above misses ordinary Python methods in Cython
         # files.
         argspec = sage_getargspec(obj) #inspect.getargspec(obj)
     #if isclassinstance(obj) or inspect.isclass(obj):
     if argspec is not None and argspec[0] and argspec[0][0] in ('cls', 'self'):
         del argspec[0][0]
     return argspec
Beispiel #3
0
 def args_on_obj(obj):
     if hasattr(obj, "_sage_argspec_"):
         return obj._sage_argspec_()
     if inspect.isbuiltin(obj) or \
            inspect.ismethoddescriptor(obj):
         # can never get arguments of a C function or method unless
         # a function to do so is supplied
         if self.env.config.autodoc_builtin_argspec:
             argspec = self.env.config.autodoc_builtin_argspec(obj)
             return argspec
         else:
             return None
     argspec = sage_getargspec(obj) #inspect.getargspec(obj)
     if isclassinstance(obj) or inspect.isclass(obj):
         # if a class should be documented as function, we try
         # to use the constructor signature as function
         # signature without the first argument.
         if argspec is not None and argspec[0]:
             del argspec[0][0]
     return argspec