def extract_docs():
methods = []<EOL>def _key(entry):<EOL><INDENT>return<EOL><DEDENT>sorted_entries = sorted(Client.__dict__.items(), key=lambda x: x[<NUM_LIT:0>])<EOL>tree = {}<EOL>meta_key = '<STR_LIT>'<EOL>for attr_name, attr_value in sorted_entries:<EOL><INDENT>if not hasattr(attr_value, meta_key):<EOL><INDENT>continue<EOL><DEDENT>func = attr_value<EOL>meta = getattr(func, meta_key)<EOL>arg_spec = inspect.getargspec(func)<EOL>if arg_spec[<NUM_LIT:0>] and arg_spec[<NUM_LIT:0>][<NUM_LIT:0>] in ('<STR_LIT>', '<STR_LIT>'):<EOL><INDENT>del arg_spec[<NUM_LIT:0>][<NUM_LIT:0>]<EOL><DEDENT>func_name = func.__name__<EOL>func_spec = func_name + inspect.formatargspec(*arg_spec)<EOL>doc = textwrap.dedent((func.__doc__ or '<STR_LIT>'))<EOL>doc = indent(doc, n=<NUM_LIT:3>)<EOL>func_desc_lines = []<EOL>for i, line in enumerate(func.__doc__.splitlines()):<EOL><INDENT>if i == <NUM_LIT:0>:<EOL><INDENT>continue<EOL><DEDENT>func_desc_lines.append(line.strip())<EOL>if not line:<EOL><INDENT>break<EOL><DEDENT><DEDENT>func_desc = '<STR_LIT:U+0020>'.join(func_desc_lines)<EOL>doc = textwrap.dedent(<EOL>"""<STR_LIT>"""<EOL>).format(<EOL>func_spec=func_spec,<EOL>func_name_line='<STR_LIT:->' * len(func_name),<EOL>func_name=func_name,<EOL>func_desc=func_desc,<EOL>doc=doc,<EOL>)<EOL>categories = meta['<STR_LIT>']<EOL>for category in categories:<EOL><INDENT>tree.setdefault(category, []).append(doc)<EOL><DEDENT><DEDENT>directory = '<STR_LIT>'<EOL>for file in os.listdir(directory):<EOL><INDENT>if file.endswith('<STR_LIT>'):<EOL><INDENT>os.unlink(os.path.join(directory, file))<EOL><DEDENT><DEDENT>for category, func_docs in sorted(tree.items(), key=lambda x: x[<NUM_LIT:0>]):<EOL><INDENT>category = category or '<STR_LIT>'<EOL>file_path = os.path.join(directory, category) + '<STR_LIT>'<EOL>with open(file_path, '<STR_LIT:w>') as docfile:<EOL><INDENT>docfile.write('<STR_LIT>' % category + '<STR_LIT:\n>')<EOL>title = '<STR_LIT>'.format(category=category.capitalize())<EOL>docfile.write('<STR_LIT>' % title)<EOL>docfile.write('<STR_LIT>' % (len(title) * '<STR_LIT:=>'))<EOL>docfile.write('<STR_LIT:\n>')<EOL>for func_doc in func_docs:<EOL><INDENT>docfile.write(func_doc + '<STR_LIT:\n>')<EOL><DEDENT><DEDENT><DEDENT>
Parses the nano.rpc.Client for methods that have a __doc_meta__ attribute
and saves generated docs