Changeset 28b8f50 in rtems-central


Ignore:
Timestamp:
Mar 17, 2020, 2:45:40 PM (17 months ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
9144b6b
Parents:
a400958
git-author:
Sebastian Huber <sebastian.huber@…> (03/17/20 14:45:40)
git-committer:
Sebastian Huber <sebastian.huber@…> (03/17/20 15:27:24)
Message:

content: Add helper to accept a string or a list

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • rtemsqual/content.py

    ra400958 r28b8f50  
    125125
    126126
     127def _make_list(value):
     128    if not isinstance(value, list):
     129        return [value]
     130    return value
     131
     132
    127133class SphinxContent(object):
    128134    """ This class builds Sphinx content. """
     
    165171        """ Adds a list of index entries the content. """
    166172        first = True
    167         for entry in entries:
     173        for entry in _make_list(entries):
    168174            if first:
    169175                first = False
  • tests/test_content.py

    ra400958 r28b8f50  
    120120        sc = SphinxContent()
    121121        sc.add_index_entries(["x", "y"])
    122         assert "\n.. index:: x\n.. index:: y\n", sc.content
     122        assert "\n.. index:: x\n.. index:: y\n" == sc.content
     123        sc.add_index_entries("z")
     124        assert "\n.. index:: x\n.. index:: y\n\n.. index:: z\n" == sc.content
    123125
    124126    def test_add_definition_item(self):
Note: See TracChangeset for help on using the changeset viewer.