예제 #1
0
    def read(self) -> StringList:  # type: ignore
        inputstring = super().read()
        lines = string2lines(inputstring, convert_whitespace=True)
        content = StringList()
        for lineno, line in enumerate(lines):
            content.append(line, self.source_path, lineno)

        prepend_prolog(content, self.env.config.rst_prolog)
        append_epilog(content, self.env.config.rst_epilog)

        return content
예제 #2
0
파일: io.py 프로젝트: lmregus/Portfolio
    def read(self):  # type: ignore
        # type: () -> StringList
        inputstring = super().read()
        lines = string2lines(inputstring, convert_whitespace=True)
        content = StringList()
        for lineno, line in enumerate(lines):
            content.append(line, self.source_path, lineno)

        prepend_prolog(content, self.env.config.rst_prolog)
        append_epilog(content, self.env.config.rst_epilog)

        return content
예제 #3
0
def test_prepend_prolog_without_CR(app):
    # prolog not having CR at tail
    prolog = 'this is rst_prolog\nhello reST!'
    content = StringList(['hello Sphinx world',
                          'Sphinx is a document generator'],
                         'dummy.rst')
    prepend_prolog(content, prolog)

    assert list(content.xitems()) == [('<rst_prolog>', 0, 'this is rst_prolog'),
                                      ('<rst_prolog>', 1, 'hello reST!'),
                                      ('<generated>', 0, ''),
                                      ('dummy.rst', 0, 'hello Sphinx world'),
                                      ('dummy.rst', 1, 'Sphinx is a document generator')]
예제 #4
0
def test_prepend_prolog_without_CR(app):
    # prolog not having CR at tail
    prolog = 'this is rst_prolog\nhello reST!'
    content = StringList(
        ['hello Sphinx world', 'Sphinx is a document generator'], 'dummy.rst')
    prepend_prolog(content, prolog)

    assert list(content.xitems()) == [
        ('<rst_prolog>', 0, 'this is rst_prolog'),
        ('<rst_prolog>', 1, 'hello reST!'), ('<generated>', 0, ''),
        ('dummy.rst', 0, 'hello Sphinx world'),
        ('dummy.rst', 1, 'Sphinx is a document generator')
    ]
예제 #5
0
    def read(self):  # type: ignore
        # type: () -> StringList
        warnings.warn('SphinxRSTFileInput is deprecated.',
                      RemovedInSphinx30Warning, stacklevel=2)

        inputstring = super(SphinxRSTFileInput, self).read()
        lines = string2lines(inputstring, convert_whitespace=True)
        content = StringList()
        for lineno, line in enumerate(lines):
            content.append(line, self.source_path, lineno)

        prepend_prolog(content, self.env.config.rst_prolog)
        append_epilog(content, self.env.config.rst_epilog)

        return content
예제 #6
0
    def read(self):
        # type: () -> StringList
        warnings.warn('SphinxRSTFileInput is deprecated.',
                      RemovedInSphinx30Warning,
                      stacklevel=2)

        inputstring = super(SphinxRSTFileInput, self).read()
        lines = string2lines(inputstring, convert_whitespace=True)
        content = StringList()
        for lineno, line in enumerate(lines):
            content.append(line, self.source_path, lineno)

        prepend_prolog(content, self.env.config.rst_prolog)
        append_epilog(content, self.env.config.rst_epilog)

        return content
예제 #7
0
def test_prepend_prolog(app):
    prolog = 'this is rst_prolog\nhello reST!'
    content = StringList([
        ':title: test of SphinxFileInput', ':author: Sphinx team', '',
        'hello Sphinx world', 'Sphinx is a document generator'
    ], 'dummy.rst')
    prepend_prolog(content, prolog)

    assert list(content.xitems()) == [
        ('dummy.rst', 0, ':title: test of SphinxFileInput'),
        ('dummy.rst', 1, ':author: Sphinx team'), ('<generated>', 0, ''),
        ('<rst_prolog>', 0, 'this is rst_prolog'),
        ('<rst_prolog>', 1, 'hello reST!'), ('<generated>', 0, ''),
        ('dummy.rst', 2, ''), ('dummy.rst', 3, 'hello Sphinx world'),
        ('dummy.rst', 4, 'Sphinx is a document generator')
    ]
예제 #8
0
def test_prepend_prolog(app):
    prolog = 'this is rst_prolog\nhello reST!'
    content = StringList([':title: test of SphinxFileInput',
                          ':author: Sphinx team',
                          '',
                          'hello Sphinx world',
                          'Sphinx is a document generator'],
                         'dummy.rst')
    prepend_prolog(content, prolog)

    assert list(content.xitems()) == [('dummy.rst', 0, ':title: test of SphinxFileInput'),
                                      ('dummy.rst', 1, ':author: Sphinx team'),
                                      ('<generated>', 0, ''),
                                      ('<rst_prolog>', 0, 'this is rst_prolog'),
                                      ('<rst_prolog>', 1, 'hello reST!'),
                                      ('<generated>', 0, ''),
                                      ('dummy.rst', 2, ''),
                                      ('dummy.rst', 3, 'hello Sphinx world'),
                                      ('dummy.rst', 4, 'Sphinx is a document generator')]
예제 #9
0
 def decorate(self, content: StringList) -> None:
     """Preprocess reST content before parsing."""
     prepend_prolog(content, self.config.rst_prolog)
     append_epilog(content, self.config.rst_epilog)
예제 #10
0
 def decorate(self, content):
     # type: (StringList) -> None
     """Preprocess reST content before parsing."""
     prepend_prolog(content, self.config.rst_prolog)
     append_epilog(content, self.config.rst_epilog)