Exemple #1
0
class ModiferTestCase(unittest.TestCase):
    def setUp(self):
        self.modifier = Modifier('.callout.extreme:hover', 'calls things out')

    def test_handles_pseudo(self):
        self.assertTrue('pseudo-class-hover' in self.modifier.class_name)

    def test_handles_multiple_classes(self):
        self.assertTrue('callout extreme' in self.modifier.class_name)

    def test_add_example(self):
        example = '<i class="icon$modifier_class"></i>'
        expected = '<i class="icon callout extreme pseudo-class-hover"></i>'

        self.modifier.add_example(example)
        self.assertEqual(self.modifier.example, expected)
Exemple #2
0
class ModiferTestCase(unittest.TestCase):

    def setUp(self):
        self.modifier = Modifier('.callout.extreme:hover', 'calls things out')

    def test_handles_pseudo(self):
        self.assertTrue('pseudo-class-hover' in self.modifier.class_name)

    def test_handles_multiple_classes(self):
        self.assertTrue('callout extreme' in self.modifier.class_name)

    def test_add_example(self):
        example = '<i class="icon$modifier_class"></i>'
        expected = '<i class="icon callout extreme pseudo-class-hover"></i>'

        self.modifier.add_example(example)
        self.assertEqual(self.modifier.example, expected)
Exemple #3
0
    def parse(self):
        self._description_lines = []
        self._modifiers = []
        self._example_lines = []
        self._reference = None

        in_example = False
        in_modifiers = False

        for line in self.comment.splitlines():
            if line.startswith(CLASS_MODIFIER) or line.startswith(
                    PSEUDO_CLASS_MODIFIER):
                in_modifiers = True
                try:
                    modifier, description = line.split(
                        MODIFIER_DESCRIPTION_SEPARATOR)
                except ValueError:
                    pass
                else:
                    self._modifiers.append(
                        Modifier(modifier.strip(), description.strip()))

            elif in_modifiers and multiline_modifier_re.match(line):
                match = multiline_modifier_re.match(line)
                if match:
                    description = match.groups()[0]
                    last_modifier = self._modifiers[-1]
                    last_modifier.description += ' {0}'.format(description)

            elif line.startswith(EXAMPLE_START):
                in_example = True
                in_modifiers = False

            elif line.startswith(REFERENCE_START):
                in_example = False
                in_modifiers = False
                match = reference_re.match(line)
                if match:
                    self._reference = match.groups()[0].rstrip('.')

            elif in_example is True:
                self._example_lines.append(line)

            else:
                in_modifiers = False
                self._description_lines.append(line)

        self._description = '\n'.join(self._description_lines).strip()
        self.add_example('\n'.join(self._example_lines).strip())
Exemple #4
0
 def setUp(self):
     self.modifier = Modifier('.callout.extreme:hover', 'calls things out')
Exemple #5
0
 def setUp(self):
     self.modifier = Modifier('.callout.extreme:hover', 'calls things out')