def parse_docstring(doc):
doc = inspect.cleandoc(doc)<EOL>lines = doc.split('<STR_LIT:\n>')<EOL>section = None<EOL>section_indent = None<EOL>params = {}<EOL>returns = None<EOL>for line in lines:<EOL><INDENT>line = line.rstrip()<EOL>if len(line) == <NUM_LIT:0>:<EOL><INDENT>continue<EOL><DEDENT>elif str(line) == '<STR_LIT>':<EOL><INDENT>section = '<STR_LIT:args>'<EOL>section_indent = None<EOL>continue<EOL><DEDENT>elif str(line) == '<STR_LIT>':<EOL><INDENT>section = '<STR_LIT>'<EOL>section_indent = None<EOL>continue<EOL><DEDENT>if section is not None:<EOL><INDENT>stripped = line.lstrip()<EOL>margin = len(line) - len(stripped)<EOL>if section_indent is None:<EOL><INDENT>section_indent = margin<EOL><DEDENT>if margin != section_indent:<EOL><INDENT>continue<EOL><DEDENT>if section == '<STR_LIT:args>':<EOL><INDENT>param_name, type_info = parse_param(stripped)<EOL>params[param_name] = type_info<EOL><DEDENT>elif section == '<STR_LIT>':<EOL><INDENT>returns = parse_return(stripped)<EOL><DEDENT><DEDENT><DEDENT>return params, returns<EOL>
Parse a docstring into ParameterInfo and ReturnInfo objects.