def parse_module(module):
attributes = [<EOL>(name, type_)<EOL>for (name, type_) in getmembers(module)<EOL>if (isclass(type_) or isfunction(type_))<EOL>and type_.__module__ == module.__name__<EOL>and not type_.__name__.startswith('<STR_LIT:_>')<EOL>]<EOL>attribute_docs = ['<STR_LIT>'.format(module.__name__), '<STR_LIT>']<EOL>if module.__doc__:<EOL><INDENT>docstring, _ = _parse_docstring(module.__doc__)<EOL>attribute_docs.append(docstring)<EOL><DEDENT>if hasattr(module, '<STR_LIT>'):<EOL><INDENT>for name in module.__all__:<EOL><INDENT>link = '<STR_LIT>'.format(name)<EOL>attribute_docs.append(link)<EOL><DEDENT><DEDENT>for (name, type_) in attributes:<EOL><INDENT>if isfunction(type_):<EOL><INDENT>attribute_docs.append(_parse_function(module, name, type_))<EOL><DEDENT>else:<EOL><INDENT>attribute_docs.append(_parse_class(module, name, type_))<EOL><DEDENT><DEDENT>return u'<STR_LIT>'.format(<EOL>u'<STR_LIT:\n>'.join(attribute_docs).strip()<EOL>)<EOL>
Parse a module's attributes and generate a markdown document.