def to_rst(self, length, first_column, second_column): split_result = re.split('\((.*)\)', self.name) method_name = split_result[0] method_text = ':meth:`{0} <{1}>`'.format(self.name, method_name) summary = ' '.join([line.strip() for line in self.desc]) line = ' ' * length line = replace_at(method_text, line, first_column) line = replace_at(summary, line, second_column) return [line]
def _refactor_methods(self, header): """Refactor the methods section to sphinx friendly format. """ if self.verbose: print '{0} section'.format(header) index = self.index self.remove_lines(index, 2) indent = get_indent(self.peek()) method_fields = self.extract_fields(indent, MethodField) lines = [] if len(method_fields) > 0 : name_length = max_name_length(method_fields) method_length = max_header_length(method_fields) desc_length = max_desc_length(method_fields) first_column = len(indent) second_column = first_column + method_length + name_length + 13 first_column_str = '=' * (method_length + name_length + 12) second_column_str = '=' * desc_length border = '{0}{1} {2}'.format(indent, first_column_str, second_column_str) length = len(border) empty = length * ' ' headings = empty[:] headings = replace_at('Methods', headings, first_column) headings = replace_at('Description', headings, second_column) lines.append(border) lines.append(headings) lines.append(border) for field in method_fields: lines += field.to_rst(length, first_column, second_column) lines.append(border) lines = [line.rstrip() for line in lines] self.insert_lines(lines, index) self.index += len(lines) return
def _refactor_methods(self, header): """Refactor the methods section to sphinx friendly format. """ if self.verbose: print '{0} section'.format(header) index = self.index self.remove_lines(index, 2) indent = get_indent(self.peek()) method_fields = self.extract_fields(indent, MethodField) lines = [] if len(method_fields) > 0: name_length = max_name_length(method_fields) method_length = max_header_length(method_fields) desc_length = max_desc_length(method_fields) first_column = len(indent) second_column = first_column + method_length + name_length + 13 first_column_str = '=' * (method_length + name_length + 12) second_column_str = '=' * desc_length border = '{0}{1} {2}'.format(indent, first_column_str, second_column_str) length = len(border) empty = length * ' ' headings = empty[:] headings = replace_at('Methods', headings, first_column) headings = replace_at('Description', headings, second_column) lines.append(border) lines.append(headings) lines.append(border) for field in method_fields: lines += field.to_rst(length, first_column, second_column) lines.append(border) lines = [line.rstrip() for line in lines] self.insert_lines(lines, index) self.index += len(lines) return