def _getparams_rtype(cls, function):
        """Get function params from input function and rtype.

        :return: OrderedDict, rtype, vargs and kwargs.
        :rtype: tuple
        """
        try:
            args, vargs, kwargs, default = getargspec(function)

        except TypeError:
            args, vargs, kwargs, default = (), (), (), ()

        indexlen = len(args) - (0 if default is None else len(default))

        params = OrderedDict()

        for index, arg in enumerate(args):

            pkwargs = {
                'name': arg,
                'mandatory': True
            }  # param kwargs

            if index >= indexlen:  # has default value
                value = default[index - indexlen]
                pkwargs['default'] = value
                pkwargs['ref'] = None if value is None else data2schema(value)
                pkwargs['mandatory'] = False

            params[arg] = pkwargs

        rtype = None

        # parse docstring
        if function.__doc__ is not None and not isbuiltin(function):

            scope = get_function_globals(function)

            for match in cls._REC.findall(function.__doc__):
                if rtype is None:
                    rrtype = match[4].strip() or None

                    if rrtype:

                        rtypes = rrtype.split(',')

                        schemas = []
                        for rtype_ in rtypes:

                            rtype_ = rtype_.strip()
                            islist = False

                            try:
                                lkrtype = lookup(rtype_, scope=scope)

                            except ImportError:
                                islist = True

                                try:
                                    if rtype_[-1] == 's':
                                        lkrtype = lookup(
                                            rtype_[:-1], scope=scope
                                        )

                                    elif rtype_.startswith('list of '):
                                        lkrtype = lookup(
                                            rtype_[8:], scope=scope
                                        )

                                    else:
                                        raise

                                except ImportError:
                                    msg = 'rtype "{0}" ({1}) from {2} not found.'
                                    raise ImportError(
                                        msg.format(rtype_, rrtype, function)
                                    )

                            try:
                                schemacls = datatype2schemacls(lkrtype)

                            except TypeError:
                                schemacls = ParamTypeSchema(type=lkrtype)

                            rschema = schemacls()

                            if islist:
                                rschema = ArraySchema(itemtype=rschema)

                            schemas.append(rschema)

                        if len(rtypes) > 1:
                            rtype = OneOfSchema(schemas=schemas, nullable=True)

                        else:
                            rtype = schemas[0]

                        continue

                pname = (match[1] or match[2]).strip()

                if pname and pname in params:

                    ptype = (match[0] or match[3]).strip()

                    ptypes = ptype.split(',')

                    schemas = []

                    for ptype in ptypes:

                        ptype = ptype.strip()

                        islist = False

                        try:
                            lkptype = lookup(ptype, scope=scope)

                        except ImportError:
                            islist = True

                            try:
                                if ptype[-1] == 's':
                                    lkptype = lookup(ptype[:-1], scope=scope)

                                elif ptype.startswith('list of '):
                                    lkptype = lookup(ptype[8:], scope=scope)

                                else:
                                    raise

                            except ImportError:

                                msg = 'Error on ptype "{0}" ({1}) from {2} not found.'
                                raise ImportError(
                                    msg.format(pname, ptype, function)
                                )

                        try:
                            schemacls = datatype2schemacls(lkptype)

                        except TypeError:
                            schemacls = ParamTypeSchema(type=lkptype)

                        pschema = schemacls()

                        if islist:
                            pschema = ArraySchema(itemtype=pschema)

                        schemas.append(pschema)

                    if len(ptypes) > 1:
                        pschema = OneOfSchema(schemas=schemas, nullable=True)

                    else:
                        pschema = schemas[0]

                    params[pname]['ref'] = pschema

        return params, rtype, vargs, kwargs
Get function params from input function and rtype.

        :return: OrderedDict, rtype, vargs and kwargs.
        :rtype: tuple