aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSean Brant2013-07-13 11:01:18 -0500
committerSean Brant2013-07-13 11:01:18 -0500
commit784be915d581c59596d745a930438ce5e1c7799f (patch)
tree56fc8d0e33cd9b9ccd8bef64f489ad95c4995329
parentfe8360e25afc60f6288470b88cdbccde61f265f3 (diff)
downloadpykss-784be915d581c59596d745a930438ce5e1c7799f.tar.bz2
Fixes #4. Sections missing a reference are now ignored.
-rw-r--r--pykss/section.py5
-rw-r--r--tests/test_section.py16
2 files changed, 14 insertions, 7 deletions
diff --git a/pykss/section.py b/pykss/section.py
index edbfb45..941c05f 100644
--- a/pykss/section.py
+++ b/pykss/section.py
@@ -28,6 +28,7 @@ class Section(object):
in_example = False
for line in self.comment.splitlines():
+ print line
if line.startswith(CLASS_MODIFIER) or line.startswith(PSEUDO_CLASS_MODIFIER):
try:
modifier, description = line.split(MODIFIER_DESCRIPTION_SEPARATOR)
@@ -41,7 +42,9 @@ class Section(object):
elif line.startswith(REFERENCE_START):
in_example = False
- self._reference = reference_re.match(line).groups()[0].rstrip('.')
+ match = reference_re.match(line)
+ if match:
+ self._reference = match.groups()[0].rstrip('.')
elif in_example is True:
self._example_lines.append(line)
diff --git a/tests/test_section.py b/tests/test_section.py
index 200e65e..f2cb57d 100644
--- a/tests/test_section.py
+++ b/tests/test_section.py
@@ -23,21 +23,25 @@ Styleguide 2.1.1.
"""
self.section = Section(comment.strip(), 'example.css')
- def test_parses_the_description(self):
+ def stest_parses_the_description(self):
self.assertEqual(self.section.description, '# Form Button\n\nYour standard form button.')
- def test_parses_the_modifiers(self):
+ def stest_parses_the_modifiers(self):
self.assertEqual(len(self.section.modifiers), 4)
- def test_parses_modifier_names(self):
+ def stest_parses_modifier_names(self):
self.assertEqual(self.section.modifiers[0].name, ':hover')
- def test_parses_modifier_descriptions(self):
+ def stest_parses_modifier_descriptions(self):
self.assertEqual(self.section.modifiers[0].description, 'Highlights when hovering.')
- def test_parses_the_example(self):
+ def stest_parses_the_example(self):
expected = '<a href="#" class="button">Button</a><a href="#">Button</a>'
self.assertEqual(self.section.example, expected)
- def test_parses_the_styleguide_reference(self):
+ def stest_parses_the_styleguide_reference(self):
self.assertEqual(self.section.section, '2.1.1')
+
+ def test_handles_when_no_reference(self):
+ self.section = Section('Styleguide', 'example.css')
+ self.assertEqual(self.section.section, None)