<s> from base_doc import BaseDoc <EOL> from line_functions import get_indent , replace_at , add_indent <EOL> from fields import ( max_header_length , max_desc_length , <EOL> max_name_length , MethodField , AttributeField ) <EOL> class ClassDoc ( BaseDoc ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , lines , headers = None , verbose = False ) : <EOL> if headers is None : <EOL> headers = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' <EOL> } <EOL> super ( ClassDoc , self ) . __init__ ( lines , headers , verbose ) <EOL> return <EOL> def _refactor_attributes ( self , header ) : <EOL> """<STR_LIT>""" <EOL> if self . verbose : <EOL> print '<STR_LIT>' . format ( header ) <EOL> index = self . index <EOL> self . remove_lines ( index , <NUM_LIT:2> ) <EOL> indent = get_indent ( self . peek ( ) ) <EOL> fields = self . extract_fields ( indent , AttributeField ) <EOL> descriptions = [ ] <EOL> for field in fields : <EOL> descriptions += field . to_rst ( len ( indent ) ) <EOL> self . insert_lines ( descriptions [ : - <NUM_LIT:1> ] , index ) <EOL> self . index += len ( descriptions ) <EOL> return <EOL> def _refactor_methods ( self , header ) : <EOL> """<STR_LIT>""" <EOL> if self . verbose : <EOL> print '<STR_LIT>' . format ( header ) <EOL> index = self . index <EOL> self . remove_lines ( index , <NUM_LIT:2> ) <EOL> indent = get_indent ( self . peek ( ) ) <EOL> method_fields = self . extract_fields ( indent , MethodField ) <EOL> lines = [ ] <EOL> if len ( method_fields ) > <NUM_LIT:0> : <EOL> name_length = max_name_length ( method_fields ) <EOL> method_length = max_header_length ( method_fields ) <EOL> desc_length = max_desc_length ( method_fields ) <EOL> first_column = len ( indent ) <EOL> second_column = first_column + method_length + name_length + <NUM_LIT> <EOL> first_column_str = '<STR_LIT:=>' * ( method_length + name_length + <NUM_LIT:12> ) <EOL> second_column_str = '<STR_LIT:=>' * desc_length <EOL> border = '<STR_LIT>' . format ( indent , <EOL> first_column_str , <EOL> second_column_str ) <EOL> length = len ( border ) <EOL> empty = length * '<STR_LIT:U+0020>' <EOL> headings = empty [ : ] <EOL> headings = replace_at ( '<STR_LIT>' , headings , first_column ) <EOL> headings = replace_at ( '<STR_LIT>' , headings , second_column ) <EOL> lines . append ( border ) <EOL> lines . append ( headings ) <EOL> lines . append ( border ) <EOL> for field in method_fields : <EOL> lines += field . to_rst ( length , first_column , second_column ) <EOL> lines . append ( border ) <EOL> lines = [ line . rstrip ( ) for line in lines ] <EOL> self . insert_lines ( lines , index ) <EOL> self . index += len ( lines ) <EOL> return <EOL> def _refactor_notes ( self , header ) : <EOL> """<STR_LIT>""" <EOL> descriptions = [ ] <EOL> index = self . index <EOL> self . remove_lines ( index , <NUM_LIT:2> ) <EOL> indent = get_indent ( self . peek ( ) ) <EOL> paragraph = self . get_next_paragraph ( ) <EOL> descriptions . append ( indent + '<STR_LIT>' ) <EOL> descriptions += add_indent ( paragraph ) <EOL> self . insert_lines ( descriptions , index ) <EOL> self . index += len ( descriptions ) <EOL> return descriptions </s>
