コード例 #1
0
 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]
コード例 #2
0
ファイル: fields.py プロジェクト: 5n1p/enaml
 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]
コード例 #3
0
ファイル: class_doc.py プロジェクト: 5n1p/enaml
    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
コード例 #4
0
ファイル: class_doc.py プロジェクト: zyex1108/pyface
    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