def parse_docstring(docstring):
    if not docstring:
        return
    
    params = []
    responses = []
    stripped = ''
    rtype = None
    for line in docstring.split('\n'):
        line = line.lstrip('\t ')
        if not line.startswith(':'):
            stripped += line + '\n<br />'
            continue
        
        directive, value = line.split(':', 2)[1:]
        value = value.strip('\t ')

        directive = directive.split(' ', 1)
        if len(directive) > 1:
            directive, key = directive
        else:
            directive = directive[0]
            key = None

        if directive in ('json', 'body', 'query', 'path', 'form', 'reqheader'):
            param = parse_docstring_param(directive, key, value)
            if param:
                params.append(param)
            continue

        if directive == 'status':
            responses.append({
                'code': int(key),
                'message': value,
            })
            continue
        
        if directive == 'rtype':
            rtype = value
        log.warning('Ignoring unknown docstring param %s', directive)

    return (params, responses, stripped, rtype)
Turns autodoc http dialect docstrings into swagger documentation
dataset/ETHPy150Open uber/clay/clay/docs.py/parse_docstring