This function uses "inspect" to retrieve information about a method.

    Also, if you place comment on the method, method can be docummented with "reStructured Text".

    :param method:    method to describe

    :returns:
        {
            'name'          : <string> - name of the method,
            'friendly_name' : <string> - friendly name of the method,
            'parameters'    : {
                'required'     : [ 'param1', 'param2' ],
                'optionnal'    : {
                    'param3'       : 'default_value3',
                    'param4'       : 'default_value4',
            },
            'help'       : {
                'summary'    : <string> - Summary - general description like in the comment,
                'parameters' : {
                    'param1' : 'description',
                    'param2' : 'description',
                },
                'return'     : <string> - Can be multiline,
            }
        }

def get_method_documentation(method):
    """
    This function uses "inspect" to retrieve information about a method.

    Also, if you place comment on the method, method can be docummented with "reStructured Text".

    :param method:    method to describe

    :returns:
        {
            'name'          : <string> - name of the method,
            'friendly_name' : <string> - friendly name of the method,
            'parameters'    : {
                'required'     : [ 'param1', 'param2' ],
                'optionnal'    : {
                    'param3'       : 'default_value3',
                    'param4'       : 'default_value4',
            },
            'help'       : {
                'summary'    : <string> - Summary - general description like in the comment,
                'parameters' : {
                    'param1' : 'description',
                    'param2' : 'description',
                },
                'return'     : <string> - Can be multiline,
            }
        }
    """
    from inspect import getargspec
    result = {
        'name': method.__name__,
        'friendly_name': ' '.join([name.capitalize() for name in method.__name__.split('_')]),
    }
    arg_specs = getargspec(method)
    arguments = {}

    if not arg_specs.defaults:
        if len(arg_specs.args[1:]) > 0:
            arguments['required'] = list(arg_specs.args[1:])
    else:
        if len(arg_specs.args[1:-(len(arg_specs.defaults))]):
            arguments['required'] = list(arg_specs.args[1:-(len(arg_specs.defaults))])
        arguments['optional'] = {}
        for i in range(len(arg_specs.defaults)):
            arguments['optional'][arg_specs.args[-(len(arg_specs.defaults)) + i]] = arg_specs.defaults[i]
    if arguments != {}:
        result['parameters'] = arguments

    doc = method.__doc__.strip() if method.__doc__ else ''
    if ':' in method.__doc__:
        doc = {'summary': method.__doc__[0:doc.find('  :')].strip()}
        params = re.findall(r":param ([^\s]*): (.*)\n", method.__doc__)
        if len(params) > 0:
            doc['parameters'] = {}
            for param in params:
                doc['parameters'][param[0]] = param[1].strip()

        regex = re.compile(r":returns:(.*)", re.MULTILINE | re.DOTALL)
        returns = regex.search(method.__doc__)
        if returns and returns.group(0):
            doc['return'] = returns.group(0).replace(':returns:', '').replace('\n        ', '\n').strip()
    if doc != '':
        result['help'] = doc
    return result