From 784be915d581c59596d745a930438ce5e1c7799f Mon Sep 17 00:00:00 2001
From: Sean Brant
Date: Sat, 13 Jul 2013 11:01:18 -0500
Subject: Fixes #4. Sections missing a reference are now ignored.
---
pykss/section.py | 5 ++++-
tests/test_section.py | 16 ++++++++++------
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 = 'ButtonButton'
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)
--
cgit v1.2.3