Esempio n. 1
0
    def get_next_block(self):
        """ Get the next item block from the docstring.

        The method reads the next item block in the docstring. The first line
        is assumed to be the Item header and the following lines to
        belong to the definition body::

            <header line>
                <definition>

        The end of the field is designated by a line with the same indent
        as the field header or two empty lines in sequence.

        """
        item_header = self.pop()
        sub_indent = get_indent(item_header) + ' '
        block = [item_header]
        while not self.eod:
            current = self.peek()
            next = self.peek(1)
            if is_empty(current) and is_empty(next):
                self.seek_to_next_non_empty_line()
                break
            elif is_empty(current) and not next.startswith(sub_indent):
                self.pop()
                break
            elif not is_empty(current) and not current.startswith(sub_indent):
                break
            else:
                line = self.pop()
                block += [line.rstrip()]
        return block
    def test_get_indent(self):
        output = get_indent('')
        self.assertEqual(output, '')

        output = get_indent('  _dgsdg 44')
        self.assertEqual(output, '  ')