Changeset a400958 in rtems-central


Ignore:
Timestamp:
Mar 17, 2020, 1:29:26 PM (17 months ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
28b8f50
Parents:
b459114
git-author:
Sebastian Huber <sebastian.huber@…> (03/17/20 13:29:26)
git-committer:
Sebastian Huber <sebastian.huber@…> (03/17/20 15:27:24)
Message:

content: Add method to add lines

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • rtemsqual/content.py

    rb459114 ra400958  
    119119
    120120
     121def _make_lines(lines):
     122    if not isinstance(lines, list):
     123        return lines.strip("\n").split("\n")
     124    return lines
     125
     126
    121127class SphinxContent(object):
    122128    """ This class builds Sphinx content. """
     
    150156        else:
    151157            self._content += "\n"
     158
     159    def add_lines(self, lines, indent=0):
     160        """ Adds a lines to the content. """
     161        for line in _make_lines(lines):
     162            self.add_line(line, indent)
    152163
    153164    def add_index_entries(self, entries):
  • tests/test_content.py

    rb459114 ra400958  
    108108        assert "x\n    y\n\n" == sc.content
    109109
     110    def test_add_lines(self):
     111        sc = SphinxContent()
     112        sc.add_lines("x")
     113        assert sc.content == "x\n"
     114        sc.add_lines("y", 1)
     115        assert sc.content == "x\n    y\n"
     116        sc.add_lines(["a", "b"])
     117        assert sc.content == "x\n    y\na\nb\n"
     118
    110119    def test_add_index_entries(self):
    111120        sc = SphinxContent()
Note: See TracChangeset for help on using the changeset viewer.