(parser, name=None)
return decorator
decorator to connect an already prepared parser to call into a function.

    This function initilizes the _func and _name properties for the parser to
    the given function, and its name. It also sets the functions docstring to
    be the parsers help. This way the help string appears in the sphinx
    documentation for the function.

    >>> @script.connect(parser)
    >>> def add(cmdline):
    >>>     pass
decorator to connect an already prepared parser to call into a function.
decorator to connect an already prepared parser to call into a function .
def connect(parser, name=None):
    '''decorator to connect an already prepared parser to call into a function.

    This function initilizes the _func and _name properties for the parser to
    the given function, and its name. It also sets the functions docstring to
    be the parsers help. This way the help string appears in the sphinx
    documentation for the function.

    >>> @script.connect(parser)
    >>> def add(cmdline):
    >>>     pass
    '''

    def decorator(function):
        # Use the function name as a fallback, it should be the same usually.
        if name is None:
            local_name = function.__name__
        else:
            local_name = name

        parser.set_defaults(_func=function, _name=local_name)

        function.__doc__ = parser.format_help()

        return function

    return decorator
def connect ( parser , name = None ) : def decorator ( function ) : # Use the function name as a fallback, it should be the same usually. if name is None : local_name = function . __name__ else : local_name = name parser . set_defaults ( _func = function , _name = local_name ) function . __doc__ = parser . format_help ( ) return function return decorator