Exemple #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
def test_append_epilog(app):
    epilog = 'this is rst_epilog\ngood-bye reST!'
    content = StringList(['hello Sphinx world',
                          'Sphinx is a document generator'],
                         'dummy.rst')
    append_epilog(content, epilog)

    assert list(content.xitems()) == [('dummy.rst', 0, 'hello Sphinx world'),
                                      ('dummy.rst', 1, 'Sphinx is a document generator'),
                                      ('<generated>', 0, ''),
                                      ('<rst_epilog>', 0, 'this is rst_epilog'),
                                      ('<rst_epilog>', 1, 'good-bye reST!')]
Exemple #3
0
def test_append_epilog(app):
    epilog = 'this is rst_epilog\ngood-bye reST!'
    content = StringList(
        ['hello Sphinx world', 'Sphinx is a document generator'], 'dummy.rst')
    append_epilog(content, epilog)

    assert list(content.xitems()) == [
        ('dummy.rst', 0, 'hello Sphinx world'),
        ('dummy.rst', 1, 'Sphinx is a document generator'),
        ('dummy.rst', 2, ''), ('<rst_epilog>', 0, 'this is rst_epilog'),
        ('<rst_epilog>', 1, 'good-bye reST!')
    ]
Exemple #4
0
    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
Exemple #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
Exemple #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
Exemple #7
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)
Exemple #8
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)